diff options
author | Lucas Rocha <lucasr@gnome.org> | 2007-08-13 20:36:29 +0000 |
---|---|---|
committer | Lucas Almeida Rocha <lucasr@src.gnome.org> | 2007-08-13 20:36:29 +0000 |
commit | 8b16d4d4122e6337517ec16b9ca22dd27df0dafb (patch) | |
tree | 4b37fe6193f44fef74d114e8c7eeeef7ab82ac4d | |
parent | fix critical warning when using checkbox and radiobox in list dialog (diff) | |
download | zenity-8b16d4d4122e6337517ec16b9ca22dd27df0dafb.tar.gz zenity-8b16d4d4122e6337517ec16b9ca22dd27df0dafb.tar.bz2 zenity-8b16d4d4122e6337517ec16b9ca22dd27df0dafb.zip |
added timeout option to all dialogs (Fixes bug #160654). Based on patch
2007-08-13 Lucas Rocha <lucasr@gnome.org>
* src/*.c: added timeout option to all dialogs (Fixes bug #160654).
Based on patch from Muthiah Annamalai <gnumuthu@users.sf.net>.
svn path=/trunk/; revision=1231
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/calendar.c | 5 | ||||
-rw-r--r-- | src/entry.c | 4 | ||||
-rw-r--r-- | src/fileselection.c | 5 | ||||
-rw-r--r-- | src/msg.c | 5 | ||||
-rw-r--r-- | src/notification.c | 5 | ||||
-rw-r--r-- | src/option.c | 13 | ||||
-rw-r--r-- | src/progress.c | 4 | ||||
-rw-r--r-- | src/scale.c | 5 | ||||
-rw-r--r-- | src/text.c | 4 | ||||
-rw-r--r-- | src/tree.c | 5 | ||||
-rw-r--r-- | src/util.c | 9 | ||||
-rw-r--r-- | src/util.h | 4 | ||||
-rw-r--r-- | src/zenity.h | 4 |
14 files changed, 74 insertions, 3 deletions
@@ -1,5 +1,10 @@ 2007-08-13 Lucas Rocha <lucasr@gnome.org> + * src/*.c: added timeout option to all dialogs (Fixes bug #160654). + Based on patch from Muthiah Annamalai <gnumuthu@users.sf.net>. + +2007-08-13 Lucas Rocha <lucasr@gnome.org> + * src/tree.c: fix critical warning when using checkbox and radiobox in list dialog (Fixes bug #453713). 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 (); } diff --git a/src/entry.c b/src/entry.c index 390d9b6b..dcd09854 100644 --- a/src/entry.c +++ b/src/entry.c @@ -120,6 +120,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) 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 (); } diff --git a/src/fileselection.c b/src/fileselection.c index 3f355bab..c91c816a 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -86,6 +86,11 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); 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 (); } @@ -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 (); } diff --git a/src/notification.c b/src/notification.c index b5cdd406..b2ab18fe 100644 --- a/src/notification.c +++ b/src/notification.c @@ -280,6 +280,11 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data /* Show icon and wait */ gtk_status_icon_set_visible (status_icon, TRUE); + + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); /* Cleanup */ diff --git a/src/option.c b/src/option.c index 25a74402..cbb50816 100644 --- a/src/option.c +++ b/src/option.c @@ -40,6 +40,7 @@ static gboolean zenity_general_multiple; static gboolean zenity_general_editable; static gchar *zenity_general_uri; static gboolean zenity_general_dialog_no_wrap; +static guint zenity_general_timeout_delay; /* Calendar Dialog Options */ static gboolean zenity_calendar_active; @@ -144,6 +145,15 @@ static GOptionEntry general_options[] = { N_("HEIGHT") }, { + "timeout", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_general_timeout_delay, + N_("Set dialog timeout in seconds"), + NULL + }, + { NULL } }; @@ -879,6 +889,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_editable = FALSE; zenity_general_uri = NULL; zenity_general_dialog_no_wrap = FALSE; + zenity_general_timeout_delay = -1; return TRUE; } @@ -1065,7 +1076,7 @@ zenity_general_post_callback (GOptionContext *context, results->data->window_icon = zenity_general_window_icon; results->data->width = zenity_general_width; results->data->height = zenity_general_height; - + results->data->timeout_delay=zenity_general_timeout_delay; return TRUE; } diff --git a/src/progress.c b/src/progress.c index b8ac1fc8..ffd87072 100644 --- a/src/progress.c +++ b/src/progress.c @@ -219,6 +219,10 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) zenity_util_show_dialog (dialog); zenity_progress_read_info (progress_data); + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } diff --git a/src/scale.c b/src/scale.c index cacb083a..91b0ef5f 100644 --- a/src/scale.c +++ b/src/scale.c @@ -93,6 +93,11 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) gtk_scale_set_draw_value (GTK_SCALE (scale), 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 (); } @@ -152,6 +152,10 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (glade_dialog) g_object_unref (glade_dialog); + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } @@ -493,6 +493,11 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) } 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 (); if (glade_dialog) @@ -350,6 +350,7 @@ transient_get_xterm_toplevel (void) static void zenity_util_make_transient (GdkWindow *window) { +#if 0 Window xterm = transient_get_xterm_toplevel (); if (xterm != None) { GdkWindow *gdkxterm = gdk_window_foreign_new (xterm); @@ -358,6 +359,7 @@ zenity_util_make_transient (GdkWindow *window) g_object_unref (G_OBJECT (gdkxterm)); } } +#endif } #endif /* GDK_WINDOWING_X11 */ @@ -373,3 +375,10 @@ zenity_util_show_dialog (GtkWidget *dialog) gtk_widget_show (dialog); } +gboolean +zenity_util_timeout_handle (void) +{ + gtk_main_quit(); + exit(ZENITY_TIMEOUT); + return FALSE; +} @@ -27,7 +27,9 @@ GdkPixbuf * zenity_util_pixbuf_new_from_file (GtkWidget *widget, void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); void zenity_util_show_dialog (GtkWidget *widget); - + +gboolean zenity_util_timeout_handle (void); + G_END_DECLS #endif /* UTIL_H */ diff --git a/src/zenity.h b/src/zenity.h index 330d317d..ac6c4f8e 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -29,6 +29,7 @@ typedef struct { gint width; gint height; gint exit_code; + guint timeout_delay; } ZenityData; typedef enum { @@ -36,7 +37,8 @@ typedef enum { ZENITY_CANCEL, ZENITY_ESC, ZENITY_ERROR, - ZENITY_EXTRA + ZENITY_EXTRA, + ZENITY_TIMEOUT } ZenityExitCode; typedef struct { |