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/fileselection.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 52c0021a..74122f87 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -25,21 +25,30 @@ #include "zenity.h" #include "util.h" -void zenity_fileselection_dialog_response (GtkWindow *window, int button, gpointer data); +static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data); -int zenity_fileselection (ZenityData *data, ZenityFileData *file_data) +void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { GladeXML *glade_dialog; GtkWidget *dialog; glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_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_fileselection_dialog"); + + if (glade_dialog) + g_object_unref (glade_dialog); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_fileselection_dialog_response), data); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -53,28 +62,27 @@ int zenity_fileselection (ZenityData *data, ZenityFileData *file_data) gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } -void -zenity_fileselection_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_fileselection_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; + g_printerr ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget))); 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