summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/calendar.c13
-rw-r--r--src/color.c10
-rw-r--r--src/entry.c13
-rw-r--r--src/fileselection.c11
-rw-r--r--src/forms.c10
-rw-r--r--src/msg.c45
-rw-r--r--src/option.c40
-rw-r--r--src/password.c10
-rw-r--r--src/progress.c11
-rw-r--r--src/scale.c12
-rw-r--r--src/text.c11
-rw-r--r--src/tree.c11
-rw-r--r--src/util.c2
-rw-r--r--src/util.h2
-rw-r--r--src/zenity.h2
15 files changed, 188 insertions, 15 deletions
diff --git a/src/calendar.c b/src/calendar.c
index 0166c500..0e6cb329 100644
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -91,7 +91,15 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
if (data->timeout_delay > 0) {
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
}
-
+
+ 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++;
+ }
+ }
+
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);
@@ -145,7 +153,8 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
- /* Esc dialog */
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
diff --git a/src/color.c b/src/color.c
index 2a7e0396..05898c4d 100644
--- a/src/color.c
+++ b/src/color.c
@@ -51,6 +51,14 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
}
}
+ 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++;
+ }
+ }
+
if (data->ok_label) {
g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL);
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
@@ -96,6 +104,8 @@ zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer
break;
default:
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
diff --git a/src/entry.c b/src/entry.c
index efb2234d..80367260 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -83,7 +83,15 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
if (data->modal)
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-
+
+ 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++;
+ }
+ }
+
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);
@@ -184,7 +192,8 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
- /* Esc dialog */
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
diff --git a/src/fileselection.c b/src/fileselection.c
index 30495558..3ccd11dd 100644
--- a/src/fileselection.c
+++ b/src/fileselection.c
@@ -62,6 +62,14 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data)
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_fileselection_dialog_response), file_data);
+ 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++;
+ }
+ }
+
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
@@ -181,7 +189,8 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer
break;
default:
- /* Esc dialog */
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
diff --git a/src/forms.c b/src/forms.c
index 3e19f4c5..53e94238 100644
--- a/src/forms.c
+++ b/src/forms.c
@@ -205,6 +205,14 @@ 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->extra_label) {
+ gint i=0;
+ while(data->extra_label[i]!=NULL){
+ gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
+ i++;
+ }
+ }
+
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);
@@ -363,6 +371,8 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
diff --git a/src/msg.c b/src/msg.c
index 6892e733..ddaab266 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -31,6 +31,8 @@ static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocat
static void
zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data)
{
+
+
GtkWidget *cancel_button, *ok_button;
cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_No"), GTK_RESPONSE_CANCEL);
@@ -45,6 +47,33 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data
if (data->ok_label) {
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
}
+
+
+}
+
+static void
+zenity_label_widget_clipboard_selection(GtkWidget *widget)
+{
+ /* Workaround hotfix for suspected toolkit issue:
+ since focus change of the dialog's focussed widget (text)
+ somehow currently chooses to destroy
+ a pre-existing (read: foreign, user-initiated) X11 primary selection
+ (via gtk_label_select_region() -> ...
+ -> gtk_clipboard_set_contents()/gtk_clipboard_clear()),
+ we need to ensure
+ that the widget does have its gtk-label-select-on-focus property off,
+ in order to avoid having the label become selected automatically
+ and thereby having pre-existing clipboard content nullified.
+ Side note: this selection issue only applies to widgets
+ which have both
+ <property name="can_focus">True</property>
+ <property name="selectable">True</property>
+ .
+ */
+ g_object_set(gtk_widget_get_settings (widget),
+ "gtk-label-select-on-focus",
+ FALSE,
+ NULL);
}
void
@@ -66,6 +95,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
break;
case ZENITY_MSG_QUESTION:
+ case ZENITY_MSG_SWITCH:
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");
@@ -99,6 +129,14 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
break;
}
+ 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++;
+ }
+ }
+
if (builder == NULL) {
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
@@ -128,6 +166,10 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
zenity_msg_construct_question_dialog (dialog, msg_data, data);
break;
+ case ZENITY_MSG_SWITCH:
+ zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-question");
+ break;
+
case ZENITY_MSG_ERROR:
zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-error");
break;
@@ -158,6 +200,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text);
else
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text));
+ zenity_label_widget_clipboard_selection(GTK_WIDGET (text));
}
if (msg_data->ellipsize)
@@ -201,6 +244,8 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
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;
}
diff --git a/src/password.c b/src/password.c
index c5161002..1d17d913 100644
--- a/src/password.c
+++ b/src/password.c
@@ -43,6 +43,14 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data
dialog = gtk_dialog_new ();
+ 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++;
+ }
+ }
+
gtk_dialog_add_button(GTK_DIALOG(dialog),
data->cancel_label != NULL ? data->cancel_label : _("_Cancel"),
GTK_RESPONSE_CANCEL);
@@ -171,6 +179,8 @@ zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
diff --git a/src/progress.c b/src/progress.c
index dfbdd8a9..d8ecea52 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -316,6 +316,14 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
if (data->modal)
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ 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++;
+ }
+ }
+
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);
@@ -385,7 +393,8 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data)
zenity_util_exit_code_with_data (ZENITY_TIMEOUT, zen_data);
break;
default:
- /* Esc dialog */
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
diff --git a/src/scale.c b/src/scale.c
index ea56dd22..cc9ce105 100644
--- a/src/scale.c
+++ b/src/scale.c
@@ -78,7 +78,15 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
if (data->modal)
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-
+
+ 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++;
+ }
+ }
+
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);
@@ -141,6 +149,8 @@ zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
diff --git a/src/text.c b/src/text.c
index 634be3da..581b3666 100644
--- a/src/text.c
+++ b/src/text.c
@@ -276,6 +276,14 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
if (text_data->editable)
zen_text_data->buffer = text_buffer;
+ 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++;
+ }
+ }
+
if (data->ok_label) {
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
}
@@ -394,7 +402,8 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
- /* Esc dialog */
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zenity_util_exit_code_with_data(ZENITY_ESC, zen_data);
break;
}
diff --git a/src/tree.c b/src/tree.c
index c87958f0..0849946c 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -397,6 +397,14 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
if (data->modal)
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ 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++;
+ }
+ }
+
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);
@@ -703,7 +711,8 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
- /* Esc dialog */
+ if (response < g_strv_length(zen_data->extra_label))
+ printf("%s\n",zen_data->extra_label[response]);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
diff --git a/src/util.c b/src/util.c
index 29ef6daf..9693b0b2 100644
--- a/src/util.c
+++ b/src/util.c
@@ -76,7 +76,7 @@ zenity_util_load_ui_file (const gchar *root_widget, ...)
/* Enforce terminating NULL */
g_ptr_array_add (ptrarray, NULL);
objects = (gchar**) g_ptr_array_free (ptrarray, FALSE);
-
+
if (g_file_test (ZENITY_UI_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) {
/* Try current dir, for debugging */
result = gtk_builder_add_objects_from_file (builder,
diff --git a/src/util.h b/src/util.h
index 0fd2fff9..4296ab93 100644
--- a/src/util.h
+++ b/src/util.h
@@ -6,6 +6,8 @@
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
+#else
+typedef gint Window;
#endif
G_BEGIN_DECLS
diff --git a/src/zenity.h b/src/zenity.h
index 6390b007..77f0c050 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -28,6 +28,7 @@ typedef struct {
gchar *window_icon;
gchar *ok_label;
gchar *cancel_label;
+ gchar **extra_label;
gint width;
gint height;
gint exit_code;
@@ -56,6 +57,7 @@ typedef struct {
typedef enum {
ZENITY_MSG_WARNING,
ZENITY_MSG_QUESTION,
+ ZENITY_MSG_SWITCH,
ZENITY_MSG_ERROR,
ZENITY_MSG_INFO
} MsgMode;
bgstack15