[zenity] Fix for bug #611297 Now Zenity have --ok-label and --cancel-label in all dialogs. This patch doesn't



commit 6768a40e997697d05008aecdb41815e1dbae61c6
Author: Arx Cruz <arxcruz gnome org>
Date:   Tue Jul 26 14:00:28 2011 -0300

    Fix for bug #611297 Now Zenity have --ok-label and --cancel-label in all dialogs. This patch doesn't break old zenity scripts.

 src/calendar.c |   17 ++++++++++++-
 src/color.c    |   17 ++++++++++++
 src/entry.c    |   15 +++++++++++
 src/forms.c    |   17 ++++++++++++-
 src/msg.c      |   26 ++++++++++++++----
 src/option.c   |   76 +++++++++++++++++++++----------------------------------
 src/password.c |    4 +-
 src/progress.c |   15 +++++++++++
 src/scale.c    |   15 +++++++++++
 src/text.c     |   20 +++++++++-----
 src/tree.c     |   15 +++++++++++
 src/zenity.h   |    6 +---
 src/zenity.ui  |   16 ++++++------
 13 files changed, 183 insertions(+), 76 deletions(-)
---
diff --git a/src/calendar.c b/src/calendar.c
index 32825da..c62c181 100644
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -39,6 +39,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
 {
   GtkBuilder *builder;
   GtkWidget *dialog;
+  GtkWidget *button;
   GObject *text;
 
   zen_cal_data = cal_data;
@@ -84,10 +85,24 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
   gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar);
   zenity_util_show_dialog (dialog);
 
-  if(data->timeout_delay > 0) {
+  if (data->timeout_delay > 0) {
     g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
   }
 
+  if (data->ok_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
+  }
+
+  if (data->cancel_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
+  }
+
   g_object_unref (builder);
 
   gtk_main ();
diff --git a/src/color.c b/src/color.c
index ca8debd..5e24e3d 100644
--- a/src/color.c
+++ b/src/color.c
@@ -35,6 +35,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
 {
   GtkWidget *dialog;
   GtkWidget *colorsel;
+  GtkWidget *button;
   GdkColor color;
 
   zen_data = data;
@@ -56,6 +57,22 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
                                              &color);
   }
 
+  if (data->ok_label) {
+    g_object_get (G_OBJECT (dialog), "ok-button", &button);
+    gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
+    g_object_unref (G_OBJECT (button));
+  }
+
+  if (data->cancel_label) {
+    g_object_get (G_OBJECT (dialog), "cancel-button", &button);
+    gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
+    gtk_button_set_image (GTK_BUTTON (button), 
+                          gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
+    g_object_unref (G_OBJECT (button));
+  }
+
   gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel),
                                        color_data->show_palette);
 
diff --git a/src/entry.c b/src/entry.c
index d8111c0..7163e54 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -53,6 +53,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
 {
   GtkBuilder *builder = NULL;
   GtkWidget *dialog;
+  GtkWidget *button;
   GObject *text;
   GSList *entries = NULL; 
   GSList *tmp;
@@ -79,6 +80,20 @@ 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);
+  
+  if (data->ok_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
+  }
+
+  if (data->cancel_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
+  }
 
   text = gtk_builder_get_object (builder, "zenity_entry_text");
 
diff --git a/src/forms.c b/src/forms.c
index d59a5af..c2b9f85 100644
--- a/src/forms.c
+++ b/src/forms.c
@@ -36,6 +36,7 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data)
   GtkWidget *dialog;
   GtkWidget *table;
   GtkWidget *text;
+  GtkWidget *button;
 
   GSList *tmp;
 
@@ -62,7 +63,21 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data)
 
   if (data->width > -1 || data->height > -1)
     gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
-  
+
+  if (data->ok_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_ok_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
+  }  
+
+  if (data->cancel_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_cancel_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
+  }
+
   text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text"));
 
   if (forms_data->dialog_text)
