summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--src/calendar.c5
-rw-r--r--src/entry.c4
-rw-r--r--src/fileselection.c5
-rw-r--r--src/msg.c5
-rw-r--r--src/notification.c5
-rw-r--r--src/option.c13
-rw-r--r--src/progress.c4
-rw-r--r--src/scale.c5
-rw-r--r--src/text.c4
-rw-r--r--src/tree.c5
-rw-r--r--src/util.c9
-rw-r--r--src/util.h4
-rw-r--r--src/zenity.h4
14 files changed, 74 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index cd2e28c6..7281de42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 ();
}
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 ();
}
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 ();
}
diff --git a/src/text.c b/src/text.c
index a8da744a..bdd8e0c8 100644
--- a/src/text.c
+++ b/src/text.c
@@ -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 ();
}
diff --git a/src/tree.c b/src/tree.c
index 254ac0e7..6dd3f645 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -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)
diff --git a/src/util.c b/src/util.c
index 41c7c556..267332cd 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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;
+}
diff --git a/src/util.h b/src/util.h
index 7535275b..4815da2a 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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 {
bgstack15