From 3f33966167cf2216f813c091d47461c451837602 Mon Sep 17 00:00:00 2001 From: Felix Riemann Date: Mon, 20 Jul 2009 10:23:32 +0200 Subject: =?UTF-8?q?Bug=20578393=20=E2=80=93=20convert=20from=20libglade=20?= =?UTF-8?q?to=20GtkBuilder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configure.in | 2 +- po/POTFILES.in | 2 +- po/POTFILES.skip | 1 + src/Makefile.am | 8 +- src/calendar.c | 23 +- src/entry.c | 24 +- src/fileselection.c | 1 - src/msg.c | 48 +- src/notification.c | 1 - src/progress.c | 41 +- src/scale.c | 29 +- src/text.c | 19 +- src/tree.c | 34 +- src/util.c | 60 +- src/util.h | 8 +- src/zenity.ui | 1854 +++++++++++++++++++++++++++++++++++++++++++++++++++ 16 files changed, 2019 insertions(+), 136 deletions(-) create mode 100644 src/zenity.ui diff --git a/configure.in b/configure.in index d688ead..8c30444 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_PROG_CC GTK_REQUIRED=2.15.1 -PKG_CHECK_MODULES([ZENITY],[gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 glib-2.0]) +PKG_CHECK_MODULES([ZENITY],[gtk+-2.0 >= $GTK_REQUIRED glib-2.0]) AC_SUBST([ZENITY_CFLAGS]) AC_SUBST([ZENITY_LIBS]) diff --git a/po/POTFILES.in b/po/POTFILES.in index 958855f..09b36c7 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -4,5 +4,5 @@ src/notification.c src/scale.c src/tree.c src/util.c -src/zenity.glade +[type: gettext/glade]src/zenity.ui src/option.c diff --git a/po/POTFILES.skip b/po/POTFILES.skip index c66bc6f..c834f54 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -6,4 +6,5 @@ src/progress.c src/text.c src/util.h src/util.c +src/zenity.glade src/zenity.h diff --git a/src/Makefile.am b/src/Makefile.am index e70a51b..30f7ccd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -40,15 +40,15 @@ zenity_LDADD = \ $(LIBNOTIFY_LIBS) \ $(X_LIBS) -gladedir = $(datadir)/zenity +uidir = $(datadir)/zenity -glade_DATA = \ - zenity.glade +ui_DATA = \ + zenity.ui DISTCLEANFILES= \ gdialog EXTRA_DIST = \ - $(glade_DATA) \ + $(ui_DATA) \ gdialog \ gdialog.in diff --git a/src/calendar.c b/src/calendar.c index e05950c..8ad53ea 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include #include "zenity.h" #include "util.h" @@ -38,22 +37,23 @@ static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data); void zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { - GladeXML *glade_dialog = NULL; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text; + GObject *text; zen_cal_data = cal_data; - glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); + builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_calendar_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_calendar_dialog_response), data); @@ -66,16 +66,13 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); + text = gtk_builder_get_object (builder, "zenity_calendar_text"); if (cal_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (cal_data->dialog_text)); - calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); + calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar")); - if (glade_dialog) - g_object_unref (glade_dialog); - if (cal_data->month > 0 || cal_data->year > 0) gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); if (cal_data->day > 0) @@ -91,6 +88,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); } + g_object_unref (builder); + gtk_main (); } diff --git a/src/entry.c b/src/entry.c index dcd0985..9c02095 100644 --- a/src/entry.c +++ b/src/entry.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -46,23 +45,23 @@ zenity_entry_fill_entries (GSList **entries, const gchar **args) void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { - GladeXML *glade_dialog = NULL; + GtkBuilder *builder = NULL; GtkWidget *dialog; - GtkWidget *text; + GObject *text; GSList *entries = NULL; GSList *tmp; - GtkWidget *vbox; + GObject *vbox; - glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); + builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_entry_dialog_response), data); @@ -75,12 +74,12 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); + text = gtk_builder_get_object (builder, "zenity_entry_text"); if (entry_data->dialog_text) gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); - vbox = glade_xml_get_widget (glade_dialog, "vbox4"); + vbox = gtk_builder_get_object (builder, "vbox4"); zenity_entry_fill_entries(&entries, entry_data->data); @@ -113,11 +112,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); - if (glade_dialog) - g_object_unref (glade_dialog); - gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); + g_object_unref (builder); + zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { diff --git a/src/fileselection.c b/src/fileselection.c index 4cfa051..dd4ab0d 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include #include "zenity.h" #include "util.h" diff --git a/src/msg.c b/src/msg.c index 0364268..cf0e47d 100644 --- a/src/msg.c +++ b/src/msg.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -55,56 +54,53 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data void zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { - GladeXML *glade_dialog; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text; + GObject *text; switch (msg_data->mode) { case ZENITY_MSG_WARNING: - glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_warning_text"); + builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog")); + text = gtk_builder_get_object (builder, "zenity_warning_text"); break; case ZENITY_MSG_QUESTION: - glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_question_text"); + builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_question_dialog")); + text = gtk_builder_get_object (builder, "zenity_question_text"); break; case ZENITY_MSG_ERROR: - glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); + builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog")); + text = gtk_builder_get_object (builder, "zenity_error_text"); break; case ZENITY_MSG_INFO: - glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog"); - dialog= glade_xml_get_widget (glade_dialog, "zenity_info_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_info_text"); + builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog")); + text = gtk_builder_get_object (builder, "zenity_info_text"); break; default: - glade_dialog = NULL; + builder = NULL; dialog = NULL; text = NULL; g_assert_not_reached (); break; } - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_msg_dialog_response), data); - - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - - glade_xml_signal_autoconnect (glade_dialog); - - if (glade_dialog) - g_object_unref (glade_dialog); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_msg_dialog_response), data); + + gtk_builder_connect_signals (builder, NULL); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -145,6 +141,8 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); } + g_object_unref (builder); + gtk_main (); } diff --git a/src/notification.c b/src/notification.c index 6c8f746..1d80fa1 100644 --- a/src/notification.c +++ b/src/notification.c @@ -25,7 +25,6 @@ #include #include -#include #include #include diff --git a/src/progress.c b/src/progress.c index ffd8707..a17a36a 100644 --- a/src/progress.c +++ b/src/progress.c @@ -29,11 +29,10 @@ #include #include #include -#include #include "zenity.h" #include "util.h" -static GladeXML *glade_dialog; +static GtkBuilder *builder; static ZenityData *zen_data; static GIOChannel *channel; @@ -57,14 +56,14 @@ zenity_progress_handle_stdin (GIOChannel *channel, gpointer data) { static ZenityProgressData *progress_data; - static GtkWidget *progress_bar; - static GtkWidget *progress_label; + static GObject *progress_bar; + static GObject *progress_label; static gint pulsate_timeout = -1; float percentage = 0.0; progress_data = (ZenityProgressData *) data; - progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); - progress_label = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); + progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); + progress_label = gtk_builder_get_object (builder, "zenity_progress_text"); if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { GString *string; @@ -114,8 +113,8 @@ zenity_progress_handle_stdin (GIOChannel *channel, /* Now try to convert the thing to a number */ percentage = atoi (string->str); if (percentage >= 100) { - GtkWidget *button; - button = glade_xml_get_widget( glade_dialog,"zenity_progress_ok_button"); + GObject *button; + button = gtk_builder_get_object(builder, "zenity_progress_ok_button"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); gtk_widget_grab_focus(GTK_WIDGET (button)); @@ -136,11 +135,13 @@ zenity_progress_handle_stdin (GIOChannel *channel, /* We assume that we are done, so stop the pulsating and de-sensitize the buttons */ GtkWidget *button; - button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); + button = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_progress_ok_button")); gtk_widget_set_sensitive (button, TRUE); gtk_widget_grab_focus (button); - button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); + button = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_progress_cancel_button")); gtk_widget_set_sensitive (button, FALSE); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); @@ -150,8 +151,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, pulsate_timeout = -1; } - if (glade_dialog) - g_object_unref (glade_dialog); + g_object_unref (builder); if (progress_data->autoclose) { zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); @@ -177,20 +177,21 @@ void zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { GtkWidget *dialog; - GtkWidget *text; - GtkWidget *progress_bar; + GObject *text; + GObject *progress_bar; zen_data = data; - glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); + builder = zenity_util_load_ui_file ("zenity_progress_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_progress_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_progress_dialog_response), data); @@ -203,12 +204,12 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - text = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); + text = gtk_builder_get_object (builder, "zenity_progress_text"); if (progress_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (progress_data->dialog_text)); - progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); + progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); if (progress_data->percentage > -1) gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), diff --git a/src/scale.c b/src/scale.c index d69bd8a..8678774 100644 --- a/src/scale.c +++ b/src/scale.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -35,23 +34,24 @@ static void zenity_scale_dialog_response (GtkWidget *widget, int response, gpoin void zenity_scale (ZenityData *data, ZenityScaleData *scale_data) { - GladeXML *glade_dialog; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text; + GObject *text; - glade_dialog = zenity_util_load_glade_file ("zenity_scale_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_scale_dialog"); - scale = glade_xml_get_widget (glade_dialog, "zenity_scale_hscale"); - text = glade_xml_get_widget (glade_dialog, "zenity_scale_text"); + builder = zenity_util_load_ui_file ("zenity_scale_dialog", "adjustment1", NULL); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_scale_dialog_response), data); - - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_dialog")); + scale = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_hscale")); + text = gtk_builder_get_object (builder, "zenity_scale_text"); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_scale_dialog_response), data); + if (scale_data->min_value >= scale_data->max_value) { g_printerr (_("Maximum value must be greater than minimum value.\n")); data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); @@ -65,11 +65,8 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - if (glade_dialog) - g_object_unref (glade_dialog); - if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -98,6 +95,8 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); } + g_object_unref (builder); + gtk_main (); } diff --git a/src/text.c b/src/text.c index bdd8e0c..25bd768 100644 --- a/src/text.c +++ b/src/text.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -102,22 +101,23 @@ zenity_text_fill_entries_from_stdin (GtkTextBuffer *text_buffer) void zenity_text (ZenityData *data, ZenityTextData *text_data) { - GladeXML *glade_dialog = NULL; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text_view; + GObject *text_view; GtkTextBuffer *text_buffer; zen_text_data = text_data; - glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog"); + builder = zenity_util_load_ui_file ("zenity_text_dialog", + "textbuffer1", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_text_dialog_response), data); @@ -130,7 +130,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); text_buffer = gtk_text_buffer_new (NULL); - text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view"); + text_view = gtk_builder_get_object (builder, "zenity_text_view"); gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer); gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), text_data->editable); @@ -149,8 +149,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) zenity_util_show_dialog (dialog); - if (glade_dialog) - g_object_unref (glade_dialog); + g_object_unref (builder); if(data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); diff --git a/src/tree.c b/src/tree.c index 3237cde..da2cf47 100644 --- a/src/tree.c +++ b/src/tree.c @@ -25,7 +25,6 @@ #include "config.h" -#include #include #include #include "zenity.h" @@ -34,7 +33,7 @@ #define MAX_ELEMENTS_BEFORE_SCROLLING 5 #define PRINT_HIDE_COLUMN_SEPARATOR "," -static GladeXML *glade_dialog; +static GtkBuilder *builder; static GSList *selected; static gchar *separator; static gboolean print_all_columns = FALSE; @@ -168,7 +167,8 @@ zenity_tree_handle_stdin (GIOChannel *channel, GtkRequisition rectangle; gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); - scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); + scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_tree_window")); gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -245,7 +245,8 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, GtkRequisition rectangle; gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); - scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); + scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_tree_window")); gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -281,8 +282,8 @@ void zenity_tree (ZenityData *data, ZenityTreeData *tree_data) { GtkWidget *dialog; - GtkWidget *tree_view; - GtkWidget *text; + GObject *tree_view; + GObject *text; GtkTreeViewColumn *column; GtkListStore *model; GType *column_types; @@ -290,9 +291,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gboolean first_column = FALSE; gint i, column_index, n_columns; - glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog"); + builder = zenity_util_load_ui_file ("zenity_tree_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -328,9 +329,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_tree_dialog_response), data); @@ -338,7 +339,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - text = glade_xml_get_widget (glade_dialog, "zenity_tree_text"); + text = gtk_builder_get_object (builder, "zenity_tree_text"); if (tree_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (tree_data->dialog_text)); @@ -348,10 +349,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); + tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); if (!(tree_data->radiobox || tree_data->checkbox)) - g_signal_connect (G_OBJECT (tree_view), "row-activated", + g_signal_connect (tree_view, "row-activated", G_CALLBACK (zenity_tree_row_activated), data); /* Create an empty list store */ @@ -500,8 +501,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_main (); - if (glade_dialog) - g_object_unref (glade_dialog); + g_object_unref (builder); } static void @@ -591,13 +591,13 @@ static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; - GtkWidget *tree_view; + GObject *tree_view; GtkTreeSelection *selection; GtkTreeModel *model; switch (response) { case GTK_RESPONSE_OK: - tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); + tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) diff --git a/src/util.c b/src/util.c index cf34579..036e2b5 100644 --- a/src/util.c +++ b/src/util.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "config.h" #include "util.h" #include "zenity.h" @@ -48,27 +49,62 @@ #define ZENITY_ERROR_DEFAULT -1 #define ZENITY_EXTRA_DEFAULT 127 -GladeXML* -zenity_util_load_glade_file (const gchar *widget_root) +GtkBuilder* +zenity_util_load_ui_file (const gchar *root_widget, ...) { - GladeXML *xml = NULL; + va_list args; + gchar *arg = NULL; + GPtrArray *ptrarray; + GtkBuilder *builder = gtk_builder_new (); + GError *error = NULL; + gchar **objects; + guint result = 0; - if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) { + gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); + + /* We have at least the root_widget and a NULL */ + ptrarray = g_ptr_array_sized_new (2); + + g_ptr_array_add (ptrarray, g_strdup (root_widget)); + + va_start (args, root_widget); + + arg = va_arg (args, gchar*); + + while (arg) { + g_ptr_array_add (ptrarray, g_strdup (arg)); + arg = va_arg (args, gchar*); + } + va_end (args); + + /* Enforce terminating NULL */ + g_ptr_array_add (ptrarray, NULL); + objects = (gchar**) g_ptr_array_free (ptrarray, FALSE); + + if (g_file_test (ZENITY_UI_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) { /* Try current dir, for debugging */ - xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE); + result = gtk_builder_add_objects_from_file (builder, + ZENITY_UI_FILE_RELATIVEPATH, + objects, NULL); } - - if (xml == NULL) - xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE); - if (xml == NULL) { - g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH); + if (result == 0) + result = gtk_builder_add_objects_from_file (builder, + ZENITY_UI_FILE_FULLPATH, + objects, &error); + + g_strfreev (objects); + + if (result == 0) { + g_warning ("Could not load ui file %s: %s", ZENITY_UI_FILE_FULLPATH, + error->message); + g_error_free (error); + g_object_unref (builder); return NULL; } - return xml; + return builder; } - gchar* zenity_util_strip_newline (gchar *string) { diff --git a/src/util.h b/src/util.h index 4815da2..2bf154e 100644 --- a/src/util.h +++ b/src/util.h @@ -2,16 +2,16 @@ #define UTIL_H #include -#include #include "zenity.h" G_BEGIN_DECLS -#define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade" -#define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade" +#define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui" +#define ZENITY_UI_FILE_RELATIVEPATH "./zenity.ui" + #define ZENITY_IMAGE_FULLPATH(filename) (ZENITY_DATADIR "/" filename) -GladeXML* zenity_util_load_glade_file (const gchar *widget_root); +GtkBuilder* zenity_util_load_ui_file (const gchar *widget_root, ...) G_GNUC_NULL_TERMINATED; gchar * zenity_util_strip_newline (gchar *string); gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename); diff --git a/src/zenity.ui b/src/zenity.ui new file mode 100644 index 0000000..48f0501 --- /dev/null +++ b/src/zenity.ui @@ -0,0 +1,1854 @@ + + + + + + 5 + Calendar selection + center + dialog + False + False + + + + True + 2 + + + True + 5 + 6 + + + True + 6 + + + True + 0 + Select a date from below. + True + True + + + False + False + 0 + + + + + 0 + + + + + True + 0 + C_alendar: + True + zenity_calendar + + + + + + False + False + 1 + + + + + True + True + + + False + False + 2 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_calendar_cancel_button + zenity_calendar_ok_button + + + + 5 + Warning + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + 0 + gtk-dialog-warning + 6 + + + False + 0 + + + + + True + True + 0 + Are you sure you want to proceed? + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_warning_ok_button + + + + 5 + Question + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + 0 + gtk-dialog-question + 6 + + + False + 0 + + + + + True + True + 0 + Are you sure you want to proceed? + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + False + end + 0 + + + + + + + 5 + Add a new entry + center + dialog + False + False + + + + True + 2 + + + True + 6 + + + True + 6 + + + True + 0 + _Enter new text: + True + True + + + False + False + 0 + + + + + + + + False + 0 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_entry_cancel_button + zenity_entry_ok_button + + + + 5 + Text View + center + 300 + 200 + dialog + False + False + + + + True + 2 + + + True + 5 + + + True + True + automatic + automatic + etched-in + + + True + True + 2 + 2 + False + word + 2 + 2 + textbuffer1 + + + + + 0 + + + + + 1 + + + + + True + end + + + gtk-close + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_text_close_button + + + + 5 + Progress + center + dialog + False + False + + + + True + 2 + + + True + 5 + 6 + + + True + 0 + Running... + True + + + False + False + 0 + + + + + True + 0.10000000149 + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + False + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_progress_cancel_button + zenity_progress_ok_button + + + + 5 + Error + center + dialog + False + False + + + + True + 14 + + + True + 6 + + + True + 5 + 12 + + + True + 0 + gtk-dialog-error + 6 + + + 0 + + + + + True + True + 0 + An error has occurred. + True + True + True + + + False + False + 1 + + + + + 0 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_error_ok_button + + + + 5 + Select items from the list + center + 300 + 196 + dialog + False + False + + + + True + + + True + 5 + 6 + + + True + 0 + Select items from the list below. + True + + + False + False + 0 + + + + + True + True + automatic + automatic + in + + + True + True + True + + + + + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_tree_cancel_button + zenity_tree_ok_button + + + + 5 + Information + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + gtk-dialog-info + 6 + + + 0 + + + + + True + True + 0 + All updates are complete. + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_info_ok_button + + + + True + 5 + Adjust the scale value + 300 + 100 + dialog + False + False + + + + True + + + True + 5 + 6 + + + True + 0 + 4 + Adjust the scale value + True + + + False + False + 0 + + + + + True + True + discontinuous + adjustment1 + 0 + right + + + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + cancelbutton1 + okbutton1 + + + + 100 + 1 + 1 + + + + + + + + + 5 + Calendar selection + center + dialog + False + False + + + + True + 2 + + + True + 5 + 6 + + + True + 6 + + + True + 0 + Select a date from below. + True + True + + + False + False + 0 + + + + + 0 + + + + + True + 0 + C_alendar: + True + zenity_calendar + + + + + + False + False + 1 + + + + + True + True + + + False + False + 2 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_calendar_cancel_button + zenity_calendar_ok_button + + + + 5 + Warning + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + 0 + gtk-dialog-warning + 6 + + + False + 0 + + + + + True + True + 0 + Are you sure you want to proceed? + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_warning_ok_button + + + + 5 + Question + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + 0 + gtk-dialog-question + 6 + + + False + 0 + + + + + True + True + 0 + Are you sure you want to proceed? + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + False + end + 0 + + + + + + + 5 + Add a new entry + center + dialog + False + False + + + + True + 2 + + + True + 6 + + + True + 6 + + + True + 0 + _Enter new text: + True + True + + + False + False + 0 + + + + + + + + False + 0 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_entry_cancel_button + zenity_entry_ok_button + + + + 5 + Text View + center + 300 + 200 + dialog + False + False + + + + True + 2 + + + True + 5 + + + True + True + automatic + automatic + etched-in + + + True + True + 2 + 2 + False + word + 2 + 2 + textbuffer1 + + + + + 0 + + + + + 1 + + + + + True + end + + + gtk-close + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_text_close_button + + + + 5 + Progress + center + dialog + False + False + + + + True + 2 + + + True + 5 + 6 + + + True + 0 + Running... + True + + + False + False + 0 + + + + + True + 0.10000000149 + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + False + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_progress_cancel_button + zenity_progress_ok_button + + + + 5 + Error + center + dialog + False + False + + + + True + 14 + + + True + 6 + + + True + 5 + 12 + + + True + 0 + gtk-dialog-error + 6 + + + 0 + + + + + True + True + 0 + An error has occurred. + True + True + True + + + False + False + 1 + + + + + 0 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_error_ok_button + + + + 5 + Select items from the list + center + 300 + 196 + dialog + False + False + + + + True + + + True + 5 + 6 + + + True + 0 + Select items from the list below. + True + + + False + False + 0 + + + + + True + True + automatic + automatic + in + + + True + True + True + + + + + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_tree_cancel_button + zenity_tree_ok_button + + + + 5 + Information + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + gtk-dialog-info + 6 + + + 0 + + + + + True + True + 0 + All updates are complete. + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_info_ok_button + + + + True + 5 + Adjust the scale value + 300 + 100 + dialog + False + False + + + + True + + + True + 5 + 6 + + + True + 0 + 4 + Adjust the scale value + True + + + False + False + 0 + + + + + True + True + discontinuous + adjustment1 + 0 + right + + + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + cancelbutton1 + okbutton1 + + + + 100 + 1 + 1 + + + -- cgit v1.2.3-2-g168b