diff --git a/src/msg.c b/src/msg.c
index 5df884f..667239b 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:
diff --git a/src/option.c b/src/option.c
index e5f79b9..e9d370d 100644
--- a/src/option.c
+++ b/src/option.c
@@ -188,6 +188,24 @@ static GOptionEntry general_options[] = {
     N_("TIMEOUT")
   },
   {
+    "ok-label",
+    '\0',
+    G_OPTION_FLAG_NOALIAS,
+    G_OPTION_ARG_STRING,
+    &zenity_general_ok_button,
+    N_("Sets the label of the Ok button"),
+    N_("TEXT")
+  },
+  {
+    "cancel-label",
+    '\0',
+    G_OPTION_FLAG_NOALIAS,
+    G_OPTION_ARG_STRING,
+    &zenity_general_cancel_button,
+    N_("Sets the label of the Cancel button"),
+    N_("TEXT")
+  },
+  {
     NULL
   }
 };
@@ -690,24 +708,6 @@ static GOptionEntry question_options[] = {
     N_("TEXT")
   },
   {
-    "ok-label",
-    '\0',
-    G_OPTION_FLAG_NOALIAS,
-    G_OPTION_ARG_STRING,
-    &zenity_general_ok_button,
-    N_("Sets the label of the Ok button"),
-    N_("TEXT")
-  },
-  {
-    "cancel-label",
-    '\0',
-    G_OPTION_FLAG_NOALIAS,
-    G_OPTION_ARG_STRING,
-    &zenity_general_cancel_button,
-    N_("Sets the label of the Cancel button"),
-    N_("TEXT")
-  },
-  {
     "no-wrap",
     '\0',
     G_OPTION_FLAG_NOALIAS,
@@ -767,24 +767,6 @@ static GOptionEntry text_options[] = {
     N_("TEXT")
   },
   {
-    "ok-label",
-    '\0',
-    G_OPTION_FLAG_NOALIAS,
-    G_OPTION_ARG_STRING,
-    &zenity_general_ok_button,
-    N_("Sets the label of the Ok button"),
-    N_("TEXT")
-  },
-  {
-    "cancel-label",
-    '\0',
-    G_OPTION_FLAG_NOALIAS,
-    G_OPTION_ARG_STRING,
-    &zenity_general_cancel_button,
-    N_("Sets the label of the Cancel button"),
-    N_("TEXT")
-  },
-  {
     "checkbox",
     '\0',
     G_OPTION_FLAG_NOALIAS,
@@ -1467,7 +1449,9 @@ zenity_general_post_callback (GOptionContext *context,
   results->data->window_icon = zenity_general_window_icon;
   results->data->width = zenity_general_width;
   results->data->height = zenity_general_height;
-  results->data->timeout_delay=zenity_general_timeout_delay;
+  results->data->timeout_delay = zenity_general_timeout_delay;
+  results->data->ok_label = zenity_general_ok_button;
+  results->data->cancel_label = zenity_general_cancel_button;
   return TRUE;
 }
 
@@ -1497,6 +1481,7 @@ zenity_calendar_post_callback (GOptionContext *context,
     results->calendar_data->day = zenity_calendar_day;
     results->calendar_data->month = zenity_calendar_month;
     results->calendar_data->year = zenity_calendar_year;
+
     if (zenity_calendar_date_format)
       results->calendar_data->date_format = zenity_calendar_date_format;
     else
@@ -1748,8 +1733,6 @@ zenity_question_post_callback (GOptionContext *context,
     results->msg_data->mode = ZENITY_MSG_QUESTION;
     results->msg_data->no_wrap = zenity_general_dialog_no_wrap;
     results->msg_data->no_markup = zenity_general_dialog_no_markup;
-    results->msg_data->ok_label = zenity_general_ok_button;
-    results->msg_data->cancel_label = zenity_general_cancel_button;
   }
 
   return TRUE;
@@ -1768,8 +1751,6 @@ zenity_text_post_callback (GOptionContext *context,
     results->text_data->editable = zenity_general_editable;
     results->text_data->no_wrap = zenity_general_dialog_no_wrap;
     results->text_data->font = zenity_text_font;
-    results->text_data->ok_label = zenity_general_ok_button;
-    results->text_data->cancel_label = zenity_general_cancel_button;
     results->text_data->checkbox = zenity_text_checkbox;
 #ifdef HAVE_WEBKITGTK
     results->text_data->html = zenity_text_enable_html;
@@ -2163,15 +2144,16 @@ zenity_option_parse (gint argc, gchar **argv)
   if (zenity_general_uri)
     if (results->mode != MODE_FILE && results->mode != MODE_TEXTINFO)
       zenity_option_error (zenity_option_get_name (text_options, &zenity_general_uri), ERROR_SUPPORT);
-
+  
   if (zenity_general_ok_button)
-    if(results->mode != MODE_QUESTION && results->mode != MODE_TEXTINFO)
-      zenity_option_error (zenity_option_get_name (text_options, &zenity_general_ok_button), ERROR_SUPPORT);
+    if(results->mode == MODE_FILE)
+      zenity_option_error (zenity_option_get_name (general_options, &zenity_general_ok_button), ERROR_SUPPORT);
   
   if (zenity_general_cancel_button)
-    if(results->mode != MODE_QUESTION && results->mode != MODE_TEXTINFO)
-      zenity_option_error (zenity_option_get_name (text_options, &zenity_general_cancel_button), ERROR_SUPPORT);
- 
+    if(results->mode == MODE_FILE || results->mode == MODE_ERROR || results->mode == MODE_WARNING || results->mode == MODE_INFO)
+      zenity_option_error (zenity_option_get_name (general_options, &zenity_general_cancel_button), ERROR_SUPPORT);
+  
+
   if (zenity_general_dialog_no_wrap)
     if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING && results->mode != MODE_TEXTINFO)
       zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_no_wrap), ERROR_SUPPORT);
diff --git a/src/password.c b/src/password.c
index c49b675..b656d8f 100644
--- a/src/password.c
+++ b/src/password.c
@@ -45,10 +45,10 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data
   dialog = gtk_dialog_new ();
 
   gtk_dialog_add_button(GTK_DIALOG(dialog), 
-                        GTK_STOCK_CANCEL, 
+                        data->cancel_label != NULL ? data->cancel_label : GTK_STOCK_CANCEL, 
                         GTK_RESPONSE_CANCEL);
   gtk_dialog_add_button(GTK_DIALOG(dialog), 
-                        GTK_STOCK_OK, 
+                        data->ok_label != NULL ? data->ok_label : GTK_STOCK_OK, 
                         GTK_RESPONSE_OK);
   
   image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION,
diff --git a/src/progress.c b/src/progress.c
index 6dc93f8..b16e400 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -227,6 +227,7 @@ void
 zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
 {
   GtkWidget *dialog;
+  GtkWidget *button;
   GObject *text;
   GObject *progress_bar;
   GObject *cancel_button,*ok_button;
@@ -255,6 +256,20 @@ 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);
 
+  if (data->ok_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
+  }
+
+  if (data->cancel_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_cancel_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
+  }
+
   text = gtk_builder_get_object (builder, "zenity_progress_text");
 
   if (progress_data->dialog_text)
diff --git a/src/scale.c b/src/scale.c
index 87bf55a..11d9588 100644
--- a/src/scale.c
+++ b/src/scale.c
@@ -36,6 +36,7 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
 {
   GtkBuilder *builder;
   GtkWidget *dialog;
+  GtkWidget *button;
   GObject *text;
 
   builder = zenity_util_load_ui_file ("zenity_scale_dialog", "adjustment1", NULL);
@@ -75,6 +76,20 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
   if (data->width > -1 || data->height > -1)
     gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
         
+  if (data->ok_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
+  }
+
+  if (data->cancel_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_cancel_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
+  }
+
   if (scale_data->dialog_text) 
     gtk_label_set_markup (GTK_LABEL (text), g_strcompress (scale_data->dialog_text));
 
diff --git a/src/text.c b/src/text.c
index e786884..9c031cb 100644
--- a/src/text.c
+++ b/src/text.c
@@ -262,16 +262,22 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
   if (text_data->editable)
     zen_text_data->buffer = text_buffer;
 
-  if (text_data->ok_label) 
-    gtk_button_set_label (GTK_BUTTON(ok_button), text_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));
+  }
 
