summaryrefslogtreecommitdiff
path: root/src/msg.c
diff options
context:
space:
mode:
authorLucas Rocha <lucasr@gnome.org>2008-03-29 22:13:50 +0000
committerLucas Almeida Rocha <lucasr@src.gnome.org>2008-03-29 22:13:50 +0000
commit2141cb9184c20be91e469b2bd4e4bb22e57faba3 (patch)
tree365dfc58346aa5c3ed10b92b029d62fbd7e96b8d /src/msg.c
parent23eb83f5bc97bb777b9612122a9ebd3cfd6f49c0 (diff)
Allow question dialogs to use custom button label text (Fixes bug
2008-03-30 Lucas Rocha <lucasr@gnome.org> Allow question dialogs to use custom button label text (Fixes bug #335763). Patch from Cosimo Cecchi <anarki@lilik.it> and Thomas Thurman <tthurman@gnome.org>. * src/msg.c (zenity_msg_construct_question_dialog), (zenity_msg): dynamically add dialog buttons with provided labels. * src/option.c (zenity_option_free): free input labels. (zenity_question_post_callback): set button labels provided by the respective command line options. * src/zenity.glade: remove pre-defined dialog button from question dialog. * src/zenity.h: added ok_label and cancel_label to ZenityMsgData. svn path=/trunk/; revision=1346
Diffstat (limited to 'src/msg.c')
-rw-r--r--src/msg.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/msg.c b/src/msg.c
index cbe6e3a..90e5164 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -29,6 +29,29 @@
static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data);
+static void
+zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data)
+{
+ GtkWidget *cancel_button, *ok_button;
+
+ cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK);
+
+ gtk_widget_grab_focus (ok_button);
+
+ if (msg_data->cancel_label) {
+ gtk_button_set_label (GTK_BUTTON (cancel_button), g_strdup (msg_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), g_strdup (msg_data->ok_label));
+ gtk_button_set_image (GTK_BUTTON (ok_button),
+ gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
+ }
+}
+
void
zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
{
@@ -92,6 +115,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);
break;
case ZENITY_MSG_ERROR: