diff options
author | Logan Rathbone <poprocks@gmail.com> | 2023-02-04 07:51:04 -0500 |
---|---|---|
committer | Logan Rathbone <poprocks@gmail.com> | 2023-02-04 08:46:56 -0500 |
commit | bab82948507dacfff804e11e376b00d7a5e12f04 (patch) | |
tree | 267123dd38789d2f7552baad89370abc7ff4aecd | |
parent | Update Ukrainian translation (diff) | |
download | zenity-bab82948507dacfff804e11e376b00d7a5e12f04.tar.gz zenity-bab82948507dacfff804e11e376b00d7a5e12f04.tar.bz2 zenity-bab82948507dacfff804e11e376b00d7a5e12f04.zip |
Prevent ZENITY_TIMEOUT from clashing with custom response IDs
Redefine ZENITY_TIMEOUT response ID as INT_MAX
Also, add and use ZENITY_TIMEOUT_DEFAULT exit status (hardcoded to 5 to
keep consistent with what it has happened to be for the entire 3.x
release cycle; POLA and all).
See #48
-rw-r--r-- | src/util.c | 12 | ||||
-rw-r--r-- | src/zenity.h | 9 |
2 files changed, 18 insertions, 3 deletions
@@ -49,6 +49,14 @@ #define ZENITY_ERROR_DEFAULT -1 #define ZENITY_EXTRA_DEFAULT 127 +/* This exit code number is arbitrary, but since for the entire 3.x release + * cycle, zenity would essentially exit(ZENITY_TIMEOUT), which happened to be + * defined as 5 based on where it was placed in the enum sequence. So + * hardcoding it as 5 now in case any pre-existing scripts relied upon that + * being the exit status for timeouts. + */ +#define ZENITY_TIMEOUT_DEFAULT 5 + GtkBuilder * zenity_util_load_ui_file (const gchar *root_widget, ...) { va_list args; @@ -298,7 +306,7 @@ zenity_util_return_exit_code (ZenityExitCode value) { if (!env_var) env_var = g_getenv ("DIALOG_TIMEOUT"); if (!env_var) - retval = ZENITY_TIMEOUT; + retval = ZENITY_TIMEOUT_DEFAULT; break; default: @@ -412,7 +420,7 @@ zenity_util_timeout_handle (gpointer data) { gtk_dialog_response (dialog, ZENITY_TIMEOUT); else { gtk_main_quit (); - exit (ZENITY_TIMEOUT); + exit (ZENITY_TIMEOUT_DEFAULT); } return FALSE; } diff --git a/src/zenity.h b/src/zenity.h index 404eec77..c50a76bd 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -33,7 +33,14 @@ typedef enum { ZENITY_ESC, ZENITY_ERROR, ZENITY_EXTRA, - ZENITY_TIMEOUT + /* Previously, this was not specified to any value, which could cause it to + * clash with the custom response ID that happened to match it. We could set + * this to a negative value tha doesn't clash with one of GtkDialog's + * predefined response ID's as it's doubtful GTK will ever extend the GtkDialog + * API at this stage -- but technically negative values are reserved for the + * library and positive values for applications, according to gtkdialog.c + */ + ZENITY_TIMEOUT = INT_MAX } ZenityExitCode; typedef struct { |