-  if (text_data->cancel_label)
-    gtk_button_set_label (GTK_BUTTON(cancel_button), text_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 (text_data->checkbox) {
-    gtk_widget_set_visible (GTK_WIDGET(checkbox), TRUE);
-    gtk_widget_set_sensitive (GTK_WIDGET(ok_button), FALSE);
-    gtk_button_set_label (GTK_BUTTON(checkbox), text_data->checkbox);
+    gtk_widget_set_visible (GTK_WIDGET (checkbox), TRUE);
+    gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE);
+    gtk_button_set_label (GTK_BUTTON (checkbox), text_data->checkbox);
 
     g_signal_connect (G_OBJECT (checkbox), "toggled",
                       G_CALLBACK (zenity_text_toggle_button), ok_button);
diff --git a/src/tree.c b/src/tree.c
index c15f502..10d8946 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -287,6 +287,7 @@ void
 zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
 {
   GtkWidget *dialog;
+  GtkWidget *button;
   GObject *tree_view;
   GObject *text;
   GtkTreeViewColumn *column;
@@ -344,6 +345,20 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
   if (data->dialog_title)
     gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
 
+  if (data->ok_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
+  }
+
+  if (data->cancel_label) {
+    button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_cancel_button"));
+    gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
+    gtk_button_set_image (GTK_BUTTON (button),
+                          gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
+  }
+
   text = gtk_builder_get_object (builder, "zenity_tree_text");
                                                                                 
   if (tree_data->dialog_text)
diff --git a/src/zenity.h b/src/zenity.h
index d9d0a10..4d1e27d 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -26,6 +26,8 @@ G_BEGIN_DECLS
 typedef struct {
   gchar *dialog_title;
   gchar *window_icon;
+  gchar *ok_label;
+  gchar *cancel_label;
   gint   width;
   gint   height;
   gint   exit_code;
@@ -61,8 +63,6 @@ typedef struct {
   MsgMode  mode;
   gboolean no_wrap;
   gboolean no_markup;
-  gchar   *ok_label;
-  gchar   *cancel_label;
 } ZenityMsgData;
 
 typedef struct {
@@ -108,8 +108,6 @@ typedef struct {
   gboolean       no_wrap;
   gchar         *font;
   GtkTextBuffer	*buffer;
-  gchar         *ok_label;
-  gchar         *cancel_label;
   gchar         *checkbox;
 #ifdef HAVE_WEBKITGTK
   gboolean       html;
diff --git a/src/zenity.ui b/src/zenity.ui
index cd955b2..869bdca 100644
--- a/src/zenity.ui
+++ b/src/zenity.ui
@@ -365,7 +365,7 @@
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="cancelbutton12">
+              <object class="GtkButton" id="zenity_forms_cancel_button">
                 <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -380,7 +380,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="okbutton12">
+              <object class="GtkButton" id="zenity_forms_ok_button">
                 <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -449,8 +449,8 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="-6">cancelbutton12</action-widget>
-      <action-widget response="-5">okbutton12</action-widget>
+      <action-widget response="-6">zenity_forms_cancel_button</action-widget>
+      <action-widget response="-5">zenity_forms_ok_button</action-widget>
     </action-widgets>
   </object>
   <object class="GtkDialog" id="zenity_info_dialog">
@@ -739,7 +739,7 @@
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="cancelbutton1">
+              <object class="GtkButton" id="zenity_scale_cancel_button">
                 <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -755,7 +755,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="okbutton1">
+              <object class="GtkButton" id="zenity_scale_ok_button">
                 <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -823,8 +823,8 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="-6">cancelbutton1</action-widget>
-      <action-widget response="-5">okbutton1</action-widget>
+      <action-widget response="-6">zenity_scale_cancel_button</action-widget>
+      <action-widget response="-5">zenity_scale_ok_button</action-widget>
     </action-widgets>
   </object>
   <object class="GtkDialog" id="zenity_text_dialog">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]