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/calendar.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/calendar.c (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c new file mode 100644 index 00000000..4cdf4811 --- /dev/null +++ b/src/calendar.c @@ -0,0 +1,90 @@ +/* + * calendar.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_calendar_dialog_response (GtkWindow *window, int button, gpointer data); + +int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) +{ + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *calendar; + GtkWidget *text; + + glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); + + if (glade_dialog == NULL) + return FALSE; + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_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 + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + + text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); + gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); + + calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); + + if (cal_data->month != 0 && cal_data->year !=0) + gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month, cal_data->year); + if (cal_data->day) + gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); + + gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); + gtk_widget_show (dialog); + gtk_main (); + + if (glade_dialog) + g_object_unref (glade_dialog); + + return TRUE; +} + +void +zenity_calendar_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 a8c3006035a068069ed9199400472332db540bb5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Jan 2003 00:01:00 +0000 Subject: Improve error handling... a lot. 2003-01-06 Glynn Foster * src/calendar.c, src/main.c, src/progress.c, src/tree.c, src/zenity.h: Improve error handling... a lot. --- src/calendar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 4cdf4811..0264ce17 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -55,9 +55,9 @@ int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); - if (cal_data->month != 0 && cal_data->year !=0) + if (cal_data->month > 0 && cal_data->year > 0) gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month, cal_data->year); - if (cal_data->day) + if (cal_data->day > 0) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); -- 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/calendar.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 0264ce17..df5d35c1 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -25,23 +25,32 @@ #include "zenity.h" #include "util.h" -void zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data); -int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) +static GtkWidget *calendar; + +static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data); + +void +zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { GladeXML *glade_dialog = NULL; GtkWidget *dialog; - GtkWidget *calendar; GtkWidget *text; glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_calendar_dialog_response), data); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -55,36 +64,41 @@ int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); + if (glade_dialog) + g_object_unref (glade_dialog); + if (cal_data->month > 0 && cal_data->year > 0) - gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month, cal_data->year); + gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); if (cal_data->day > 0) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } -void -zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; + guint day, month, year; - switch (button) { + switch (response) { case GTK_RESPONSE_OK: + gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); + g_printerr ("%02d/%02d/%02d\n", day, month + 1, year); + zen_data->exit_code = 0; gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; gtk_main_quit (); break; default: + /* Esc dialog */ + zen_data->exit_code = 1; break; } } -- cgit From cd4e438bfb3ebfd3cc872e203e343a50acc02a15 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Thu, 9 Jan 2003 18:07:04 +0000 Subject: Fix up the date string, although I guess this should be localized. 2003-01-09 Glynn Foster * src/calendar.c: Fix up the date string, although I guess this should be localized. * src/main.c: Add a new --pulsate option, which reads from stdin and pulsates the progress bar until we reach EOF. * src/progress.c: Rewrite to actually work. Don't really need GIOChannels here. * TODO: Updated accordingly. --- src/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index df5d35c1..4d521be2 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -86,7 +86,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - g_printerr ("%02d/%02d/%02d\n", day, month + 1, year); + g_printerr ("%02d/%02d/%02d\n", year, month + 1, day); zen_data->exit_code = 0; gtk_main_quit (); break; -- cgit From 9a77e41fecb3489b069aa7b1bb52ba56f1052819 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Mon, 13 Jan 2003 17:35:57 +0000 Subject: Localise output of --calendar dialog by default (using nl_langinfo), and provide a --date-format option to provide a strftime-style format for the returned date. --- src/calendar.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 4d521be2..29768caa 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -22,6 +22,7 @@ */ #include +#include #include "zenity.h" #include "util.h" @@ -49,7 +50,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_calendar_dialog_response), data); + G_CALLBACK (zenity_calendar_dialog_response), cal_data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -80,13 +81,20 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - guint day, month, year; - + ZenityCalendarData *cal_data = data; + ZenityData *zen_data; + gint day, month, year; + gchar time_string[128]; + GDate *date = NULL; + switch (response) { case GTK_RESPONSE_OK: gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - g_printerr ("%02d/%02d/%02d\n", year, month + 1, day); + date = g_date_new_dmy (year, month+1, day); + g_date_strftime (time_string, 127, + cal_data->date_format, date); + g_printerr ("%s\n",time_string); + g_date_free ( date ); zen_data->exit_code = 0; gtk_main_quit (); 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/calendar.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 29768caa..65c2bf90 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -28,6 +28,7 @@ static GtkWidget *calendar; +static ZenityCalendarData *zen_cal_data; static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data); @@ -38,6 +39,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) GtkWidget *dialog; GtkWidget *text; + zen_cal_data = cal_data; + glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); if (glade_dialog == NULL) { @@ -50,7 +53,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_calendar_dialog_response), cal_data); + G_CALLBACK (zenity_calendar_dialog_response), data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -81,20 +84,22 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityCalendarData *cal_data = data; ZenityData *zen_data; gint day, month, year; gchar time_string[128]; GDate *date = NULL; - + + zen_data = data; + switch (response) { case GTK_RESPONSE_OK: gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - date = g_date_new_dmy (year, month+1, day); + date = g_date_new_dmy (year, month + 1, day); g_date_strftime (time_string, 127, - cal_data->date_format, date); - g_printerr ("%s\n",time_string); - g_date_free ( date ); + zen_cal_data->date_format, date); + g_printerr ("%s\n", time_string); + if (date != NULL) + g_date_free (date); zen_data->exit_code = 0; gtk_main_quit (); break; -- cgit From 18760d406d64f71f7ca6fec5a7a01978418fa8f5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 18 Jan 2003 18:02:14 +0000 Subject: Only some examples and some screenshots and we're mostly done for a first 2003-01-18 Glynn Foster * help/C/zenity.xml: Only some examples and some screenshots and we're mostly done for a first draft. * src/calendar.c: Don't set the text if it's NULL. * src/main.c: Swap the order of the commandline dialogs so that we're alphabetical. * src/zenity.glade: Add some default strings. --- src/calendar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 65c2bf90..68956e76 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -64,7 +64,9 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); - gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); + + if (cal_data->dialog_text) + gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); -- 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/calendar.c | 126 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 64 insertions(+), 62 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 68956e76..fc1c014d 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -35,85 +35,87 @@ static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gp void zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { - GladeXML *glade_dialog = NULL; - GtkWidget *dialog; - GtkWidget *text; + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *text; - zen_cal_data = cal_data; + zen_cal_data = cal_data; - glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); + glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } - glade_xml_signal_autoconnect (glade_dialog); + glade_xml_signal_autoconnect (glade_dialog); - dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_calendar_dialog_response), data); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_calendar_dialog_response), data); - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + 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 - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); - text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); + text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); - if (cal_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); + if (cal_data->dialog_text) + gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); - calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); + calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); - if (glade_dialog) - g_object_unref (glade_dialog); + if (glade_dialog) + g_object_unref (glade_dialog); - if (cal_data->month > 0 && cal_data->year > 0) - gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); - if (cal_data->day > 0) - gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); + if (cal_data->month > 0 && cal_data->year > 0) + gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); + if (cal_data->day > 0) + gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); - gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); - gtk_widget_show (dialog); - gtk_main (); + gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); + gtk_widget_show (dialog); + gtk_main (); } static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data; - gint day, month, year; - gchar time_string[128]; - GDate *date = NULL; - - zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, - zen_cal_data->date_format, date); - g_printerr ("%s\n", time_string); - if (date != NULL) - g_date_free (date); - zen_data->exit_code = 0; - gtk_main_quit (); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; - gtk_main_quit (); - break; - - default: - /* Esc dialog */ - zen_data->exit_code = 1; - break; - } + ZenityData *zen_data; + gint day, month, year; + gchar time_string[128]; + GDate *date = NULL; + + zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); + date = g_date_new_dmy (year, month + 1, day); + g_date_strftime (time_string, 127, + zen_cal_data->date_format, date); + g_printerr ("%s\n", time_string); + + if (date != NULL) + g_date_free (date); + + zen_data->exit_code = 0; + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; + gtk_main_quit (); + break; + + default: + /* Esc dialog */ + 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/calendar.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index fc1c014d..1316d518 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -63,6 +63,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); if (cal_data->dialog_text) -- cgit From a7673b42d20f5cbacd61b4dd85408e54aafd135d Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 17:56:51 +0000 Subject: Fix an indentation weirdness in calendar.c Take notice of width and height in gdialog wrapper for textbox, because the original gdialog also did. --- src/calendar.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 1316d518..460ab8d5 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -99,8 +99,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) case GTK_RESPONSE_OK: gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, - zen_cal_data->date_format, date); + g_date_strftime (time_string, 127, zen_cal_data->date_format, date); g_printerr ("%s\n", time_string); if (date != NULL) -- 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/calendar.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 460ab8d5..e2d94ffd 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -44,7 +44,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -105,18 +105,18 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) if (date != NULL) g_date_free (date); - 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; default: /* Esc dialog */ - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } -- cgit From 652c90596e2c4fff6b7b748afcb01df6e21d22d9 Mon Sep 17 00:00:00 2001 From: "Kevin C. Krinke" Date: Sun, 13 Jul 2003 23:03:18 +0000 Subject: user input data output to STDOUT via g_print instead of outputting to 2003-07-11 Kevin C. Krinke * src/calendar.c, src/entry.c, src/fileselection.c, src/text.c, src/tree.c: user input data output to STDOUT via g_print instead of outputting to STDERR via g_printerr. This makes it possible to destinguish user input data from GTK+ warnings / errors. * THANKS, src/about.c: I figure this is my second patch submission so I belong in the credits... --- src/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index e2d94ffd..36b3fe4d 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -100,7 +100,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); date = g_date_new_dmy (year, month + 1, day); g_date_strftime (time_string, 127, zen_cal_data->date_format, date); - g_printerr ("%s\n", time_string); + g_print ("%s\n", time_string); if (date != NULL) g_date_free (date); -- 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/calendar.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 36b3fe4d..f5cbb33c 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -63,7 +63,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); - 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); text = glade_xml_get_widget (glade_dialog, "zenity_calendar_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/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index f5cbb33c..2d297786 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -82,7 +82,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); - gtk_widget_show (dialog); + 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/calendar.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 2d297786..5936aef2 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -107,17 +107,16 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) g_date_free (date); 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: /* Esc dialog */ 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/calendar.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 5936aef2..9da633e8 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -58,10 +58,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_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 - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); -- cgit From 516f9944095b4308a055eaca9a9220cfeb66b669 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 9 Jan 2005 20:04:30 +0000 Subject: Really fix #162297, and preload the current dates if they aren't already 2005-01-07 Glynn Foster * src/option.c, src/calendar.c: Really fix #162297, and preload the current dates if they aren't already set. --- src/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 9da633e8..8bffed8e 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -73,7 +73,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (glade_dialog) g_object_unref (glade_dialog); - if (cal_data->month > 0 && cal_data->year > 0) + if (cal_data->month > 0 || cal_data->year > 0) gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); if (cal_data->day > 0) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); -- 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/calendar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 8bffed8e..248f3b8d 100644 --- a/src/calendar.c +++ b/src/calendar.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/calendar.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 248f3b8d..7e9eb9ca 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -21,6 +21,8 @@ * Authors: Glynn Foster */ +#include "config.h" + #include #include #include "zenity.h" -- cgit From 21f7bc6a54636c749cf5514e091feb68cc88907b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 8 Jul 2005 23:21:34 +0000 Subject: general code cleanups. Contribution from Benoît Dejean. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2005-07-08 Lucas Rocha * src/about.c, src/calendar.c, src/fileselection.c, src/option.c, src/progress.c, src/text.c, src/tree.c, src/util.c: general code cleanups. Contribution from Benoît Dejean. --- src/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 7e9eb9ca..f876c038 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -89,7 +89,7 @@ static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data; - gint day, month, year; + guint day, month, year; gchar time_string[128]; GDate *date = NULL; -- cgit From 5547de9384430dfccb9c3c8a68badfa120760b4a Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 15 Nov 2005 04:14:35 +0000 Subject: make it possible to add new lines and markup in the dialog text. 2005-11-15 Lucas Rocha * src/calendar.c, src/progress.c, src/tree.c: make it possible to add new lines and markup in the dialog text. --- src/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index f876c038..fd0eb7b5 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -68,7 +68,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); if (cal_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); + gtk_label_set_markup (GTK_LABEL (text), g_strcompress (cal_data->dialog_text)); calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); -- cgit From f297dd91bd4e6a81d0b14562fccd615f2045bc48 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 14 May 2007 21:38:47 +0000 Subject: double-click on day results in dialog response (Fixes bug #395152). Patch 2007-05-15 Lucas Rocha * src/calendar.c (zenity_calendar, zenity_calendar_double_click): double-click on day results in dialog response (Fixes bug #395152). Patch from Tom Tromey . svn path=/trunk/; revision=1209 --- src/calendar.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index fd0eb7b5..9c50c5ab 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -33,6 +33,7 @@ static GtkWidget *calendar; static ZenityCalendarData *zen_cal_data; static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data); void zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) @@ -80,6 +81,9 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (cal_data->day > 0) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); + g_signal_connect (calendar, "day-selected-double-click", + G_CALLBACK (zenity_calendar_double_click), data); + gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); zenity_util_show_dialog (dialog); gtk_main (); @@ -119,3 +123,9 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) } gtk_main_quit (); } + +static void +zenity_calendar_double_click (GtkCalendar *cal, gpointer data) +{ + zenity_calendar_dialog_response (NULL, GTK_RESPONSE_OK, data); +} -- 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/calendar.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 9c50c5ab..e05950cb 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -86,6 +86,11 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); 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 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/calendar.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index e05950cb..8ad53ea6 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include #include "zenity.h" #include "util.h" @@ -38,22 +37,23 @@ static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data); void zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { - GladeXML *glade_dialog = NULL; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text; + GObject *text; zen_cal_data = cal_data; - glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); + builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_calendar_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_calendar_dialog_response), data); @@ -66,16 +66,13 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); + text = gtk_builder_get_object (builder, "zenity_calendar_text"); if (cal_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (cal_data->dialog_text)); - calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); + calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar")); - if (glade_dialog) - g_object_unref (glade_dialog); - if (cal_data->month > 0 || cal_data->year > 0) gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); if (cal_data->day > 0) @@ -91,6 +88,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); } + g_object_unref (builder); + gtk_main (); } -- 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/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 8ad53ea6..9aaee9f2 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -85,7 +85,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_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/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 9aaee9f2..60931c49 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -85,7 +85,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_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 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/calendar.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 60931c49..32825da9 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -112,8 +112,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) if (date != NULL) g_date_free (date); - - 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 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/calendar.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 32825da9..c62c1818 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -39,6 +39,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { GtkBuilder *builder; GtkWidget *dialog; + GtkWidget *button; GObject *text; zen_cal_data = cal_data; @@ -84,10 +85,24 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); zenity_util_show_dialog (dialog); - if(data->timeout_delay > 0) { + if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } + if (data->ok_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + + if (data->cancel_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_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 (builder); gtk_main (); -- 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/calendar.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index c62c1818..c0f7af13 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -67,6 +67,9 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_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); + text = gtk_builder_get_object (builder, "zenity_calendar_text"); if (cal_data->dialog_text) -- cgit From 1ac1da63f8de626ce10d350be7b29744a743ec95 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 5 Mar 2013 16:56:24 -0300 Subject: But #674881 - Timeout option overriding normal exit code --- src/calendar.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index c0f7af13..f2820014 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -110,33 +110,44 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) gtk_main (); } +static void +zenity_calendar_dialog_output (void) +{ + guint day, month, year; + gchar time_string[128]; + GDate *date = NULL; + + gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); + date = g_date_new_dmy (year, month + 1, day); + g_date_strftime (time_string, 127, zen_cal_data->date_format, date); + g_print ("%s\n", time_string); + + if (date != NULL) + g_date_free (date); +} static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data; - guint day, month, year; - gchar time_string[128]; - GDate *date = NULL; zen_data = data; switch (response) { case GTK_RESPONSE_OK: - gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, zen_cal_data->date_format, date); - g_print ("%s\n", time_string); - - if (date != NULL) - g_date_free (date); - zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + zenity_calendar_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zenity_calendar_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); -- 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/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index f2820014..e8967974 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -86,7 +86,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) G_CALLBACK (zenity_calendar_double_click), data); gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); - 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, 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/calendar.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index e8967974..0166c500 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -95,15 +95,11 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_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 (builder); -- 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/calendar.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index e8967974..8e2f6950 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -91,7 +91,15 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } - + + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); @@ -149,7 +157,8 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - /* Esc dialog */ + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } -- 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/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 0e6cb329..9f82cc63 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -153,7 +153,7 @@ zenity_calendar_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 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/calendar.c | 268 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 140 insertions(+), 128 deletions(-) (limited to 'src/calendar.c') diff --git a/src/calendar.c b/src/calendar.c index 9f82cc63..9aaf927f 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -23,146 +23,158 @@ #include "config.h" -#include -#include "zenity.h" #include "util.h" - +#include "zenity.h" +#include static GtkWidget *calendar; static ZenityCalendarData *zen_cal_data; -static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_calendar_dialog_response ( + GtkWidget *widget, int response, gpointer data); static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data); -void -zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) -{ - GtkBuilder *builder; - GtkWidget *dialog; - GtkWidget *button; - GObject *text; - - zen_cal_data = cal_data; - - builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL); - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - gtk_builder_connect_signals (builder, NULL); - - dialog = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_calendar_dialog")); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_calendar_dialog_response), data); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); - - 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); - - text = gtk_builder_get_object (builder, "zenity_calendar_text"); - - if (cal_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), g_strcompress (cal_data->dialog_text)); - - calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar")); - - if (cal_data->month > 0 || cal_data->year > 0) - gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); - if (cal_data->day > 0) - gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); - - g_signal_connect (calendar, "day-selected-double-click", - G_CALLBACK (zenity_calendar_double_click), data); - - gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); - 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); - } - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button")); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - } - - if (data->cancel_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_button")); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - } - - g_object_unref (builder); - - gtk_main (); +void +zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { + GtkBuilder *builder; + GtkWidget *dialog; + GtkWidget *button; + GObject *text; + + zen_cal_data = cal_data; + + builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals (builder, NULL); + + dialog = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_dialog")); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_calendar_dialog_response), + data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + zenity_util_set_window_icon (dialog, + data->window_icon, + ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + + 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); + + text = gtk_builder_get_object (builder, "zenity_calendar_text"); + + if (cal_data->dialog_text) + gtk_label_set_markup ( + GTK_LABEL (text), g_strcompress (cal_data->dialog_text)); + + calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar")); + + if (cal_data->month > 0 || cal_data->year > 0) + gtk_calendar_select_month ( + GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); + if (cal_data->day > 0) + gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); + + g_signal_connect (calendar, + "day-selected-double-click", + G_CALLBACK (zenity_calendar_double_click), + data); + + gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); + 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); + } + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_calendar_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + } + + if (data->cancel_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_calendar_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + } + + g_object_unref (builder); + + gtk_main (); } -static void -zenity_calendar_dialog_output (void) -{ - guint day, month, year; - gchar time_string[128]; - GDate *date = NULL; - - gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, zen_cal_data->date_format, date); - g_print ("%s\n", time_string); - - if (date != NULL) - g_date_free (date); +static void +zenity_calendar_dialog_output (void) { + guint day, month, year; + gchar time_string[128]; + GDate *date = NULL; + + gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); + date = g_date_new_dmy (year, month + 1, day); + g_date_strftime (time_string, 127, zen_cal_data->date_format, date); + g_print ("%s\n", time_string); + + if (date != NULL) + g_date_free (date); } static void -zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data; - - zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_calendar_dialog_output (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - case ZENITY_TIMEOUT: - zenity_calendar_dialog_output (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - 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_calendar_dialog_response ( + GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data; + + zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_calendar_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + case ZENITY_TIMEOUT: + zenity_calendar_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + 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 (); } static void -zenity_calendar_double_click (GtkCalendar *cal, gpointer data) -{ - zenity_calendar_dialog_response (NULL, GTK_RESPONSE_OK, data); +zenity_calendar_double_click (GtkCalendar *cal, gpointer data) { + zenity_calendar_dialog_response (NULL, GTK_RESPONSE_OK, data); } -- cgit