diff options
author | Gama Anderson <gamaanderson92@gmail.com> | 2015-02-28 20:06:09 +0100 |
---|---|---|
committer | Arx Cruz <acruz@redhat.com> | 2015-04-21 13:00:44 +0200 |
commit | ba5ea0386de2a80a664fb28d3af7e8d395968314 (patch) | |
tree | f07081dd0d7b837c80716b4573dd563a2300f2ea /src/option.c | |
parent | allow build if GDK_WINDOWING_X11 not set (diff) | |
download | zenity-ba5ea0386de2a80a664fb28d3af7e8d395968314.tar.gz zenity-ba5ea0386de2a80a664fb28d3af7e8d395968314.tar.bz2 zenity-ba5ea0386de2a80a664fb28d3af7e8d395968314.zip |
ADD gchar **extra_label TO struct ZenityData
this is done to keep the name of the extra buttons
ADD general option "extra-button" with string array as argument
This will upon consecutive calls save the name of buttons in an array of strings
To all MODES, except notification.c and about.c ADD
if (data->extra_label) {
gint i=0;
while(data->extra_label[i]!=NULL){
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
i++;
}
}
This add the extra buttons to the dialog. The response is the number of the button
To all MODES response, except notification.c and about.c ADD
default:
if (response < g_strv_length(zen_data->extra_label))
printf("%s\n",zen_data->extra_label[response]);
This will print the button name to stdout when they are pressed
ADD question option "switch"
This will suppress the standard "ok" and "cancel" button in question. This just wort in combination with --extra-button, otherwise error is raised.
https://bugzilla.gnome.org/show_bug.cgi?id=118016
Diffstat (limited to 'src/option.c')
-rw-r--r-- | src/option.c | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/src/option.c b/src/option.c index eb0a03a3..7ec4b634 100644 --- a/src/option.c +++ b/src/option.c @@ -45,6 +45,7 @@ static gboolean zenity_general_dialog_no_markup; static gint zenity_general_timeout_delay; static gchar *zenity_general_ok_button; static gchar *zenity_general_cancel_button; +static gchar **zenity_general_extra_buttons; static gboolean zenity_general_modal; static gint zenity_general_attach; static gboolean zenity_general_dialog_ellipsize; @@ -104,6 +105,7 @@ static gboolean zenity_progress_time_remaining; /* Question Dialog Options */ static gboolean zenity_question_active; static gboolean zenity_question_default_cancel; +static gboolean zenity_question_switch; /* Text Dialog Options */ static gboolean zenity_text_active; @@ -223,6 +225,15 @@ static GOptionEntry general_options[] = { N_("TEXT") }, { + "extra-button", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_general_extra_buttons, + N_("Add extra-button"), + N_("TEXT") + }, + { "modal", '\0', G_OPTION_FLAG_NOALIAS, @@ -855,6 +866,15 @@ static GOptionEntry question_options[] = { &zenity_general_dialog_ellipsize, N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") }, + { + "switch", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_question_switch, + N_("Supress ok and cancel buttons"), + NULL + }, { NULL } @@ -1341,7 +1361,9 @@ zenity_option_free (void) { g_free (zenity_general_ok_button); if (zenity_general_cancel_button) g_free (zenity_general_cancel_button); - + if (zenity_general_extra_buttons) + g_strfreev (zenity_general_extra_buttons); + if (zenity_calendar_date_format) g_free (zenity_calendar_date_format); @@ -1463,6 +1485,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_uri = NULL; zenity_general_ok_button = NULL; zenity_general_cancel_button = NULL; + zenity_general_extra_buttons = NULL; zenity_general_dialog_no_wrap = FALSE; zenity_general_dialog_no_markup = FALSE; zenity_general_timeout_delay = -1; @@ -1594,7 +1617,7 @@ zenity_question_pre_callback (GOptionContext *context, { zenity_question_active = FALSE; zenity_question_default_cancel = FALSE; - + zenity_question_switch = FALSE; return TRUE; } @@ -1710,6 +1733,7 @@ zenity_general_post_callback (GOptionContext *context, results->data->timeout_delay = zenity_general_timeout_delay; results->data->ok_label = zenity_general_ok_button; results->data->cancel_label = zenity_general_cancel_button; + results->data->extra_label = zenity_general_extra_buttons; results->data->modal = zenity_general_modal; results->data->attach = zenity_general_attach; @@ -2012,13 +2036,18 @@ zenity_question_post_callback (GOptionContext *context, if (results->mode == MODE_QUESTION) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->dialog_icon = zenity_general_dialog_icon; - results->msg_data->mode = ZENITY_MSG_QUESTION; + if(zenity_question_switch) + results->msg_data->mode = ZENITY_MSG_SWITCH; + else + 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->ellipsize = zenity_general_dialog_ellipsize; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; results->msg_data->default_cancel = zenity_question_default_cancel; } - + if(zenity_question_switch && zenity_general_extra_buttons==NULL) + zenity_option_error (zenity_option_get_name (question_options, &zenity_question_switch), ERROR_SYNTAX); + return TRUE; } @@ -2495,5 +2524,6 @@ zenity_option_parse (gint argc, gchar **argv) if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_ellipsize), ERROR_SUPPORT); + return results; } |