From 6768a40e997697d05008aecdb41815e1dbae61c6 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 26 Jul 2011 14:00:28 -0300 Subject: Fix for bug #611297 Now Zenity have --ok-label and --cancel-label in all dialogs. This patch doesn't break old zenity scripts. --- src/msg.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 5df884ff..667239b1 100644 --- a/src/msg.c +++ b/src/msg.c @@ -29,7 +29,7 @@ static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); static void -zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data) +zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { GtkWidget *cancel_button, *ok_button; @@ -38,14 +38,14 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data gtk_widget_grab_focus (ok_button); - if (msg_data->cancel_label) { - gtk_button_set_label (GTK_BUTTON (cancel_button), msg_data->cancel_label); + if (data->cancel_label) { + gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); gtk_button_set_image (GTK_BUTTON (cancel_button), gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } - if (msg_data->ok_label) { - gtk_button_set_label (GTK_BUTTON (ok_button), msg_data->ok_label); + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); gtk_button_set_image (GTK_BUTTON (ok_button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } @@ -56,6 +56,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { GtkBuilder *builder; GtkWidget *dialog; + GtkWidget *ok_button; GObject *text; switch (msg_data->mode) { @@ -63,30 +64,35 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) 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"); + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_ok_button")); break; case ZENITY_MSG_QUESTION: 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"); + ok_button = NULL; break; case ZENITY_MSG_ERROR: 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"); + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_ok_button")); break; case ZENITY_MSG_INFO: 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"); + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_ok_button")); break; default: builder = NULL; dialog = NULL; text = NULL; + ok_button = NULL; g_assert_not_reached (); break; } @@ -104,6 +110,14 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (ok_button) { + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (ok_button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + } + switch (msg_data->mode) { case ZENITY_MSG_WARNING: zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_WARNING); @@ -111,7 +125,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) case ZENITY_MSG_QUESTION: zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION); - zenity_msg_construct_question_dialog (dialog, msg_data); + zenity_msg_construct_question_dialog (dialog, msg_data, data); break; case ZENITY_MSG_ERROR: -- cgit