From 48c1564ac5ef431e9111606e40488d04a96f3059 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 3 Jan 2003 13:26:04 +0000 Subject: Initial revision --- src/msg.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 src/msg.c (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c new file mode 100644 index 00000000..a8e5c2de --- /dev/null +++ b/src/msg.c @@ -0,0 +1,117 @@ +/* + * msg.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include "zenity.h" +#include "util.h" + +void zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data); + +int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) +{ + GladeXML *glade_dialog; + GtkWidget *dialog; + GtkWidget *text; + + switch (msg_data->mode) { + + case ZENITY_MSG_WARNING: + glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_warning_text"); + break; + + case ZENITY_MSG_QUESTION: + glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_question_text"); + break; + + case ZENITY_MSG_ERROR: + glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); + break; + + default: + g_assert_not_reached (); + break; + } + + if (glade_dialog == NULL) + return FALSE; + + glade_xml_signal_autoconnect (glade_dialog); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else { + GdkPixbuf *pixbuf = NULL; + switch (msg_data->mode) { + + case ZENITY_MSG_WARNING: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); + break; + case ZENITY_MSG_QUESTION: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION); + break; + case ZENITY_MSG_ERROR: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); + break; + default: + break; + } + } + + gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + + gtk_widget_show (dialog); + gtk_main (); + + if (glade_dialog) + g_object_unref (glade_dialog); + + return TRUE; +} + +void +zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data) +{ + GError *error = NULL; + + switch (button) { + case GTK_RESPONSE_OK: + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + gtk_main_quit (); + break; + + default: + break; + } +} -- cgit From 8924d5c401829efc59380fda8823bedca5994bcb Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 6 Jan 2003 21:09:22 +0000 Subject: I love featuritis. Instead of fixing stuff so it actually works, I add 2003-01-06 Glynn Foster * src/main.c, src/msg.c, src/zenity.glade, src/zenity.h: I love featuritis. Instead of fixing stuff so it actually works, I add more stuff. Add support for info dialog. --- src/msg.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index a8e5c2de..5b2cba96 100644 --- a/src/msg.c +++ b/src/msg.c @@ -52,6 +52,12 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); break; + + case ZENITY_MSG_INFO: + glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_info_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_info_text"); + break; default: g_assert_not_reached (); @@ -81,6 +87,9 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) case ZENITY_MSG_ERROR: zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); break; + case ZENITY_MSG_INFO: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO); + break; default: break; } -- cgit From 6a65d75921d352323277f770f357ca3065436133 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Jan 2003 13:22:57 +0000 Subject: Fix up the response signal handlers. Use returns of 0 for 'Ok' and 2003-01-07 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c, src/zenity.glade, src/zenity.h: Fix up the response signal handlers. Use returns of 0 for 'Ok' and 'Close', 1 for 'Cancel' and 'Escape' and -1 for 'Uh Oh'. Get stuff printing to stderr. Fix up the error handling that I thought was improved, although still have issues with popt callback getting called numerous times because of more than one instance of the same kind is being used in poptOption. * TODO: Update accordingly. --- src/msg.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 5b2cba96..bb7190fc 100644 --- a/src/msg.c +++ b/src/msg.c @@ -25,9 +25,10 @@ #include "zenity.h" #include "util.h" -void zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data); +static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); -int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) +void +zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { GladeXML *glade_dialog; GtkWidget *dialog; @@ -64,8 +65,16 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog) + g_object_unref (glade_dialog); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_msg_dialog_response), data); + + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); @@ -99,28 +108,26 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } -void -zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; - switch (button) { + switch (response) { case GTK_RESPONSE_OK: + zen_data->exit_code = 0; gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; gtk_main_quit (); break; default: + zen_data->exit_code = 1; break; } } -- cgit From 1e0ff80be4b1fe6f2e6def15bfc02b2d09312061 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Jan 2003 18:16:50 +0000 Subject: Re-structure the code to pass in the ZenityData structure into the 2003-01-13 Glynn Foster * src/calendar.c: Re-structure the code to pass in the ZenityData structure into the response_callback instead. * src/main.c: Fix the screwups in the commandline parser due to popt being teh suck. * src/msg.c: Don't unref the GladeXML before you use it. * THANKS: New file. --- src/msg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index bb7190fc..cc1f0924 100644 --- a/src/msg.c +++ b/src/msg.c @@ -65,9 +65,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } - if (glade_dialog) - g_object_unref (glade_dialog); - g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_msg_dialog_response), data); @@ -77,6 +74,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) } glade_xml_signal_autoconnect (glade_dialog); + + if (glade_dialog) + g_object_unref (glade_dialog); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); -- cgit From c41421c043ec92da0936ca8005f3e7841abd19cd Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 18 Jan 2003 18:30:52 +0000 Subject: Add some screenshots for the help documentation. 2003-01-18 Glynn Foster * help/C/figures/zenity-calendar-screenshot.png, help/C/figures/zenity-entry-screenshot.png, help/C/figures/zenity-error-screenshot.png, help/C/figures/zenity-fileselection-screenshot.png, help/C/figures/zenity-information-screenshot.png, help/C/figures/zenity-list-screenshot.png, help/C/figures/zenity-progress-screenshot.png, help/C/figures/zenity-question-screenshot.png, help/C/figures/zenity-text-screenshot.png, help/C/figures/zenity-warning-screenshot.png: Add some screenshots for the help documentation. * src/entry.c, src/msg.c: Don't set the text if it's NULL. --- src/msg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index cc1f0924..5c73af0b 100644 --- a/src/msg.c +++ b/src/msg.c @@ -103,8 +103,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } } - - gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + + if (msg_data->dialog_text) + gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); gtk_widget_show (dialog); gtk_main (); -- cgit From 49f89795349a47ae4e061666d84a715bf24f5373 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 10 Mar 2003 17:11:18 +0000 Subject: Mass indentation cleanup. Make sure the glade dialogs aren't initially 2003-03-10 Glynn Foster * src/about.c, src/calendar.c, src/entry.c, src/fileselection.c, src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c, src/util.c, src/util.h, src/zenity.glade, src/zenity.h: Mass indentation cleanup. Make sure the glade dialogs aren't initially visible because this avoids a visibility jump. Apparently == TRUE is bad mojo. Fix up. --- src/msg.c | 185 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 94 insertions(+), 91 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 5c73af0b..feac59dc 100644 --- a/src/msg.c +++ b/src/msg.c @@ -30,105 +30,108 @@ static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointe void zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { - GladeXML *glade_dialog; - GtkWidget *dialog; - GtkWidget *text; - - switch (msg_data->mode) { - - case ZENITY_MSG_WARNING: - glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_warning_text"); - break; - - case ZENITY_MSG_QUESTION: - glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_question_text"); - break; - - case ZENITY_MSG_ERROR: - glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); - break; - - case ZENITY_MSG_INFO: - glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_info_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_info_text"); - break; + GladeXML *glade_dialog; + GtkWidget *dialog; + GtkWidget *text; + + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_warning_text"); + break; + + case ZENITY_MSG_QUESTION: + glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_question_text"); + break; + + case ZENITY_MSG_ERROR: + glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); + break; + + case ZENITY_MSG_INFO: + glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog"); + dialog= glade_xml_get_widget (glade_dialog, "zenity_info_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_info_text"); + break; - default: - g_assert_not_reached (); - break; - } - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_msg_dialog_response), data); - - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } - - glade_xml_signal_autoconnect (glade_dialog); - - if (glade_dialog) - g_object_unref (glade_dialog); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + default: + g_assert_not_reached (); + break; + } - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else { - GdkPixbuf *pixbuf = NULL; - switch (msg_data->mode) { + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_msg_dialog_response), data); - case ZENITY_MSG_WARNING: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); - break; - case ZENITY_MSG_QUESTION: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION); - break; - case ZENITY_MSG_ERROR: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); - break; - case ZENITY_MSG_INFO: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO); - break; - default: - break; - } - } + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } + + glade_xml_signal_autoconnect (glade_dialog); + + if (glade_dialog) + g_object_unref (glade_dialog); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else { + GdkPixbuf *pixbuf = NULL; + + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); + break; + + case ZENITY_MSG_QUESTION: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION); + break; + + case ZENITY_MSG_ERROR: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); + break; + + case ZENITY_MSG_INFO: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO); + break; + + default: + break; + } + } - if (msg_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + if (msg_data->dialog_text) + gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); - gtk_widget_show (dialog); - gtk_main (); + gtk_widget_show (dialog); + gtk_main (); } static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zen_data->exit_code = 0; - gtk_main_quit (); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; - gtk_main_quit (); - break; - - default: - zen_data->exit_code = 1; - break; - } + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; + gtk_main_quit (); + break; + + default: + zen_data->exit_code = 1; + break; + } } -- cgit From 965c2a91497fcf96c88c0029b18a6a1e9f5d46bd Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 13 Apr 2003 15:42:41 +0000 Subject: Finish off the indentation cleanup. Add new '--width' and '--height' 2003-04-13 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c, src/zenity.h: Finish off the indentation cleanup. Add new '--width' and '--height' options to the general options. Fix up the radio list view, so that we can now act like a radio button group. * TODO: Update --- src/msg.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index feac59dc..85b533e3 100644 --- a/src/msg.c +++ b/src/msg.c @@ -106,6 +106,8 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } } + + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); if (msg_data->dialog_text) gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); -- cgit From 65cb873430d7bfcdf0452c76bf07f2ebbb4a21af Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 4 Jun 2003 12:53:46 +0000 Subject: Fix up some build warnings as reported by Ross Burton and his amazing gcc 2003-06-04 Glynn Foster * src/about.c, src/main.c, src/msg.c, src/progress.c, src/tree.c, src/util.c: Fix up some build warnings as reported by Ross Burton and his amazing gcc 3.3 techno machine. --- src/msg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 85b533e3..22f50187 100644 --- a/src/msg.c +++ b/src/msg.c @@ -60,6 +60,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; default: + glade_dialog = NULL; + dialog = NULL; + text = NULL; g_assert_not_reached (); break; } @@ -83,8 +86,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->window_icon) zenity_util_set_window_icon (dialog, data->window_icon); else { - GdkPixbuf *pixbuf = NULL; - switch (msg_data->mode) { case ZENITY_MSG_WARNING: zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); -- cgit From 5bade6fe6a14cce50508ee5d510a4560ebe3e421 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sat, 7 Jun 2003 14:41:56 +0000 Subject: Support user-defined return values via env vars, like dialog did. --- src/msg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 22f50187..2b4083b5 100644 --- a/src/msg.c +++ b/src/msg.c @@ -71,7 +71,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) G_CALLBACK (zenity_msg_dialog_response), data); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -124,12 +124,12 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); gtk_main_quit (); break; -- cgit From b43bbda2e247e72782cf116003d308d21346935f Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 19 Mar 2004 02:28:30 +0000 Subject: Patch from Darren Adams to make sure the new 2004-03-19 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c, src/progress.c, src/text.c, src/tree.c: Patch from Darren Adams to make sure the new file chooser resizes nicely. Sanitize the default setting of the other widgets. * configure.in, src/util.c: Lose gconf dependancy since we don't currently use it, although arguably we should to detect which help browser we're supposed to run :/ * THANKS, src/about.c: Add Darren to the list. --- src/msg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 2b4083b5..bd1450e0 100644 --- a/src/msg.c +++ b/src/msg.c @@ -107,8 +107,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } } - - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); if (msg_data->dialog_text) gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); -- cgit From 62785ed80fb0b86847b4eaa3f4cf596f4c109324 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 26 Apr 2004 04:41:25 +0000 Subject: Add from the 2 Sebastian's, and make email addresses more spam proof. 2004-04-26 Glynn Foster * THANKS, src/about.c: Add from the 2 Sebastian's, and make email addresses more spam proof. * src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c, * src/progress.c, src/text.c, src/tree.c, src/util.c, * src/util.h: Patch from Sebastian Kapfer to make all zenity dialogs transients of the parent xterm. Fixes #136226. * src/zenity.glade: Patch from Sebastian Heinlein to improve things HIG wise. Fixes #140745. --- src/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index bd1450e0..7ce78c58 100644 --- a/src/msg.c +++ b/src/msg.c @@ -114,7 +114,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->dialog_text) gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); - gtk_widget_show (dialog); + zenity_util_show_dialog (dialog); gtk_main (); } -- cgit From 6a17938c959a4418d2c42ef903fa40916defae2f Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 18 Jul 2004 23:40:20 +0000 Subject: Make sure the text can take markup, so that people can create nice HIG 2004-07-19 Glynn Foster * src/msg.c: Make sure the text can take markup, so that people can create nice HIG compliant message dialogs. Patch from Sebastian Heinlein. Fixes #140748. --- src/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 7ce78c58..013fc721 100644 --- a/src/msg.c +++ b/src/msg.c @@ -112,7 +112,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); if (msg_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + gtk_label_set_markup (GTK_LABEL (text), msg_data->dialog_text); zenity_util_show_dialog (dialog); gtk_main (); -- cgit From 63661a6ea0de0250b545d794f645a36ffeb88490 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 19 Jul 2004 01:13:40 +0000 Subject: src/calendar.c, src/entry.c, src/fileselection.c, Cleanup fixes from Paul 2004-07-19 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, * src/msg.c, src/progress.c, src/text.c, src/tree.c: Cleanup fixes from Paul Bolle. --- src/msg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 013fc721..27284472 100644 --- a/src/msg.c +++ b/src/msg.c @@ -126,16 +126,15 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - gtk_main_quit (); break; default: - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + gtk_main_quit (); } -- cgit From 3e05834b4c23a5d5951403719b8594ff3d9fe30b Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Sep 2004 07:51:51 +0000 Subject: Add new notification icon. Update for new files. Restructure code a little 2004-09-13 Glynn Foster * data/Makefile.am, data/zenity-notification.png: Add new notification icon. * src/Makefile.am: Update for new files. * src/about.c, src/calendar.c, src/entry.c, src/fileselection.c, src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a little bit for new utility functions for setting window icons. * src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area support. * src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h: Add support for notification area. * data/zenity.1, help/*: Update docs for notification and new file selection changes. --- src/msg.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 27284472..ffb2e531 100644 --- a/src/msg.c +++ b/src/msg.c @@ -83,29 +83,25 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else { - switch (msg_data->mode) { - case ZENITY_MSG_WARNING: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); - break; - - case ZENITY_MSG_QUESTION: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION); - break; + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_WARNING); + break; + + case ZENITY_MSG_QUESTION: + zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION); + break; - case ZENITY_MSG_ERROR: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); - break; + case ZENITY_MSG_ERROR: + zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_ERROR); + break; - case ZENITY_MSG_INFO: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO); - break; + case ZENITY_MSG_INFO: + zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_INFO); + break; - default: - break; - } + default: + break; } if (data->width > -1 || data->height > -1) -- cgit From 6e6eeaf79c01b6cc755b57dac7e7ff2d36038316 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 20 Apr 2005 01:59:42 +0000 Subject: Bug fix for #149290, based on contributions from Timo Aaltonen, Lucas 2005-04-20 Glynn Foster * src/msg.c, src/option.c, src/zenity.h: Bug fix for #149290, based on contributions from Timo Aaltonen, Lucas Rocha, and Carlos Parra. * THANKS: Update. --- src/msg.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index ffb2e531..2449c007 100644 --- a/src/msg.c +++ b/src/msg.c @@ -110,6 +110,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), msg_data->dialog_text); + if (msg_data->no_wrap) + gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); + zenity_util_show_dialog (dialog); gtk_main (); } -- cgit From 6abd93050f533752e47b75158e95431575c652ac Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 25 Apr 2005 03:20:45 +0000 Subject: COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, src/entry.c, 2005-04-25 Glynn Foster * COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, * src/entry.c, src/fileselection.c, src/main.c, src/msg.c, * src/notification.c, src/option.c, src/progress.c, * src/text.c, src/tree.c, src/util.c: Update the FSF address to point to 51 Franklin Street, Fifth Floor as per forwarded mail from Alvaro Lopez Ortega. --- src/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 2449c007..0c46c362 100644 --- a/src/msg.c +++ b/src/msg.c @@ -15,8 +15,8 @@ * * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ -- cgit From 4c328078b6ff16a0ba648f53c3bee7a68fe4dbc5 Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Wed, 6 Jul 2005 20:13:11 +0000 Subject: Include cleanups (config.h) --- src/msg.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 0c46c362..b400f0bd 100644 --- a/src/msg.c +++ b/src/msg.c @@ -21,6 +21,8 @@ * Authors: Glynn Foster */ +#include "config.h" + #include #include "zenity.h" #include "util.h" -- cgit From c8b9b79813c426837092ccda149bb3f2ca9c58be Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 14 Nov 2005 04:25:58 +0000 Subject: make it possible to add new lines in the in the msg dialog (Fixes bug 2005-11-13 Lucas Rocha * src/msg.c: make it possible to add new lines in the in the msg dialog (Fixes bug #320787). --- src/msg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index b400f0bd..973062ee 100644 --- a/src/msg.c +++ b/src/msg.c @@ -109,9 +109,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (msg_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), msg_data->dialog_text); - + if (msg_data->dialog_text) + gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); + if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); -- cgit From 8b16d4d4122e6337517ec16b9ca22dd27df0dafb Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 13 Aug 2007 20:36:29 +0000 Subject: added timeout option to all dialogs (Fixes bug #160654). Based on patch 2007-08-13 Lucas Rocha * src/*.c: added timeout option to all dialogs (Fixes bug #160654). Based on patch from Muthiah Annamalai . svn path=/trunk/; revision=1231 --- src/msg.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 973062ee..cbe6e3af 100644 --- a/src/msg.c +++ b/src/msg.c @@ -116,6 +116,11 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); 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 (); } -- cgit From 2141cb9184c20be91e469b2bd4e4bb22e57faba3 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 29 Mar 2008 22:13:50 +0000 Subject: Allow question dialogs to use custom button label text (Fixes bug 2008-03-30 Lucas Rocha Allow question dialogs to use custom button label text (Fixes bug #335763). Patch from Cosimo Cecchi and Thomas Thurman . * 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. svn path=/trunk/; revision=1346 --- src/msg.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index cbe6e3af..90e51642 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: -- cgit From eeb43bf65b8fd1f41b30e69fd898526ba02d9f78 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 7 Apr 2008 19:06:21 +0000 Subject: fix memory leak on custom labels (Fixes bug #526627). Patch by 2008-03-30 Lucas Rocha * src/msg.c (zenity_msg_construct_question_dialog): fix memory leak on custom labels (Fixes bug #526627). Patch by kraai@ftbfs.org. svn path=/trunk/; revision=1348 --- src/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 90e51642..03642686 100644 --- a/src/msg.c +++ b/src/msg.c @@ -40,13 +40,13 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data 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_label (GTK_BUTTON (cancel_button), 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_label (GTK_BUTTON (ok_button), msg_data->ok_label); gtk_button_set_image (GTK_BUTTON (ok_button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } -- cgit From 3f33966167cf2216f813c091d47461c451837602 Mon Sep 17 00:00:00 2001 From: Felix Riemann Date: Mon, 20 Jul 2009 10:23:32 +0200 Subject: Bug 578393 – convert from libglade to GtkBuilder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/msg.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 03642686..cf0e47d0 100644 --- a/src/msg.c +++ b/src/msg.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -55,56 +54,53 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data void zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { - GladeXML *glade_dialog; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text; + GObject *text; switch (msg_data->mode) { case ZENITY_MSG_WARNING: - glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_warning_text"); + builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog")); + text = gtk_builder_get_object (builder, "zenity_warning_text"); break; case ZENITY_MSG_QUESTION: - glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_question_text"); + 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"); break; case ZENITY_MSG_ERROR: - glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); + builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog")); + text = gtk_builder_get_object (builder, "zenity_error_text"); break; case ZENITY_MSG_INFO: - glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog"); - dialog= glade_xml_get_widget (glade_dialog, "zenity_info_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_info_text"); + builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog")); + text = gtk_builder_get_object (builder, "zenity_info_text"); break; default: - glade_dialog = NULL; + builder = NULL; dialog = NULL; text = NULL; g_assert_not_reached (); break; } - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_msg_dialog_response), data); - - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - - glade_xml_signal_autoconnect (glade_dialog); - - if (glade_dialog) - g_object_unref (glade_dialog); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_msg_dialog_response), data); + + gtk_builder_connect_signals (builder, NULL); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -145,6 +141,8 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); } + g_object_unref (builder); + gtk_main (); } -- cgit From c1f2e66288e5fbb5e2b4402139f45cb96735d24a Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 10 Aug 2009 04:17:47 +0100 Subject: Bug 572835 – Zenity --question should be yes or no MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index cf0e47d0..fd92289c 100644 --- a/src/msg.c +++ b/src/msg.c @@ -33,8 +33,8 @@ 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); + 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); -- cgit From 1570a2bbf07627cb5f8d9828a95db67b7d00634c Mon Sep 17 00:00:00 2001 From: Philippe Gauthier Date: Fri, 30 Oct 2009 14:51:16 -0400 Subject: Use g_timeout_add_seconds instead g_timeout_add The calls to g_timeout_add are replaced with g_timeout_add_seconds to reduce the number or program wake ups. See the GNOME Goal description: http://live.gnome.org/GnomeGoals/UseTimeoutAddSeconds --- src/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index fd92289c..1a92875b 100644 --- a/src/msg.c +++ b/src/msg.c @@ -138,7 +138,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } g_object_unref (builder); -- 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/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 1a92875b..567ee23d 100644 --- a/src/msg.c +++ b/src/msg.c @@ -138,7 +138,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } g_object_unref (builder); -- cgit From f77a0199af3a3d1362be95ab651186546492e8cd Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 16 Jun 2011 14:45:52 -0300 Subject: Fix the msg forms (question, warning, error) to return 5 when timeout --- src/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 567ee23d..1a92875b 100644 --- a/src/msg.c +++ b/src/msg.c @@ -138,7 +138,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } g_object_unref (builder); -- 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/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 1a92875b..1f060c5a 100644 --- a/src/msg.c +++ b/src/msg.c @@ -153,7 +153,7 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) 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); break; case GTK_RESPONSE_CANCEL: -- cgit From d8954d9222654f645ebdcc1752c70be97faaae45 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 6 Jul 2011 14:55:30 -0300 Subject: Patch for bug #621907 This patch add the option --no-markup in the info, warning, error and question dialogs So if the user wants to use & \ ' and other symbols, now he can, and no error will be showed. --- src/msg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 1f060c5a..b5a1aa01 100644 --- a/src/msg.c +++ b/src/msg.c @@ -131,7 +131,10 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); - + + if (msg_data->no_markup) + gtk_label_set_use_markup (GTK_LABEL (text), FALSE); + if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); -- cgit From 3f5c1667926bbd8071be69727d3688ef73b10164 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 6 Jul 2011 15:09:38 -0300 Subject: Forgot change one option in gtk_label --- src/msg.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index b5a1aa01..5df884ff 100644 --- a/src/msg.c +++ b/src/msg.c @@ -129,11 +129,12 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (msg_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); - - if (msg_data->no_markup) - gtk_label_set_use_markup (GTK_LABEL (text), FALSE); + if (msg_data->dialog_text) { + if (msg_data->no_markup) + 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)); + } if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); -- 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/msg.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 5df884ff..667239b1 100644 --- a/src/msg.c +++ b/src/msg.c @@ -29,7 +29,7 @@ static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); static void -zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data) +zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { GtkWidget *cancel_button, *ok_button; @@ -38,14 +38,14 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data gtk_widget_grab_focus (ok_button); - if (msg_data->cancel_label) { - gtk_button_set_label (GTK_BUTTON (cancel_button), msg_data->cancel_label); + if (data->cancel_label) { + gtk_button_set_label (GTK_BUTTON (cancel_button), 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), msg_data->ok_label); + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); gtk_button_set_image (GTK_BUTTON (ok_button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } @@ -56,6 +56,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { GtkBuilder *builder; GtkWidget *dialog; + GtkWidget *ok_button; GObject *text; switch (msg_data->mode) { @@ -63,30 +64,35 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog")); text = gtk_builder_get_object (builder, "zenity_warning_text"); + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_ok_button")); break; case ZENITY_MSG_QUESTION: 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"); + ok_button = NULL; break; case ZENITY_MSG_ERROR: builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog")); text = gtk_builder_get_object (builder, "zenity_error_text"); + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_ok_button")); break; case ZENITY_MSG_INFO: builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog")); text = gtk_builder_get_object (builder, "zenity_info_text"); + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_ok_button")); break; default: builder = NULL; dialog = NULL; text = NULL; + ok_button = NULL; g_assert_not_reached (); break; } @@ -104,6 +110,14 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (ok_button) { + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (ok_button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + } + switch (msg_data->mode) { case ZENITY_MSG_WARNING: zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_WARNING); @@ -111,7 +125,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); + zenity_msg_construct_question_dialog (dialog, msg_data, data); break; case ZENITY_MSG_ERROR: -- 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/msg.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 667239b1..505f961c 100644 --- a/src/msg.c +++ b/src/msg.c @@ -142,6 +142,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); if (msg_data->dialog_text) { if (msg_data->no_markup) -- cgit From bbcb2a3783de925b93707b8e76110ec9ebaed552 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Tue, 18 Sep 2012 22:51:08 +0200 Subject: msg: Add an option to set a custom dialog icon The predefined dialog icons work well in many cases, but sometimes it makes sense to use a more specific icon, so add an option to specify an icon-name to use instead. https://bugzilla.gnome.org/show_bug.cgi?id=684329 --- src/msg.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 505f961c..229f0cec 100644 --- a/src/msg.c +++ b/src/msg.c @@ -58,12 +58,14 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) GtkWidget *dialog; GtkWidget *ok_button; GObject *text; + GObject *image; switch (msg_data->mode) { case ZENITY_MSG_WARNING: builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog")); text = gtk_builder_get_object (builder, "zenity_warning_text"); + image = gtk_builder_get_object (builder, "zenity_warning_image"); ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_ok_button")); break; @@ -71,6 +73,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) 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"); + image = gtk_builder_get_object (builder, "zenity_question_image"); ok_button = NULL; break; @@ -78,6 +81,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog")); text = gtk_builder_get_object (builder, "zenity_error_text"); + image = gtk_builder_get_object (builder, "zenity_error_image"); ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_ok_button")); break; @@ -85,6 +89,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog")); text = gtk_builder_get_object (builder, "zenity_info_text"); + image = gtk_builder_get_object (builder, "zenity_info_image"); ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_ok_button")); break; @@ -92,6 +97,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) builder = NULL; dialog = NULL; text = NULL; + image = NULL; ok_button = NULL; g_assert_not_reached (); break; @@ -152,6 +158,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) else gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); } + + if (msg_data->dialog_icon) + gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); -- 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/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 229f0cec..53f8a5df 100644 --- a/src/msg.c +++ b/src/msg.c @@ -165,7 +165,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); -- cgit From b0fc720fe4584530d1090cd3e9175905e6381c85 Mon Sep 17 00:00:00 2001 From: Berislav Kovacki Date: Sat, 23 Nov 2013 16:44:26 -0200 Subject: Bug #534935 Need hability to specify default answer in --question dialog --- src/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') 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); -- cgit From ec0c2f3292b3db0fdad7f02ed068a97b66f7a2ea Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 20 May 2014 16:05:32 -0300 Subject: Add the --ellipsize option to info, error, warning and question dialogs This option will help people who need to add huge texts in their dialogs and the window size get's very huge due amount of size that GtkLabel requests --- src/msg.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index f4d5e7a9..f5d4dc94 100644 --- a/src/msg.c +++ b/src/msg.c @@ -159,6 +159,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); } + if (msg_data->ellipsize) + gtk_label_set_ellipsize (GTK_LABEL(text), PANGO_ALIGN_RIGHT); + if (msg_data->dialog_icon) gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); @@ -176,6 +179,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_main (); } + static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { -- cgit From e5eb127e9779b9a58e53b1a7d268b81284ebd241 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 29 May 2014 17:51:46 -0300 Subject: Bug #670496 and #673643 This fix the size of GtkLabel width when you have a big text in the dialog. --- src/msg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index f5d4dc94..f287f25d 100644 --- a/src/msg.c +++ b/src/msg.c @@ -27,7 +27,7 @@ #include "util.h" static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); - +static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data); static void zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { @@ -161,6 +161,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->ellipsize) gtk_label_set_ellipsize (GTK_LABEL(text), PANGO_ALIGN_RIGHT); + else + g_signal_connect_after (G_OBJECT (text), "size-allocate", + G_CALLBACK (zenity_text_size_allocate), data); if (msg_data->dialog_icon) gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); @@ -179,6 +182,11 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_main (); } +static void +zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) +{ + gtk_widget_set_size_request (widget, allocation->width, -1); +} static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) -- cgit From 210b073bcd4ee3d6d7a3c743ac407703cff60185 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 22 Oct 2014 15:16:22 +0200 Subject: Better sollution for wrap text This fix is a better sollution for info, error, warning and question dialog. Now the dialog wraps the text properly, and don't allocate a lot of height --- src/msg.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index f287f25d..49137e38 100644 --- a/src/msg.c +++ b/src/msg.c @@ -146,9 +146,17 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } - if (data->width > -1 || data->height > -1) + if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->width > -1) + gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); + else + if (!msg_data->ellipsize) + g_signal_connect_after (G_OBJECT (text), "size-allocate", + G_CALLBACK (zenity_text_size_allocate), data); + + if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); @@ -161,13 +169,10 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->ellipsize) gtk_label_set_ellipsize (GTK_LABEL(text), PANGO_ALIGN_RIGHT); - else - g_signal_connect_after (G_OBJECT (text), "size-allocate", - G_CALLBACK (zenity_text_size_allocate), data); - + if (msg_data->dialog_icon) gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); - + if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); @@ -185,7 +190,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) { - gtk_widget_set_size_request (widget, allocation->width, -1); + gtk_widget_set_size_request (widget, allocation->width/2, -1); } static void -- cgit From b5460887fb2b37d1f7aa2edc5dc53b86152cfb2a Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 22 Oct 2014 15:35:22 +0200 Subject: Bug #700249 - Progress dialog does not wrap --- src/msg.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 49137e38..4132ae98 100644 --- a/src/msg.c +++ b/src/msg.c @@ -149,13 +149,12 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (data->width > -1) - gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); - else - if (!msg_data->ellipsize) - g_signal_connect_after (G_OBJECT (text), "size-allocate", - G_CALLBACK (zenity_text_size_allocate), data); - + if (data->width > -1) + gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); + else + if (!msg_data->ellipsize) + g_signal_connect_after (G_OBJECT (text), "size-allocate", + G_CALLBACK (zenity_text_size_allocate), data); if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); -- 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/msg.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 4132ae98..ce25ab3a 100644 --- a/src/msg.c +++ b/src/msg.c @@ -40,14 +40,10 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data if (data->cancel_label) { gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (cancel_button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } if (data->ok_label) { gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (ok_button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } } @@ -119,8 +115,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (ok_button) { if (data->ok_label) { gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (ok_button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } } -- cgit From 1a43253ac568bc8ff293746477361a33a4469f88 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 05:17:25 +0000 Subject: Do not use a stock answer for yes/no buttons --- src/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index ce25ab3a..73c48981 100644 --- a/src/msg.c +++ b/src/msg.c @@ -33,8 +33,8 @@ 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_NO, GTK_RESPONSE_CANCEL); - ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_YES, GTK_RESPONSE_OK); + cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_No"), GTK_RESPONSE_CANCEL); + ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Yes"), GTK_RESPONSE_OK); gtk_widget_grab_focus (msg_data->default_cancel ? cancel_button : ok_button); -- cgit From fba4f05582d6c84030354ba3e1adc228543a3919 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 06:02:41 +0000 Subject: Rework zenity_util_set_window_icon* to not use stock images --- src/msg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 73c48981..6892e733 100644 --- a/src/msg.c +++ b/src/msg.c @@ -120,20 +120,20 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) switch (msg_data->mode) { case ZENITY_MSG_WARNING: - zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_WARNING); + zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-warning"); break; case ZENITY_MSG_QUESTION: - zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION); + zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-question"); zenity_msg_construct_question_dialog (dialog, msg_data, data); break; case ZENITY_MSG_ERROR: - zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_ERROR); + zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-error"); break; case ZENITY_MSG_INFO: - zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_INFO); + zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-information"); break; default: -- cgit From 4fe3fa98d941f2a00750bc5ce0c2a23846006265 Mon Sep 17 00:00:00 2001 From: Andreas Mohr Date: Tue, 21 Apr 2015 09:55:40 +0200 Subject: Bug #734196 --info destroys X11 primary selection content, and does not document that either --- src/msg.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 4132ae98..fb549421 100644 --- a/src/msg.c +++ b/src/msg.c @@ -51,6 +51,31 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data } } +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 + True + True + . + */ + g_object_set(gtk_widget_get_settings (widget), + "gtk-label-select-on-focus", + FALSE, + NULL); +} + void zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { @@ -164,6 +189,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) -- 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/msg.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index fb549421..6f077501 100644 --- a/src/msg.c +++ b/src/msg.c @@ -31,8 +31,10 @@ 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), GTK_STOCK_NO, GTK_RESPONSE_CANCEL); ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_YES, GTK_RESPONSE_OK); @@ -49,6 +51,8 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data gtk_button_set_image (GTK_BUTTON (ok_button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } + + } static void @@ -95,6 +99,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"); @@ -128,6 +133,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; @@ -159,6 +172,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_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION); + break; + case ZENITY_MSG_ERROR: zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_ERROR); break; @@ -233,6 +250,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; } -- 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/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index ddaab266..da4783d4 100644 --- a/src/msg.c +++ b/src/msg.c @@ -244,7 +244,7 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) 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 db4a0c3c0f8b224870ea23a3b3c25f800ee4870a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 17 Mar 2017 14:10:10 -0400 Subject: Fix misleading indentation Coverity flagged this. https://bugzilla.gnome.org/show_bug.cgi?id=780217 --- src/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index da4783d4..3fe102fa 100644 --- a/src/msg.c +++ b/src/msg.c @@ -200,7 +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)); + zenity_label_widget_clipboard_selection(GTK_WIDGET (text)); } if (msg_data->ellipsize) -- cgit From 3b64d05e8a1aae1581d2bec7288d80ac4699e1b1 Mon Sep 17 00:00:00 2001 From: Alan Date: Sat, 18 Mar 2017 10:24:47 +0000 Subject: Fix message dialog width and height on recent Gtk The fix for Zenity bug 670496 "Zenity info/error windows grow in height with message length" (https://bugzilla.gnome.org/show_bug.cgi?id=670496) stopped working on recent Gtk, which doesn't seem to honor gtk_widget_set_size_request. This commit workarounds Gtk bug 657621 "Calculate the wrong height of labels wrapping on words" (https://bugzilla.gnome.org/show_bug.cgi?id=657621) by setting label's width-chars and max-width-chars to 60. This magic number was picked from GtkMessageDialog source (https://git.gnome.org/browse/gtk+/tree/gtk/ui/gtkmessagedialog.ui#n48). --- src/msg.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index 3fe102fa..d1ea6fae 100644 --- a/src/msg.c +++ b/src/msg.c @@ -27,7 +27,6 @@ #include "util.h" static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); -static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data); static void zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { @@ -188,9 +187,13 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1) gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); else - if (!msg_data->ellipsize) - g_signal_connect_after (G_OBJECT (text), "size-allocate", - G_CALLBACK (zenity_text_size_allocate), data); + if (!msg_data->ellipsize && !msg_data->no_wrap) { + // the magic number 60 is picked from gtk+/gtk/ui/gtkmessagedialog.ui + // however, 60 would increase the distance between the icon and the text, + // decreasing to 10 fix it. + gtk_label_set_width_chars (text, 10); + gtk_label_set_max_width_chars (text, 10); + } if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); @@ -223,12 +226,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_main (); } -static void -zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) -{ - gtk_widget_set_size_request (widget, allocation->width/2, -1); -} - static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { -- 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/msg.c | 435 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 227 insertions(+), 208 deletions(-) (limited to 'src/msg.c') diff --git a/src/msg.c b/src/msg.c index d1ea6fae..ca14d867 100644 --- a/src/msg.c +++ b/src/msg.c @@ -23,228 +23,247 @@ #include "config.h" -#include "zenity.h" #include "util.h" +#include "zenity.h" -static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_msg_dialog_response ( + GtkWidget *widget, int response, gpointer data); static void -zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) -{ - +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); - ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Yes"), GTK_RESPONSE_OK); + GtkWidget *cancel_button, *ok_button; - gtk_widget_grab_focus (msg_data->default_cancel ? cancel_button : ok_button); + cancel_button = gtk_dialog_add_button ( + GTK_DIALOG (dialog), _ ("_No"), GTK_RESPONSE_CANCEL); + ok_button = gtk_dialog_add_button ( + GTK_DIALOG (dialog), _ ("_Yes"), GTK_RESPONSE_OK); - if (data->cancel_label) { - gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); - } + gtk_widget_grab_focus ( + msg_data->default_cancel ? cancel_button : ok_button); - if (data->ok_label) { - gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - } - + if (data->cancel_label) { + gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); + } + 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 - True - True - . - */ - g_object_set(gtk_widget_get_settings (widget), - "gtk-label-select-on-focus", - FALSE, - NULL); +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 + True + True + . + */ + g_object_set (gtk_widget_get_settings (widget), + "gtk-label-select-on-focus", + FALSE, + NULL); } -void -zenity_msg (ZenityData *data, ZenityMsgData *msg_data) -{ - GtkBuilder *builder; - GtkWidget *dialog; - GtkWidget *ok_button; - GObject *text; - GObject *image; - - switch (msg_data->mode) { - case ZENITY_MSG_WARNING: - builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog")); - text = gtk_builder_get_object (builder, "zenity_warning_text"); - image = gtk_builder_get_object (builder, "zenity_warning_image"); - ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_ok_button")); - 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"); - image = gtk_builder_get_object (builder, "zenity_question_image"); - ok_button = NULL; - break; - - case ZENITY_MSG_ERROR: - builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog")); - text = gtk_builder_get_object (builder, "zenity_error_text"); - image = gtk_builder_get_object (builder, "zenity_error_image"); - ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_ok_button")); - break; - - case ZENITY_MSG_INFO: - builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog")); - text = gtk_builder_get_object (builder, "zenity_info_text"); - image = gtk_builder_get_object (builder, "zenity_info_image"); - ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_ok_button")); - break; - - default: - builder = NULL; - dialog = NULL; - text = NULL; - image = NULL; - ok_button = NULL; - g_assert_not_reached (); - 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; - } - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_msg_dialog_response), data); - - gtk_builder_connect_signals (builder, NULL); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - if (ok_button) { - if (data->ok_label) { - gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - } - } - - switch (msg_data->mode) { - case ZENITY_MSG_WARNING: - zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-warning"); - break; - - case ZENITY_MSG_QUESTION: - zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-question"); - 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; - - case ZENITY_MSG_INFO: - zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-information"); - break; - - default: - break; - } - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - - if (data->width > -1) - gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); - else - if (!msg_data->ellipsize && !msg_data->no_wrap) { - // the magic number 60 is picked from gtk+/gtk/ui/gtkmessagedialog.ui - // however, 60 would increase the distance between the icon and the text, - // decreasing to 10 fix it. - gtk_label_set_width_chars (text, 10); - gtk_label_set_max_width_chars (text, 10); - } - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - if (msg_data->dialog_text) { - if (msg_data->no_markup) - 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) - gtk_label_set_ellipsize (GTK_LABEL(text), PANGO_ALIGN_RIGHT); - - if (msg_data->dialog_icon) - gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); - - if (msg_data->no_wrap) - gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); - - zenity_util_show_dialog (dialog, data->attach); - - if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); - } - - g_object_unref (builder); - - gtk_main (); +void +zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { + GtkBuilder *builder; + GtkWidget *dialog; + GtkWidget *ok_button; + GObject *text; + GObject *image; + + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); + dialog = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_warning_dialog")); + text = gtk_builder_get_object (builder, "zenity_warning_text"); + image = gtk_builder_get_object (builder, "zenity_warning_image"); + ok_button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_warning_ok_button")); + 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"); + image = gtk_builder_get_object (builder, "zenity_question_image"); + ok_button = NULL; + break; + + case ZENITY_MSG_ERROR: + builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); + dialog = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_error_dialog")); + text = gtk_builder_get_object (builder, "zenity_error_text"); + image = gtk_builder_get_object (builder, "zenity_error_image"); + ok_button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_error_ok_button")); + break; + + case ZENITY_MSG_INFO: + builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); + dialog = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_info_dialog")); + text = gtk_builder_get_object (builder, "zenity_info_text"); + image = gtk_builder_get_object (builder, "zenity_info_image"); + ok_button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_info_ok_button")); + break; + + default: + builder = NULL; + dialog = NULL; + text = NULL; + image = NULL; + ok_button = NULL; + g_assert_not_reached (); + 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; + } + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_msg_dialog_response), + data); + + gtk_builder_connect_signals (builder, NULL); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (ok_button) { + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); + } + } + + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + zenity_util_set_window_icon_from_icon_name ( + dialog, data->window_icon, "dialog-warning"); + break; + + case ZENITY_MSG_QUESTION: + zenity_util_set_window_icon_from_icon_name ( + dialog, data->window_icon, "dialog-question"); + 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; + + case ZENITY_MSG_INFO: + zenity_util_set_window_icon_from_icon_name ( + dialog, data->window_icon, "dialog-information"); + break; + + default: + break; + } + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + + if (data->width > -1) + gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); + else if (!msg_data->ellipsize && !msg_data->no_wrap) { + // the magic number 60 is picked from gtk+/gtk/ui/gtkmessagedialog.ui + // however, 60 would increase the distance between the icon and the + // text, + // decreasing to 10 fix it. + gtk_label_set_width_chars (text, 10); + gtk_label_set_max_width_chars (text, 10); + } + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + if (msg_data->dialog_text) { + if (msg_data->no_markup) + 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) + gtk_label_set_ellipsize (GTK_LABEL (text), PANGO_ALIGN_RIGHT); + + if (msg_data->dialog_icon) + gtk_image_set_from_icon_name ( + GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); + + if (msg_data->no_wrap) + gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); + + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + NULL); + } + + g_object_unref (builder); + + gtk_main (); } static void -zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - 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_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + 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