diff options
-rw-r--r-- | src/calendar.c | 3 | ||||
-rw-r--r-- | src/color.c | 2 | ||||
-rw-r--r-- | src/entry.c | 2 | ||||
-rw-r--r-- | src/fileselection.c | 2 | ||||
-rw-r--r-- | src/forms.c | 2 | ||||
-rw-r--r-- | src/msg.c | 2 | ||||
-rw-r--r-- | src/password.c | 2 | ||||
-rw-r--r-- | src/progress.c | 2 | ||||
-rw-r--r-- | src/scale.c | 2 | ||||
-rw-r--r-- | src/text.c | 2 | ||||
-rw-r--r-- | src/tree.c | 2 | ||||
-rw-r--r-- | src/util.c | 19 | ||||
-rw-r--r-- | src/util.h | 2 |
13 files changed, 31 insertions, 13 deletions
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: diff --git a/src/color.c b/src/color.c index eee68ee7..ca8debde 100644 --- a/src/color.c +++ b/src/color.c @@ -78,7 +78,7 @@ zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer 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); colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (widget)); gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color); g_print ("%s\n", gdk_color_to_string (&color)); diff --git a/src/entry.c b/src/entry.c index ce6cda50..d8111c04 100644 --- a/src/entry.c +++ b/src/entry.c @@ -143,7 +143,7 @@ zenity_entry_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); if (n_entries > 1) { text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); } diff --git a/src/fileselection.c b/src/fileselection.c index 07d85c0d..349ff32d 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -150,7 +150,7 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer 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); selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); for (iter = selections;iter != NULL; iter = iter->next) { g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); diff --git a/src/forms.c b/src/forms.c index d6db7787..d59a5afb 100644 --- a/src/forms.c +++ b/src/forms.c @@ -181,7 +181,7 @@ zenity_forms_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); for (tmp = forms_data->list; tmp; tmp = tmp->next) { ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; switch (zenity_value->type) { @@ -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: diff --git a/src/password.c b/src/password.c index 219f5f9c..c49b6752 100644 --- a/src/password.c +++ b/src/password.c @@ -154,7 +154,7 @@ zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data) ZenityPasswordData *password_data = (ZenityPasswordData *) 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); if (password_data->username) g_print("%s|%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_username)), gtk_entry_get_text (GTK_ENTRY(password_data->entry_password))); else diff --git a/src/progress.c b/src/progress.c index 2533aa1c..6dc93f87 100644 --- a/src/progress.c +++ b/src/progress.c @@ -297,7 +297,7 @@ zenity_progress_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: diff --git a/src/scale.c b/src/scale.c index d6cc340b..87bf55ae 100644 --- a/src/scale.c +++ b/src/scale.c @@ -113,7 +113,7 @@ zenity_scale_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); g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale))); break; @@ -187,7 +187,7 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) default: /* Esc dialog */ - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + zenity_util_exit_code_with_data(ZENITY_ESC, zen_data); break; } gtk_main_quit (); @@ -613,7 +613,7 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) GTK_TREE_VIEW (tree_view)); } zenity_tree_dialog_output (); - 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: @@ -304,7 +304,15 @@ zenity_util_return_exit_code ( ZenityExitCode value ) if (! env_var) retval = ZENITY_ERROR_DEFAULT; break; - + + case ZENITY_TIMEOUT: + env_var = g_getenv("ZENITY_TIMEOUT"); + if (! env_var) + env_var = g_getenv("DIALOG_TIMEOUT"); + if (! env_var) + retval = ZENITY_TIMEOUT; + break; + default: retval = 1; } @@ -314,6 +322,15 @@ zenity_util_return_exit_code ( ZenityExitCode value ) return retval; } +void +zenity_util_exit_code_with_data(ZenityExitCode value, ZenityData *zen_data) +{ + /* We assume it's being called with --timeout option and should return 5) */ + if(zen_data->timeout_delay > 0) + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + else + zen_data->exit_code = zenity_util_return_exit_code (value); +} #ifdef GDK_WINDOWING_X11 @@ -26,6 +26,8 @@ GdkPixbuf * zenity_util_pixbuf_new_from_file (GtkWidget *widget, const gchar *filename); void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); +void zenity_util_exit_code_with_data (ZenityExitCode value, + ZenityData *data); void zenity_util_show_dialog (GtkWidget *widget); gboolean zenity_util_timeout_handle (gpointer data); |