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)
|
if (date != NULL)
|
||||||
g_date_free (date);
|
g_date_free (date);
|
||||||
|
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
|
@ -78,7 +78,7 @@ zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer
|
|||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
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));
|
colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (widget));
|
||||||
gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color);
|
gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color);
|
||||||
g_print ("%s\n", gdk_color_to_string (&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) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
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) {
|
if (n_entries > 1) {
|
||||||
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry));
|
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) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
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));
|
selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget));
|
||||||
for (iter = selections;iter != NULL; iter = iter->next) {
|
for (iter = selections;iter != NULL; iter = iter->next) {
|
||||||
g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL));
|
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) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
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) {
|
for (tmp = forms_data->list; tmp; tmp = tmp->next) {
|
||||||
ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data;
|
ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data;
|
||||||
switch (zenity_value->type) {
|
switch (zenity_value->type) {
|
||||||
|
@ -153,7 +153,7 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data)
|
|||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
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;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
|
@ -154,7 +154,7 @@ zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data)
|
|||||||
ZenityPasswordData *password_data = (ZenityPasswordData *) data;
|
ZenityPasswordData *password_data = (ZenityPasswordData *) data;
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
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)
|
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)));
|
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
|
else
|
||||||
|
@ -297,7 +297,7 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data)
|
|||||||
{
|
{
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
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;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
|
@ -113,7 +113,7 @@ zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data)
|
|||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
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)));
|
g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
/* Esc dialog */
|
/* Esc dialog */
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
zenity_util_exit_code_with_data(ZENITY_ESC, zen_data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
|
@ -613,7 +613,7 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
|
|||||||
GTK_TREE_VIEW (tree_view));
|
GTK_TREE_VIEW (tree_view));
|
||||||
}
|
}
|
||||||
zenity_tree_dialog_output ();
|
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;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
|
17
src/util.c
17
src/util.c
@ -305,6 +305,14 @@ zenity_util_return_exit_code ( ZenityExitCode value )
|
|||||||
retval = ZENITY_ERROR_DEFAULT;
|
retval = ZENITY_ERROR_DEFAULT;
|
||||||
break;
|
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:
|
default:
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
@ -314,6 +322,15 @@ zenity_util_return_exit_code ( ZenityExitCode value )
|
|||||||
return retval;
|
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
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ GdkPixbuf * zenity_util_pixbuf_new_from_file (GtkWidget *widget,
|
|||||||
const gchar *filename);
|
const gchar *filename);
|
||||||
void zenity_util_show_help (GError **error);
|
void zenity_util_show_help (GError **error);
|
||||||
gint zenity_util_return_exit_code (ZenityExitCode value);
|
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);
|
void zenity_util_show_dialog (GtkWidget *widget);
|
||||||
|
|
||||||
gboolean zenity_util_timeout_handle (gpointer data);
|
gboolean zenity_util_timeout_handle (gpointer data);
|
||||||
|
Reference in New Issue
Block a user