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
This commit is contained in:
parent
f77a0199af
commit
d60e5eeeb3
@ -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:
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
19
src/util.c
19
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
|
||||
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user