From 7486a38445e16fc17505c5f3e6afd7f8f8e87aeb Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 18 Dec 2005 03:19:40 +0000 Subject: use GtkAboutDialog instead of custom dialog (Fixes bug #309405). remove 2005-12-18 Lucas Rocha * src/about.c: use GtkAboutDialog instead of custom dialog (Fixes bug #309405). * src/zenity.glade: remove zenity_about_dialog. * configure.in: zenity now depends on GTK+ >= 2.6.x because now it uses GtkAboutDialog. --- src/about.c | 379 ++++++++---------------------------------------------------- 1 file changed, 47 insertions(+), 332 deletions(-) (limited to 'src/about.c') diff --git a/src/about.c b/src/about.c index 07578236..2fe95aa7 100644 --- a/src/about.c +++ b/src/about.c @@ -30,7 +30,6 @@ #include #include #include -#include #define GTK_RESPONSE_CREDITS 0 #define ZENITY_HELP_PATH ZENITY_DATADIR "/help/" @@ -40,165 +39,27 @@ #define ZENITY_CANVAS_Y 280.0 static GtkWidget *dialog; -static GtkWidget *cred_dialog; +static void zenity_about_display_help (GtkWidget *widget, gpointer data); static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data); /* Sync with the people in the THANKS file */ -static const gchar *const author_credits[] = { - "Authors", - "=======", +static const gchar *const authors[] = { "Glynn Foster ", + "Lucas Rocha ", "Mike Newman ", - "", - "Patches from the following people", - "=================================", - "Darren Adams " - "Peter Astrand ", - "Jonathan Blandford ", - "Paul Bolle ", - "Paolo Borelli ", - "Leonardo Boshell

", - "Ross Burton ", - "Damien Carbery ", - "Anders Carlsson ", - "Ed Catmur ", - "Nicholas Curran ", - "John Fleck ", - "Sebastian Heinlein ", - "James Henstridge ", - "Chris Lahey ", - "Mihai T Lazarescu ", - "Sebastian Kapfer ", - "Tomasz Koczko ", - "Jordi Mallach ", - "Kjartan Maraas ", - "Breda McColgan ", - "Baptiste Mille-Mathias ", - "Buhan Milne ", - "Christian Monneckes ", - "Ivan Noris ", - "Havoc Pennington ", - "Jan Arne Petersen ", - "Kevin C Krinke ", - "Kristian Rietveld ", - "Lucas Rocha ", - "Christian Rose ", - "Jakub Steiner ", - "Luke Suchocki ", - "Daniel d'Surreal ", - "Hidetoshi Tajima ", - "Tom Tromey ", - "Yann ", - "Norman Rasmussen ", - "Benoît Dejean ", - "", - "And all the translators that rock my world", - "==========================================", - "Vincent van Adrighem ", - "Taneem Ahmed ", - "Takeshi Aihana ", - "Amanpreet Singh Alam ", - "Metin Amiroff ", - "Sanlig Badral ", - "John C Barstow ", - "Aygimantas Beruka ", - "Alberto Fernandez Benito ", - "Stefano Canepa ", - "Young-Ho Cha ", - "Abel Cheung ", - "Zbigniew Chyla ", - "Mohammad Damt ", - "Fatih Demir ", - "Laurent Dhima ", - "Paul Duffy ", - "Laszlo Dvornik ", - "Maxim Dziumanenko ", - "Francisco Javier Fernandez ", - "Artur Flinta ", - "Alessio Frusciante ", - "Evandro Fernandes Giovanini ", - "Pablo Gonzalo del Campo ", - "Dhurba Gnawali ", - "Sammi Gunnarsson ", - "Martin Willemoes Hansen ", - "Dafydd Harries ", - "Raphael Higino ", - "Wang Jian ", - "Guntupalli Karunakar ", - "Tomas Kuliavas ", - "Priit Laes ", - "Iaki Larraaga ", - "Ole Laursen ", - "Toivo Leedjrv ", - "David Lodge ", - "Duarte Loreto ", - "Johanna Makkonen ", - "Jordi Mallach ", - "Kjartan Maraas ", - "Jordi Mas ", - "Kamagasako Masatoshi ", - "Dmitry G Mastrukov ", - "Arafat Medini ", - "Christophe Merlet ", - "Mike Newman ", - "Ahmad Riza H Nst ", - "Alexandre Folle de Menezes ", - "Christian Neumair ", - "Metin Omirov ", - "Gareth Owen ", - "Kostas Papadimas ", - "Ankit Patel ", - "Sami Pesonen ", - "Roozbeh Pournader ", - "Jarkko Ranta ", - "Rostislav Raykov ", - "Hendrik Richter ", - "Christian Rose ", - "Changwoo Ryu ", - "Pablo Saratxaga ", - "Robert Sedak ", - "Paisa Seeluangsawat ", - "Danilo Segan ", - "Alexander Shopov ", - "Aasmund Skjaveland ", - "Yuriy Syrota ", - "Marcel Telka ", - "Andras Timar ", - "Miloslav Trmac ", - "Mugurel Tudor ", - "Daniel Yacob ", - "Funda Wang ", - "Alexander Winston ", - "Theppitak Karoonboonyanan ", - "Martin Willemoes Hansen ", - "Ignacio Casal Quinteiro ", - "Pawan Chitrakar ", - "Rajesh Ranjan ", - "Vladimir Petkov ", - "Abduxukur Abdurixit ", - "Adi Attar ", - "Steve Murphy ", - "Josep Puigdemont ", - "Adam Weinberger ", - "Ivar Smolin ", - "Jens Seidel ", - "Benoît Dejean ", - "Yair Hershkovitz ", - "Clytie Siddall ", - "Ilkka Tuohela ", - "Chao-Hsiung Liao ", - "Žygimantas Beručka ", - "Gabor Kelemen ", - "Telsa Gwynne ", - "Slobodan D. Sredojevic ", - "Baris Cicek ", - "Runa Bhattacharjee ", - "Erdal Ronahi ", NULL }; -static gchar *translator_credits; +static const char *documenters[] = { + "Glynn Foster ", + "Lucas Rocha ", + "Java Desktop System Documentation Team", + "GNOME Documentation Project", + NULL +}; + +static gchar *translators; static gint zenity_move_clothes_event (GnomeCanvasItem *item, @@ -381,214 +242,68 @@ zenity_zen_wisdom (GtkDialog *dialog, GdkEventKey *event, gpointer user_data) void zenity_about (ZenityData *data) { - GladeXML *glade_dialog = NULL; - GdkPixbuf *pixbuf; - GtkWidget *label; - GtkWidget *image; - gchar *text; + GdkPixbuf *logo; + GtkWidget *help_button; - glade_dialog = zenity_util_load_glade_file ("zenity_about_dialog"); + translators = _("translator-credits"); + logo = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); - if (glade_dialog == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - /* Translators: This is a special message that shouldn't be translated - literally. It is used in the about box to give credits to - the translators. - Thus, you should translate it to your name and email address. - You can also include other translators who have contributed to - this translation; in that case, please write them on separate - lines seperated by newlines (\n). */ + dialog = gtk_about_dialog_new (); - translator_credits = _("translator-credits"); + g_object_set (G_OBJECT (dialog), + "name", "Zenity", + "version", VERSION, + "copyright", "Copyright \xc2\xa9 2003 Sun Microsystems", + "comments", _("Display dialog boxes from shell scripts"), + "authors", authors, + "documenters", documenters, + "translator-credits", translators, + "logo", logo, + NULL); - glade_xml_signal_autoconnect (glade_dialog); + zenity_util_set_window_icon (dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); - dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog"); + help_button = gtk_button_new_from_stock (GTK_STOCK_HELP); + + g_signal_connect (G_OBJECT (help_button), "clicked", + G_CALLBACK (zenity_about_display_help), data); + + gtk_widget_show (help_button); + + gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->action_area), + help_button, FALSE, TRUE, 0); + gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), + help_button, TRUE); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_about_dialog_response), data); g_signal_connect (G_OBJECT (dialog), "key_press_event", - G_CALLBACK (zenity_zen_wisdom), glade_dialog); - - zenity_util_set_window_icon (dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); - - image = glade_xml_get_widget (glade_dialog, "zenity_about_image"); - - pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); - - if (pixbuf != NULL) { - gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); - g_object_unref (pixbuf); - } - - label = glade_xml_get_widget (glade_dialog, "zenity_about_version"); - gtk_label_set_selectable (GTK_LABEL (label), FALSE); - text = g_strdup_printf ("Zenity %s", VERSION); - gtk_label_set_markup (GTK_LABEL (label), text); - g_free (text); - - label = glade_xml_get_widget (glade_dialog, "zenity_about_description"); - gtk_label_set_selectable (GTK_LABEL (label), FALSE); - gtk_label_set_text (GTK_LABEL (label), _("Display dialog boxes from shell scripts")); - - label = glade_xml_get_widget (glade_dialog, "zenity_about_copyright"); - gtk_label_set_selectable (GTK_LABEL (label), FALSE); - text = g_strdup_printf ("%s", _("(C) 2003 Sun Microsystems")); - gtk_label_set_markup (GTK_LABEL (label), text); - g_free (text); - - if (glade_dialog) - g_object_unref (glade_dialog); + G_CALLBACK (zenity_zen_wisdom), NULL); zenity_util_show_dialog (dialog); gtk_main (); } -static GtkWidget * -zenity_about_create_label (void) -{ - GtkWidget *label; - - label = gtk_label_new (""); - gtk_label_set_selectable (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); - gtk_misc_set_padding (GTK_MISC (label), 8, 8); - - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - - return label; -} - -static void -zenity_about_update_author_label (GtkWidget *label) -{ - GString *string; - gchar *tmp; - gint i = 0; - - gtk_widget_show (label); - - string = g_string_new (""); - - for (i = 0; author_credits[i] != NULL; i++) { - tmp = g_markup_escape_text (author_credits[i], -1); - g_string_append (string, tmp); - - if (author_credits[i+1] != NULL) - g_string_append (string, "\n"); - - g_free (tmp); - } - gtk_label_set_markup (GTK_LABEL (label), string->str); - g_string_free (string, TRUE); -} - -static void -zenity_about_update_translator_label (GtkWidget *label) -{ - GString *string; - gchar *tmp; - - if (strcmp (translator_credits, "translator-credits") == 0) { - gtk_widget_hide (label); - return; - } else { - gtk_widget_show (label); - } - - string = g_string_new (""); - - tmp = g_markup_escape_text (translator_credits, -1); - g_string_append (string, tmp); - g_free (tmp); - - gtk_label_set_markup (GTK_LABEL (label), string->str); - g_string_free (string, TRUE); -} - -static void -zenity_about_display_credits_dialog (void) -{ - GtkWidget *credits_dialog; - GtkWidget *label, *notebook, *sw; - - if (cred_dialog != NULL) { - gtk_window_present (GTK_WINDOW (cred_dialog)); - return; - } - - credits_dialog = gtk_dialog_new_with_buttons (_("Credits"), - GTK_WINDOW (dialog), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - - g_signal_connect (G_OBJECT (credits_dialog), "response", - G_CALLBACK (gtk_widget_destroy), credits_dialog); - g_signal_connect (G_OBJECT (credits_dialog), "destroy", - G_CALLBACK (gtk_widget_destroyed), &cred_dialog); - - cred_dialog = credits_dialog; - - gtk_window_set_default_size (GTK_WINDOW (credits_dialog), 360, 260); - gtk_dialog_set_default_response (GTK_DIALOG (credits_dialog), GTK_RESPONSE_OK); - - notebook = gtk_notebook_new (); - gtk_container_set_border_width (GTK_CONTAINER (notebook), 8); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (credits_dialog)->vbox), notebook, TRUE, TRUE, 0); - - if (author_credits != NULL) { - label = zenity_about_create_label (); - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, - gtk_label_new (_("Written by"))); - zenity_about_update_author_label (label); - } - - if (translator_credits != NULL && strcmp (translator_credits, "translator-credits") != 0) { - label = zenity_about_create_label (); - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, - gtk_label_new (_("Translated by"))); - zenity_about_update_translator_label (label); - } - - gtk_widget_show_all (credits_dialog); -} - static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; switch (response) { - case GTK_RESPONSE_OK: + case GTK_RESPONSE_CLOSE: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); break; - case GTK_RESPONSE_HELP: - zenity_util_show_help (NULL); - break; - - case GTK_RESPONSE_CREDITS: - zenity_about_display_credits_dialog (); - break; - default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } + +static void +zenity_about_display_help (GtkWidget *widget, gpointer data) +{ + zenity_util_show_help (NULL); +} -- cgit