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
This commit is contained in:
Lucas Rocha 2007-08-13 20:36:29 +00:00 committed by Lucas Almeida Rocha
parent ae3e8d1496
commit 8b16d4d412
14 changed files with 74 additions and 3 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -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 ();
}

View File

@ -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 ();
}

View File

@ -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 ();
}

View File

@ -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 ();
}

View File

@ -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 */

View File

@ -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;
@ -143,6 +144,15 @@ static GOptionEntry general_options[] = {
N_("Set the height"),
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;
}

View File

@ -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 ();
}

View File

@ -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 ();
}

View File

@ -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 ();
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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 */

View File

@ -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 {