summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--src/msg.c24
-rw-r--r--src/option.c29
-rw-r--r--src/zenity.glade33
-rw-r--r--src/zenity.h2
5 files changed, 74 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index 2974539..bc648da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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.
+
2008-03-17 Lucas Rocha <lucasr@gnome.org>
* src/option.c: added arg_description for --timeout option (Fixes
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:
diff --git a/src/option.c b/src/option.c
index babe4e9..b56d5f0 100644
--- a/src/option.c
+++ b/src/option.c
@@ -87,6 +87,8 @@ static gboolean zenity_progress_auto_kill;
/* Question Dialog Options */
static gboolean zenity_question_active;
+static gchar *zenity_question_ok_button;
+static gchar *zenity_question_cancel_button;
/* Text Dialog Options */
static gboolean zenity_text_active;
@@ -609,6 +611,24 @@ static GOptionEntry question_options[] = {
N_("TEXT")
},
{
+ "ok-label",
+ '\0',
+ G_OPTION_FLAG_NOALIAS,
+ G_OPTION_ARG_STRING,
+ &zenity_question_ok_button,
+ N_("Sets the label of the Ok button"),
+ N_("TEXT")
+ },
+ {
+ "cancel-label",
+ '\0',
+ G_OPTION_FLAG_NOALIAS,
+ G_OPTION_ARG_STRING,
+ &zenity_question_cancel_button,
+ N_("Sets the label of the Cancel button"),
+ N_("TEXT")
+ },
+ {
"no-wrap",
'\0',
G_OPTION_FLAG_NOALIAS,
@@ -837,6 +857,11 @@ zenity_option_free (void) {
if (zenity_list_hide_column)
g_free (zenity_list_hide_column);
+ if (zenity_question_ok_button)
+ g_free (zenity_question_ok_button);
+ if (zenity_question_cancel_button)
+ g_free (zenity_question_cancel_button);
+
g_option_context_free (ctx);
}
@@ -1342,7 +1367,9 @@ zenity_question_post_callback (GOptionContext *context,
if (results->mode == MODE_QUESTION) {
results->msg_data->dialog_text = zenity_general_dialog_text;
results->msg_data->mode = ZENITY_MSG_QUESTION;
- results->msg_data->no_wrap = zenity_general_dialog_no_wrap;
+ results->msg_data->no_wrap = zenity_general_dialog_no_wrap;
+ results->msg_data->ok_label = zenity_question_ok_button;
+ results->msg_data->cancel_label = zenity_question_cancel_button;
}
return TRUE;
diff --git a/src/zenity.glade b/src/zenity.glade
index c496dcc..ffda0e8 100644
--- a/src/zenity.glade
+++ b/src/zenity.glade
@@ -242,6 +242,7 @@
<child>
<widget class="GtkLabel" id="zenity_warning_text">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="label" translatable="yes">Are you sure you want to proceed?</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
@@ -339,36 +340,9 @@
<property name="spacing">14</property>
<child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area3">
+ <widget class="GtkHButtonBox" id="zenity_question_button_box">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="zenity_question_cancel_button">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="zenity_question_ok_button">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="has_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
</widget>
<packing>
<property name="padding">0</property>
@@ -405,6 +379,7 @@
<child>
<widget class="GtkLabel" id="zenity_question_text">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="label" translatable="yes">Are you sure you want to proceed?</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
@@ -872,6 +847,7 @@
<child>
<widget class="GtkLabel" id="zenity_error_text">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="label" translatable="yes">An error has occurred.</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
@@ -1126,6 +1102,7 @@
<child>
<widget class="GtkLabel" id="zenity_info_text">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="label" translatable="yes">All updates are complete.</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
diff --git a/src/zenity.h b/src/zenity.h
index ac6c4f8..8865cd9 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -60,6 +60,8 @@ typedef struct {
gchar *dialog_text;
MsgMode mode;
gboolean no_wrap;
+ gchar *ok_label;
+ gchar *cancel_label;
} ZenityMsgData;
typedef struct {