From 6a65d75921d352323277f770f357ca3065436133 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Jan 2003 13:22:57 +0000 Subject: Fix up the response signal handlers. Use returns of 0 for 'Ok' and 2003-01-07 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c, src/zenity.glade, src/zenity.h: Fix up the response signal handlers. Use returns of 0 for 'Ok' and 'Close', 1 for 'Cancel' and 'Escape' and -1 for 'Uh Oh'. Get stuff printing to stderr. Fix up the error handling that I thought was improved, although still have issues with popt callback getting called numerous times because of more than one instance of the same kind is being used in poptOption. * TODO: Update accordingly. --- src/progress.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'src/progress.c') diff --git a/src/progress.c b/src/progress.c index a890059..349072a 100644 --- a/src/progress.c +++ b/src/progress.c @@ -32,7 +32,7 @@ static GladeXML *glade_dialog; static gboolean zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data); static gboolean zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data); -void zenity_progress_dialog_response (GtkWindow *window, int button, gpointer data); +static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data); gint zenity_progress_timeout (gpointer data) @@ -41,7 +41,8 @@ zenity_progress_timeout (gpointer data) return TRUE; } -int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) +void +zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { GtkWidget *dialog; GtkWidget *text; @@ -51,12 +52,17 @@ int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog"); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_progress_dialog_response), data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -72,6 +78,9 @@ int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); + if (glade_dialog) + g_object_unref (glade_dialog); + giochannel = g_io_channel_unix_new (0); if (progress_data->pulsate != TRUE && progress_data->percentage > -1) { @@ -85,11 +94,6 @@ int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) g_io_channel_unref (giochannel); gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } static gboolean @@ -119,21 +123,24 @@ zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, g /* FIXME: Do nothing at the moment */ } -void -zenity_progress_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; - switch (button) { + switch (response) { case GTK_RESPONSE_OK: + zen_data->exit_code = 0; gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; gtk_main_quit (); break; default: + zen_data->exit_code = 1; break; } } -- cgit v1.2.3-54-g00ecf