From 4ccc7f6fac79a189e0c0c4896bb2f0f38d38d7c7 Mon Sep 17 00:00:00 2001 From: Berislav Kovacki Date: Tue, 23 Feb 2010 18:24:20 +0000 Subject: Bug 540169 - Zenity should offer color selection dialog --- src/color.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/color.c (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c new file mode 100644 index 00000000..8f31937f --- /dev/null +++ b/src/color.c @@ -0,0 +1,97 @@ +/* + * color.c + * + * Copyright (C) 2010 Berislav Kovacki + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: Berislav Kovacki + */ + +#include "config.h" + +#include +#include "zenity.h" +#include "util.h" + +static ZenityData *zen_data; + +static void zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data); + +void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) +{ + GtkWidget *dialog; + GtkWidget *colorsel; + GdkColor color; + + zen_data = data; + + dialog = gtk_color_selection_dialog_new (NULL); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_colorselection_dialog_response), + color_data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog)); + + if (color_data->color) { + if (gdk_color_parse (color_data->color, &color)) + gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (colorsel), + &color); + } + + gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), + color_data->show_palette); + + zenity_util_show_dialog (dialog); + + if (data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, + (GSourceFunc) zenity_util_timeout_handle, + NULL); + } + + gtk_main(); +} + +static void +zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data) +{ + GtkWidget *colorsel; + GdkColor color; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (widget)); + gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color); + g_print ("%s\n", gdk_color_to_string (&color)); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + default: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + + gtk_main_quit (); +} -- cgit From b39ad33c35bb93c647e7f6f05d1310a0ce6895d5 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 16 Jun 2011 11:07:58 -0300 Subject: Bug 651948 - zenity list does not return default value when timeout is over --- src/color.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index 8f31937f..eee68ee7 100644 --- a/src/color.c +++ b/src/color.c @@ -64,7 +64,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) if (data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, - NULL); + dialog); } gtk_main(); -- cgit From d60e5eeeb379e5444ad218d7335b17eaa821b182 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 17 Jun 2011 10:47:07 -0300 Subject: Now if you use --timeout option, the return code will be properly handled The default behavior will be done (ie. user click on ok button) The return code will be 5 --- src/color.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index eee68ee7..ca8debde 100644 --- a/src/color.c +++ b/src/color.c @@ -78,7 +78,7 @@ zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (widget)); gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color); g_print ("%s\n", gdk_color_to_string (&color)); -- cgit From 6768a40e997697d05008aecdb41815e1dbae61c6 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 26 Jul 2011 14:00:28 -0300 Subject: Fix for bug #611297 Now Zenity have --ok-label and --cancel-label in all dialogs. This patch doesn't break old zenity scripts. --- src/color.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index ca8debde..5e24e3dc 100644 --- a/src/color.c +++ b/src/color.c @@ -35,6 +35,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) { GtkWidget *dialog; GtkWidget *colorsel; + GtkWidget *button; GdkColor color; zen_data = data; @@ -56,6 +57,22 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) &color); } + if (data->ok_label) { + g_object_get (G_OBJECT (dialog), "ok-button", &button); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + g_object_unref (G_OBJECT (button)); + } + + if (data->cancel_label) { + g_object_get (G_OBJECT (dialog), "cancel-button", &button); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + g_object_unref (G_OBJECT (button)); + } + gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), color_data->show_palette); -- cgit From 5dd7442bd5b544a99553b6e595419ed999ae6eab Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 12 Aug 2012 12:20:07 -0400 Subject: Fix various compiler warnings (two serious) Missing sentinels can cause crashes. The others are just style. --- src/color.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index 5e24e3dc..4c9c1517 100644 --- a/src/color.c +++ b/src/color.c @@ -58,7 +58,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) } if (data->ok_label) { - g_object_get (G_OBJECT (dialog), "ok-button", &button); + g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); @@ -66,7 +66,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) } if (data->cancel_label) { - g_object_get (G_OBJECT (dialog), "cancel-button", &button); + g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); -- cgit From 0628bd3291aad936b6b553366600590cca360bfa Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Tue, 18 Sep 2012 18:33:07 +0200 Subject: util: Add an option to request dialogs being modal As WMs cannot open windows themselves, Mutter uses zenity to open "Force Quit" dialogs for unresponsive windows; as those are strongly tied to the corresponding window, it makes sense to make them modal (in particular when attaching them to their parent). https://bugzilla.gnome.org/show_bug.cgi?id=684322 --- src/color.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index 4c9c1517..791d76da 100644 --- a/src/color.c +++ b/src/color.c @@ -73,6 +73,9 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) g_object_unref (G_OBJECT (button)); } + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), color_data->show_palette); -- cgit From 009523d5da827392b027ac6da1a50f94314e3a35 Mon Sep 17 00:00:00 2001 From: Weitian Leung Date: Fri, 23 Aug 2013 09:15:07 +0800 Subject: added attach option for transient window --- src/color.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index 791d76da..b6a6b121 100644 --- a/src/color.c +++ b/src/color.c @@ -79,7 +79,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), color_data->show_palette); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, -- cgit From 6ac663ea05f00aa42d2aa620968e26e525487201 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 21 Oct 2014 16:05:31 +0200 Subject: Fixing remain g_timeout_add Finish switch g_timeout_add for g_timeout_add_seconds --- src/color.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index b6a6b121..633e3427 100644 --- a/src/color.c +++ b/src/color.c @@ -82,9 +82,9 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, - (GSourceFunc) zenity_util_timeout_handle, - dialog); + g_timeout_add_seconds (data->timeout_delay * 1000, + (GSourceFunc) zenity_util_timeout_handle, + dialog); } gtk_main(); -- cgit From b44b2fb33dac0618e355f8cd5c46be0b3d13eadc Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 21 Oct 2014 16:32:14 +0200 Subject: Fixing g_timeout_add calls --- src/color.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index 633e3427..e3b8a428 100644 --- a/src/color.c +++ b/src/color.c @@ -82,7 +82,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay * 1000, + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } -- cgit From 6fcbb80fd1b5268fbedcdb985ffa873a2e475840 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 04:57:05 +0000 Subject: Do not use an icon for Cancel/OK buttons GTK+ documentation recommends to not use an icons, but use "_OK"/"_Cancel" labels instead --- src/color.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index e3b8a428..6820bbbe 100644 --- a/src/color.c +++ b/src/color.c @@ -60,16 +60,12 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) if (data->ok_label) { g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); g_object_unref (G_OBJECT (button)); } if (data->cancel_label) { g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); g_object_unref (G_OBJECT (button)); } -- cgit From e54c5db6aa0374db35abe8ae6e128648e95a35b1 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 06:30:57 +0000 Subject: src/color.c: Port to GtkColorChooserDialog --- src/color.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index 6820bbbe..2a7e0396 100644 --- a/src/color.c +++ b/src/color.c @@ -34,27 +34,21 @@ static void zenity_colorselection_dialog_response (GtkWidget *widget, int respon void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) { GtkWidget *dialog; - GtkWidget *colorsel; GtkWidget *button; - GdkColor color; + GdkRGBA color; zen_data = data; - dialog = gtk_color_selection_dialog_new (NULL); + dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_colorselection_dialog_response), color_data); - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog)); - if (color_data->color) { - if (gdk_color_parse (color_data->color, &color)) - gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (colorsel), - &color); + if (gdk_rgba_parse (&color, color_data->color)) { + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color); + } } if (data->ok_label) { @@ -72,8 +66,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), - color_data->show_palette); + g_object_set (dialog, "show-editor", !color_data->show_palette, NULL); zenity_util_show_dialog (dialog, data->attach); @@ -89,15 +82,13 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) static void zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data) { - GtkWidget *colorsel; - GdkColor color; + GdkRGBA color; switch (response) { case GTK_RESPONSE_OK: - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (widget)); - gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color); - g_print ("%s\n", gdk_color_to_string (&color)); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); + g_print ("%s\n", gdk_rgba_to_string (&color)); break; case GTK_RESPONSE_CANCEL: -- cgit From ba5ea0386de2a80a664fb28d3af7e8d395968314 Mon Sep 17 00:00:00 2001 From: Gama Anderson Date: Sat, 28 Feb 2015 20:06:09 +0100 Subject: 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 --- src/color.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index e3b8a428..be63068b 100644 --- a/src/color.c +++ b/src/color.c @@ -57,6 +57,14 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) &color); } + 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); @@ -109,6 +117,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; } -- cgit From d063797fdfa73e5bec96d9399ab1bf47173a62d4 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 2 Oct 2015 14:35:06 +0200 Subject: Fixing GLib-CRITICAL messages --- src/color.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index 05898c4d..ae47b19b 100644 --- a/src/color.c +++ b/src/color.c @@ -104,7 +104,7 @@ zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && 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; -- cgit From 4eddb202cafdcabc254aa941ad1348ff09372627 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 7 Apr 2017 14:00:42 +0200 Subject: Fix style Fixing style in all zenity code, removing useless spaces, empty lines, all code in 80 columns, etc. --- src/color.c | 166 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 85 insertions(+), 81 deletions(-) (limited to 'src/color.c') diff --git a/src/color.c b/src/color.c index ae47b19b..9ef233eb 100644 --- a/src/color.c +++ b/src/color.c @@ -23,92 +23,96 @@ #include "config.h" -#include -#include "zenity.h" #include "util.h" +#include "zenity.h" +#include static ZenityData *zen_data; -static void zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data); - -void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) -{ - GtkWidget *dialog; - GtkWidget *button; - GdkRGBA color; - - zen_data = data; - - dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_colorselection_dialog_response), - color_data); - - if (color_data->color) { - if (gdk_rgba_parse (&color, color_data->color)) { - gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color); - } - } - - 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); - g_object_unref (G_OBJECT (button)); - } - - if (data->cancel_label) { - g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - g_object_unref (G_OBJECT (button)); - } - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - g_object_set (dialog, "show-editor", !color_data->show_palette, NULL); - - zenity_util_show_dialog (dialog, data->attach); - - if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, - (GSourceFunc) zenity_util_timeout_handle, - dialog); - } - - gtk_main(); +static void zenity_colorselection_dialog_response ( + GtkWidget *widget, int response, gpointer data); + +void +zenity_colorselection (ZenityData *data, ZenityColorData *color_data) { + GtkWidget *dialog; + GtkWidget *button; + GdkRGBA color; + + zen_data = data; + + dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_colorselection_dialog_response), + color_data); + + if (color_data->color) { + if (gdk_rgba_parse (&color, color_data->color)) { + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color); + } + } + + 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); + g_object_unref (G_OBJECT (button)); + } + + if (data->cancel_label) { + g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + g_object_unref (G_OBJECT (button)); + } + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + g_object_set (dialog, "show-editor", !color_data->show_palette, NULL); + + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + + gtk_main (); } static void -zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - GdkRGBA color; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); - g_print ("%s\n", gdk_rgba_to_string (&color)); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - default: - if (zen_data->extra_label && 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; - } - - gtk_main_quit (); +zenity_colorselection_dialog_response ( + GtkWidget *widget, int response, gpointer data) { + GdkRGBA color; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); + g_print ("%s\n", gdk_rgba_to_string (&color)); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + default: + if (zen_data->extra_label && + 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; + } + + gtk_main_quit (); } -- cgit