summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlynn Foster <glynn.foster@sun.com>2003-01-07 13:22:57 +0000
committerGlynn Foster <gman@src.gnome.org>2003-01-07 13:22:57 +0000
commit6a65d75921d352323277f770f357ca3065436133 (patch)
tree46f760232c30486ecaff09686e0006f83f9a1eca
parentFix up the error returns. (diff)
downloadzenity-6a65d75921d352323277f770f357ca3065436133.tar.gz
zenity-6a65d75921d352323277f770f357ca3065436133.tar.bz2
zenity-6a65d75921d352323277f770f357ca3065436133.zip
Fix up the response signal handlers. Use returns of 0 for 'Ok' and
2003-01-07 Glynn Foster <glynn.foster@sun.com> * 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.
-rw-r--r--ChangeLog15
-rw-r--r--TODO1
-rw-r--r--src/calendar.c44
-rw-r--r--src/entry.c39
-rw-r--r--src/fileselection.c34
-rw-r--r--src/main.c55
-rw-r--r--src/msg.c33
-rw-r--r--src/progress.c33
-rw-r--r--src/text.c32
-rw-r--r--src/tree.c26
-rw-r--r--src/zenity.glade10
-rw-r--r--src/zenity.h15
12 files changed, 189 insertions, 148 deletions
diff --git a/ChangeLog b/ChangeLog
index dac305ca..25c88af2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2003-01-07 Glynn Foster <glynn.foster@sun.com>
+ * 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.
+
+2003-01-07 Glynn Foster <glynn.foster@sun.com>
+
* src/main.c: Fix up the error returns.
* TODO: Update accordingly.
diff --git a/TODO b/TODO
index 005779b5..4c1070ea 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,6 @@
* Finish off support for progress dialog
* Implement return values for all dialogs
+ * All done, except for list view
* Add some accessibility I guess
* Find some nice default window icons
* Implement about box
diff --git a/src/calendar.c b/src/calendar.c
index 0264ce17..df5d35c1 100644
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -25,23 +25,32 @@
#include "zenity.h"
#include "util.h"
-void zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data);
-int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
+static GtkWidget *calendar;
+
+static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data);
+
+void
+zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
{
GladeXML *glade_dialog = NULL;
GtkWidget *dialog;
- GtkWidget *calendar;
GtkWidget *text;
glade_dialog = zenity_util_load_glade_file ("zenity_calendar_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_calendar_dialog");
+
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (zenity_calendar_dialog_response), data);
+
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
@@ -55,36 +64,41 @@ int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar");
+ if (glade_dialog)
+ g_object_unref (glade_dialog);
+
if (cal_data->month > 0 && cal_data->year > 0)
- gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month, cal_data->year);
+ gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year);
if (cal_data->day > 0)
gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day);
gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar);
gtk_widget_show (dialog);
gtk_main ();
-
- if (glade_dialog)
- g_object_unref (glade_dialog);
-
- return TRUE;
}
-void
-zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data)
+static void
+zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data)
{
- GError *error = NULL;
+ ZenityData *zen_data = data;
+ guint day, month, year;
- switch (button) {
+ switch (response) {
case GTK_RESPONSE_OK:
+ gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year);
+ g_printerr ("%02d/%02d/%02d\n", day, month + 1, year);
+ zen_data->exit_code = 0;
gtk_main_quit ();
break;
case GTK_RESPONSE_CANCEL:
+ zen_data->exit_code = 1;
gtk_main_quit ();
break;
default:
+ /* Esc dialog */
+ zen_data->exit_code = 1;
break;
}
}
diff --git a/src/entry.c b/src/entry.c
index 3816a502..81fc2c5e 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -25,23 +25,31 @@
#include "zenity.h"
#include "util.h"
-void zenity_entry_dialog_response (GtkWindow *window, int button, gpointer data);
+static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data);
-int zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
+static GtkWidget *entry;
+
+void
+zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
{
GladeXML *glade_dialog = NULL;
GtkWidget *dialog;
GtkWidget *text;
- GtkWidget *entry;
glade_dialog = zenity_util_load_glade_file ("zenity_entry_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_entry_dialog");
+
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (zenity_entry_dialog_response), data);
+
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
@@ -57,6 +65,9 @@ int zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input");
+ if (glade_dialog)
+ g_object_unref (glade_dialog);
+
if (entry_data->entry_text)
gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text);
@@ -67,28 +78,28 @@ int zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
gtk_widget_show (dialog);
gtk_main ();
-
- if (glade_dialog)
- g_object_unref (glade_dialog);
-
- return TRUE;
}
-void
-zenity_entry_dialog_response (GtkWindow *window, int button, gpointer data)
+static void
+zenity_entry_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_entry_get_text (GTK_ENTRY (entry)));
gtk_main_quit ();
break;
case GTK_RESPONSE_CANCEL:
+ zen_data->exit_code = 1;
gtk_main_quit ();
break;
default:
+ /* Esc dialog */
+ zen_data->exit_code = 1;
break;
}
}
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;
}
}
diff --git a/src/main.c b/src/main.c
index dc341c42..f60eb7f0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -694,6 +694,7 @@ zenity_init_parsing_options (void) {
results->calendar_data->day = 0;
results->calendar_data->month = 0;
results->calendar_data->year = 0;
+ results->calendar_data->dialog_text = NULL;
results->progress_data->percentage = -1;
results->entry_data->visible = TRUE;
results->tree_data->checkbox = FALSE;
@@ -750,8 +751,8 @@ main (gint argc, gchar **argv) {
ZenityData *general;
ZenityCalendarData *cal_data;
poptContext ctx;
- char **args;
- int nextopt, retval;
+ gchar **args;
+ gint nextopt, retval;
bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
@@ -787,29 +788,29 @@ main (gint argc, gchar **argv) {
switch (results->mode) {
case MODE_CALENDAR:
- retval = zenity_calendar (results->data, results->calendar_data);
+ zenity_calendar (results->data, results->calendar_data);
break;
case MODE_ENTRY:
- retval = zenity_entry (results->data, results->entry_data);
+ zenity_entry (results->data, results->entry_data);
break;
case MODE_ERROR:
case MODE_QUESTION:
case MODE_WARNING:
case MODE_INFO:
- retval = zenity_msg (results->data, results->msg_data);
+ zenity_msg (results->data, results->msg_data);
break;
case MODE_FILE:
- retval = zenity_fileselection (results->data, results->file_data);
+ zenity_fileselection (results->data, results->file_data);
break;
case MODE_LIST:
results->tree_data->data = poptGetArgs (ctx);
- retval = zenity_tree (results->data, results->tree_data);
+ zenity_tree (results->data, results->tree_data);
break;
case MODE_PROGRESS:
- retval = zenity_progress (results->data, results->progress_data);
+ zenity_progress (results->data, results->progress_data);
break;
case MODE_TEXTINFO:
- retval = zenity_text (results->data, results->text_data);
+ zenity_text (results->data, results->text_data);
break;
default:
g_assert_not_reached ();
@@ -817,9 +818,10 @@ main (gint argc, gchar **argv) {
exit (-1);
}
+ retval = results->data->exit_code;
poptFreeContext(ctx);
zenity_free_parsing_options ();
- exit (0);
+ exit (retval);
}
static
@@ -945,38 +947,18 @@ void zenity_parse_options_callback (poptContext ctx,
case OPTION_WARNINGTEXT:
switch (results->mode) {
case MODE_CALENDAR:
- if (results->calendar_data->dialog_text != NULL) {
- g_printerr (_("--text given twice for the same dialog\n"));
- zenity_free_parsing_options ();
- exit (-1);
- }
results->calendar_data->dialog_text = g_strdup (arg);
break;
case MODE_ENTRY:
- if (results->entry_data->dialog_text != NULL) {
- g_printerr (_("--text given twice for the same dialog\n"));
- zenity_free_parsing_options ();
- exit (-1);
- }
results->entry_data->dialog_text = g_strdup (arg);
break;
case MODE_ERROR:
case MODE_QUESTION:
case MODE_WARNING:
case MODE_INFO:
- if (results->msg_data->dialog_text != NULL) {
- g_printerr (_("--text given twice for the same dialog\n"));
- zenity_free_parsing_options ();
- exit (-1);
- }
results->msg_data->dialog_text = g_strdup (arg);
break;
case MODE_PROGRESS:
- if (results->progress_data->dialog_text != NULL) {
- g_printerr (_("--text given twice for the same dialog\n"));
- zenity_free_parsing_options ();
- exit (-1);
- }
results->progress_data->dialog_text = g_strdup (arg);
break;
default:
@@ -1054,19 +1036,9 @@ void zenity_parse_options_callback (poptContext ctx,
case OPTION_TEXTFILE:
switch (results->mode) {
case MODE_FILE:
- if (results->file_data->uri != NULL) {
- g_printerr (_("--filename given twice for the same dialog\n"));
- zenity_free_parsing_options ();
- exit (-1);
- }
results->file_data->uri = g_strdup (arg);
break;
case MODE_TEXTINFO:
- if (results->text_data->uri != NULL) {
- g_printerr (_("--filename given twice for the same dialog\n"));
- zenity_free_parsing_options ();
- exit (-1);
- }
results->text_data->uri = g_strdup (arg);
break;
default:
@@ -1128,6 +1100,8 @@ void zenity_parse_options_callback (poptContext ctx,
zenity_free_parsing_options ();
exit (-1);
}
+ g_print ("This does nothing at the moment\n");
+ exit (0);
break;
case OPTION_VERSION:
if (results->mode != MODE_LAST) {
@@ -1136,6 +1110,7 @@ void zenity_parse_options_callback (poptContext ctx,
exit (-1);
}
g_print ("%s\n", VERSION);
+ exit (0);
break;
default:
g_warning ("Invalid option %s", arg);
diff --git a/src/msg.c b/src/msg.c
index 5b2cba96..bb7190fc 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -25,9 +25,10 @@
#include "zenity.h"
#include "util.h"
-void zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data);
+static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data);
-int zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
+void
+zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
{
GladeXML *glade_dialog;
GtkWidget *dialog;
@@ -64,8 +65,16 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
break;
}
- if (glade_dialog == NULL)
- return FALSE;
+ if (glade_dialog)
+ g_object_unref (glade_dialog);
+
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (zenity_msg_dialog_response), data);
+
+ if (glade_dialog == NULL) {
+ data->exit_code = -1;
+ return;
+ }
glade_xml_signal_autoconnect (glade_dialog);
@@ -99,28 +108,26 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
gtk_widget_show (dialog);
gtk_main ();
-
- if (glade_dialog)
- g_object_unref (glade_dialog);
-
- return TRUE;
}
-void
-zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data)
+static void
+zenity_msg_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;
}
}
diff --git a/src/progress.c b/src/progress.c
index a890059b..349072a3 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;
}
}
diff --git a/src/text.c b/src/text.c
index 0d2dbe11..ead35ec2 100644
--- a/src/text.c
+++ b/src/text.c
@@ -25,9 +25,10 @@
#include "zenity.h"
#include "util.h"
-void zenity_text_dialog_response (GtkWindow *window, int button, gpointer data);
+static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data);
-int zenity_text (ZenityData *data, ZenityTextData *text_data)
+void
+zenity_text (ZenityData *data, ZenityTextData *text_data)
{
GladeXML *glade_dialog = NULL;
GtkWidget *dialog;
@@ -36,13 +37,21 @@ int zenity_text (ZenityData *data, ZenityTextData *text_data)
glade_dialog = zenity_util_load_glade_file ("zenity_text_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_text_dialog");
+ if (glade_dialog)
+ g_object_unref (glade_dialog);
+
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (zenity_text_dialog_response), data);
+
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
@@ -60,24 +69,21 @@ int zenity_text (ZenityData *data, ZenityTextData *text_data)
gtk_widget_show (dialog);
gtk_main ();
-
- if (glade_dialog)
- g_object_unref (glade_dialog);
-
- return TRUE;
}
-void
-zenity_text_dialog_response (GtkWindow *window, int button, gpointer data)
+static void
+zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data)
{
- GError *error = NULL;
+ ZenityData *zen_data = data;
- switch (button) {
+ switch (response) {
case GTK_RESPONSE_CLOSE:
+ zen_data->exit_code = 0;
gtk_main_quit ();
break;
default:
+ zen_data->exit_code = 1;
break;
}
}
diff --git a/src/tree.c b/src/tree.c
index 01be45cd..401fbe00 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -31,7 +31,7 @@
static GladeXML *glade_dialog;
-void zenity_tree_dialog_response (GtkWindow *window, int button, gpointer data);
+static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data);
static void
zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data)
@@ -104,7 +104,7 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col
}
}
-int
+void
zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
{
GtkWidget *dialog;
@@ -118,13 +118,18 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
glade_dialog = zenity_util_load_glade_file ("zenity_tree_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_tree_dialog");
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (zenity_tree_dialog_response), data);
+
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
@@ -209,25 +214,26 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
if (glade_dialog)
g_object_unref (glade_dialog);
-
- return TRUE;
}
-void
-zenity_tree_dialog_response (GtkWindow *window, int button, gpointer data)
+static void
+zenity_tree_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;
}
}
diff --git a/src/zenity.glade b/src/zenity.glade
index bb9a5192..9e272fa1 100644
--- a/src/zenity.glade
+++ b/src/zenity.glade
@@ -12,7 +12,6 @@
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
- <signal name="response" handler="zenity_calendar_dialog_response" last_modification_time="Fri, 27 Dec 2002 19:07:38 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Fri, 27 Dec 2002 19:08:11 GMT"/>
<child internal-child="vbox">
@@ -157,7 +156,6 @@
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
- <signal name="response" handler="zenity_msg_dialog_response" last_modification_time="Fri, 27 Dec 2002 23:23:57 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Fri, 27 Dec 2002 23:24:20 GMT"/>
<child internal-child="vbox">
@@ -269,7 +267,6 @@
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="show_fileops">True</property>
- <signal name="response" handler="zenity_fileselection_dialog_response" last_modification_time="Sat, 28 Dec 2002 11:48:14 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 11:48:27 GMT"/>
<child internal-child="cancel_button">
@@ -301,7 +298,6 @@
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
- <signal name="response" handler="zenity_msg_dialog_response" last_modification_time="Sat, 28 Dec 2002 12:03:43 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 12:03:54 GMT"/>
<child internal-child="vbox">
@@ -412,7 +408,6 @@
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
- <signal name="response" handler="zenity_entry_dialog_response" last_modification_time="Sat, 28 Dec 2002 12:15:25 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 12:15:37 GMT"/>
<child internal-child="vbox">
@@ -543,7 +538,6 @@
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
- <signal name="response" handler="zenity_text_dialog_response" last_modification_time="Sat, 28 Dec 2002 12:34:28 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 12:34:38 GMT"/>
<child internal-child="vbox">
@@ -637,7 +631,6 @@
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
- <signal name="response" handler="zenity_progress_dialog_response" last_modification_time="Sat, 28 Dec 2002 14:46:19 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 14:46:29 GMT"/>
<child internal-child="vbox">
@@ -760,7 +753,6 @@
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
- <signal name="response" handler="zenity_msg_dialog_response" last_modification_time="Sat, 28 Dec 2002 15:05:31 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 15:05:42 GMT"/>
<child internal-child="vbox">
@@ -873,7 +865,6 @@
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
- <signal name="response" handler="zenity_tree_dialog_response" last_modification_time="Sat, 28 Dec 2002 22:18:54 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 22:19:04 GMT"/>
<child internal-child="vbox">
@@ -1007,7 +998,6 @@
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
- <signal name="response" handler="zenity_msg_dialog_response" last_modification_time="Sat, 28 Dec 2002 15:05:31 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 15:05:42 GMT"/>
<child internal-child="vbox">
diff --git a/src/zenity.h b/src/zenity.h
index e3387608..9df373c5 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -26,6 +26,7 @@ G_BEGIN_DECLS
typedef struct {
gchar *dialog_title;
gchar *window_icon;
+ gint exit_code;
} ZenityData;
typedef struct {
@@ -76,19 +77,19 @@ typedef struct {
const gchar **data;
} ZenityTreeData;
-int zenity_calendar (ZenityData *data,
+void zenity_calendar (ZenityData *data,
ZenityCalendarData *calendar_data);
-int zenity_msg (ZenityData *data,
+void zenity_msg (ZenityData *data,
ZenityMsgData *msg_data);
-int zenity_fileselection (ZenityData *data,
+void zenity_fileselection (ZenityData *data,
ZenityFileData *file_data);
-int zenity_entry (ZenityData *data,
+void zenity_entry (ZenityData *data,
ZenityEntryData *entry_data);
-int zenity_progress (ZenityData *data,
+void zenity_progress (ZenityData *data,
ZenityProgressData *progress_data);
-int zenity_text (ZenityData *data,
+void zenity_text (ZenityData *data,
ZenityTextData *text_data);
-int zenity_tree (ZenityData *data,
+void zenity_tree (ZenityData *data,
ZenityTreeData *tree_data);
G_END_DECLS
bgstack15