summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArx Cruz <arxcruz@src.gnome.org>2011-06-17 10:47:07 -0300
committerArx Cruz <arxcruz@src.gnome.org>2011-06-17 10:51:00 -0300
commitd60e5eeeb379e5444ad218d7335b17eaa821b182 (patch)
tree8a593fdb55754ad668dbac29ef342e384303e1fd
parentFix the msg forms (question, warning, error) to return 5 when timeout (diff)
downloadzenity-d60e5eeeb379e5444ad218d7335b17eaa821b182.tar.gz
zenity-d60e5eeeb379e5444ad218d7335b17eaa821b182.tar.bz2
zenity-d60e5eeeb379e5444ad218d7335b17eaa821b182.zip
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
-rw-r--r--src/calendar.c3
-rw-r--r--src/color.c2
-rw-r--r--src/entry.c2
-rw-r--r--src/fileselection.c2
-rw-r--r--src/forms.c2
-rw-r--r--src/msg.c2
-rw-r--r--src/password.c2
-rw-r--r--src/progress.c2
-rw-r--r--src/scale.c2
-rw-r--r--src/text.c2
-rw-r--r--src/tree.c2
-rw-r--r--src/util.c19
-rw-r--r--src/util.h2
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) {
diff --git a/src/msg.c b/src/msg.c
index 1a92875b..1f060c5a 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -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;
diff --git a/src/text.c b/src/text.c
index 147e7066..98686750 100644
--- a/src/text.c
+++ b/src/text.c
@@ -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 ();
diff --git a/src/tree.c b/src/tree.c
index c7477c36..b0ff4c5f 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -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:
diff --git a/src/util.c b/src/util.c
index 37845a0b..440c7de9 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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
diff --git a/src/util.h b/src/util.h
index 7005441b..48409c11 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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);
bgstack15