summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/msg.c2
-rw-r--r--src/option.c12
-rw-r--r--src/zenity.h1
3 files changed, 14 insertions, 1 deletions
diff --git a/src/msg.c b/src/msg.c
index 53f8a5df..f4d5e7a9 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -36,7 +36,7 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data
cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_NO, GTK_RESPONSE_CANCEL);
ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_YES, GTK_RESPONSE_OK);
- gtk_widget_grab_focus (ok_button);
+ gtk_widget_grab_focus (msg_data->default_cancel ? cancel_button : ok_button);
if (data->cancel_label) {
gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label);
diff --git a/src/option.c b/src/option.c
index d3004fe2..46112d04 100644
--- a/src/option.c
+++ b/src/option.c
@@ -100,6 +100,7 @@ static gboolean zenity_progress_no_cancel;
/* Question Dialog Options */
static gboolean zenity_question_active;
+static gboolean zenity_question_default_cancel;
/* Text Dialog Options */
static gboolean zenity_text_active;
@@ -797,6 +798,15 @@ static GOptionEntry question_options[] = {
&zenity_general_dialog_no_markup,
N_("Do not enable pango markup")
},
+ {
+ "default-cancel",
+ '\0',
+ G_OPTION_FLAG_NOALIAS,
+ G_OPTION_ARG_NONE,
+ &zenity_question_default_cancel,
+ N_("Give cancel button focus by default"),
+ NULL
+ },
{
NULL
}
@@ -1507,6 +1517,7 @@ zenity_question_pre_callback (GOptionContext *context,
GError **error)
{
zenity_question_active = FALSE;
+ zenity_question_default_cancel = FALSE;
return TRUE;
}
@@ -1913,6 +1924,7 @@ 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->default_cancel = zenity_question_default_cancel;
}
return TRUE;
diff --git a/src/zenity.h b/src/zenity.h
index acde39bf..52c29df5 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -66,6 +66,7 @@ typedef struct {
MsgMode mode;
gboolean no_wrap;
gboolean no_markup;
+ gboolean default_cancel;
} ZenityMsgData;
typedef struct {
bgstack15