From 48c1564ac5ef431e9111606e40488d04a96f3059 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 3 Jan 2003 13:26:04 +0000 Subject: Initial revision --- src/entry.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/entry.c (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c new file mode 100644 index 00000000..3816a502 --- /dev/null +++ b/src/entry.c @@ -0,0 +1,94 @@ +/* + * entry.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include "zenity.h" +#include "util.h" + +void zenity_entry_dialog_response (GtkWindow *window, int button, gpointer data); + +int 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; + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog"); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + /* FIXME: Come up with a nice default window icon */; + + text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); + + if (entry_data->dialog_text) + gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); + + entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); + + if (entry_data->entry_text) + gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); + + if (entry_data->visible == FALSE) + g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL); + + gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); + + 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) +{ + GError *error = NULL; + + switch (button) { + case GTK_RESPONSE_OK: + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + gtk_main_quit (); + break; + + default: + break; + } +} -- cgit 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/entry.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src/entry.c') 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; } } -- cgit From c41421c043ec92da0936ca8005f3e7841abd19cd Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 18 Jan 2003 18:30:52 +0000 Subject: Add some screenshots for the help documentation. 2003-01-18 Glynn Foster * help/C/figures/zenity-calendar-screenshot.png, help/C/figures/zenity-entry-screenshot.png, help/C/figures/zenity-error-screenshot.png, help/C/figures/zenity-fileselection-screenshot.png, help/C/figures/zenity-information-screenshot.png, help/C/figures/zenity-list-screenshot.png, help/C/figures/zenity-progress-screenshot.png, help/C/figures/zenity-question-screenshot.png, help/C/figures/zenity-text-screenshot.png, help/C/figures/zenity-warning-screenshot.png: Add some screenshots for the help documentation. * src/entry.c, src/msg.c: Don't set the text if it's NULL. --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 81fc2c5e..3578788e 100644 --- a/src/entry.c +++ b/src/entry.c @@ -56,7 +56,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->window_icon) zenity_util_set_window_icon (dialog, data->window_icon); else - /* FIXME: Come up with a nice default window icon */; + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); -- cgit From 22625f8b16e1dc38be50cc2e869780b74e7f6891 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 28 Jan 2003 14:58:30 +0000 Subject: Don't display the translators tab unless there is stuff to show. 2003-01-28 Glynn Foster * src/about.c: Don't display the translators tab unless there is stuff to show. * src/entry.c: Add sanity NULL checking. * src/tree.c, src/zenity.h: Add support for a new --editable option. * src/main.c: Add support for new --editable option for the List dialog. Merge in the list of Gtk+ options into the popt table - ripped this from libbonoboui, thanks to James for pointing this out. * src/zenity.glade: Make the translatable strings less arse. * TODO: Update accordingly. --- src/entry.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 3578788e..893fbf62 100644 --- a/src/entry.c +++ b/src/entry.c @@ -84,11 +84,16 @@ static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; + const gchar *text; switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = 0; - g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); + gtk_main_quit (); break; -- cgit From 49f89795349a47ae4e061666d84a715bf24f5373 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 10 Mar 2003 17:11:18 +0000 Subject: Mass indentation cleanup. Make sure the glade dialogs aren't initially 2003-03-10 Glynn Foster * src/about.c, 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/util.c, src/util.h, src/zenity.glade, src/zenity.h: Mass indentation cleanup. Make sure the glade dialogs aren't initially visible because this avoids a visibility jump. Apparently == TRUE is bad mojo. Fix up. --- src/entry.c | 113 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 57 insertions(+), 56 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 893fbf62..0ccd4c0e 100644 --- a/src/entry.c +++ b/src/entry.c @@ -32,79 +32,80 @@ static GtkWidget *entry; void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { - GladeXML *glade_dialog = NULL; - GtkWidget *dialog; - GtkWidget *text; + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *text; - glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); + glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } + 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"); + 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); + + 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); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); - text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); + text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); - if (entry_data->dialog_text) - gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); + if (entry_data->dialog_text) + gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); - entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); + entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); - if (glade_dialog) - g_object_unref (glade_dialog); + if (glade_dialog) + g_object_unref (glade_dialog); - if (entry_data->entry_text) - gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); + if (entry_data->entry_text) + gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); - if (entry_data->visible == FALSE) - g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL); + if (!entry_data->visible) + g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL); - gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); + gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); - gtk_widget_show (dialog); - gtk_main (); + gtk_widget_show (dialog); + gtk_main (); } static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - const gchar *text; - - switch (response) { - case GTK_RESPONSE_OK: - zen_data->exit_code = 0; - text = gtk_entry_get_text (GTK_ENTRY (entry)); - - if (text != NULL) - 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; - } + ZenityData *zen_data = data; + const gchar *text; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + 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; + } } -- cgit From 965c2a91497fcf96c88c0029b18a6a1e9f5d46bd Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 13 Apr 2003 15:42:41 +0000 Subject: Finish off the indentation cleanup. Add new '--width' and '--height' 2003-04-13 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.h: Finish off the indentation cleanup. Add new '--width' and '--height' options to the general options. Fix up the radio list view, so that we can now act like a radio button group. * TODO: Update --- src/entry.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 0ccd4c0e..a46fd613 100644 --- a/src/entry.c +++ b/src/entry.c @@ -58,7 +58,9 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) zenity_util_set_window_icon (dialog, data->window_icon); else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); - + + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); if (entry_data->dialog_text) -- cgit From 5bade6fe6a14cce50508ee5d510a4560ebe3e421 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sat, 7 Jun 2003 14:41:56 +0000 Subject: Support user-defined return values via env vars, like dialog did. --- src/entry.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index a46fd613..d3b6656e 100644 --- a/src/entry.c +++ b/src/entry.c @@ -39,7 +39,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -91,7 +91,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text != NULL) @@ -101,13 +101,13 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) break; case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); gtk_main_quit (); break; default: /* Esc dialog */ - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } -- cgit From 0ebb6d692bc5f4bbd2943cc46586e8c7ab3a2e92 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Mon, 25 Aug 2003 20:11:40 +0000 Subject: s/g_printerr/g_print --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index d3b6656e..0d55f44a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -95,7 +95,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text != NULL) - g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); + g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); gtk_main_quit (); break; -- cgit From ceb065ee3352365c7f86dafbc8c8440495eb3093 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 25 Aug 2003 20:11:40 +0000 Subject: Hook up the 'activate' signal on the entry dialog. Fixes Debian bug 2003-09-11 Glynn Foster * src/entry.c: Hook up the 'activate' signal on the entry dialog. Fixes Debian bug #202332. --- src/entry.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 0d55f44a..69822823 100644 --- a/src/entry.c +++ b/src/entry.c @@ -26,6 +26,7 @@ #include "util.h" static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_entry_response (GtkWidget *widget, gpointer data); static GtkWidget *entry; @@ -68,6 +69,9 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); + g_signal_connect (G_OBJECT (entry), "activate", + G_CALLBACK (zenity_entry_response), data); + if (glade_dialog) g_object_unref (glade_dialog); @@ -83,6 +87,22 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_main (); } +static void +zenity_entry_response (GtkWidget *widget, gpointer data) +{ + ZenityData *zen_data = data; + const gchar *text; + + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + g_print ("%s\n", text); + + gtk_main_quit (); +} + static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { @@ -95,7 +115,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text != NULL) - g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); + g_print ("%s\n", text); gtk_main_quit (); break; -- cgit From c14af1c42cd52d7bf826e19265272d37a82c9cca Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 12 Sep 2003 08:48:06 +0000 Subject: Better patch from raf@noduck.net to fix the activate on the entry dialog. 2003-09-12 Glynn Foster * src/entry.c, src/zenity.glade: Better patch from raf@noduck.net to fix the activate on the entry dialog. --- src/entry.c | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 69822823..c2570e0a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -26,7 +26,6 @@ #include "util.h" static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data); -static void zenity_entry_response (GtkWidget *widget, gpointer data); static GtkWidget *entry; @@ -69,9 +68,6 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); - g_signal_connect (G_OBJECT (entry), "activate", - G_CALLBACK (zenity_entry_response), data); - if (glade_dialog) g_object_unref (glade_dialog); @@ -87,22 +83,6 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_main (); } -static void -zenity_entry_response (GtkWidget *widget, gpointer data) -{ - ZenityData *zen_data = data; - const gchar *text; - - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - - text = gtk_entry_get_text (GTK_ENTRY (entry)); - - if (text != NULL) - g_print ("%s\n", text); - - gtk_main_quit (); -} - static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { -- cgit From b43bbda2e247e72782cf116003d308d21346935f Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 19 Mar 2004 02:28:30 +0000 Subject: Patch from Darren Adams to make sure the new 2004-03-19 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c, src/progress.c, src/text.c, src/tree.c: Patch from Darren Adams to make sure the new file chooser resizes nicely. Sanitize the default setting of the other widgets. * configure.in, src/util.c: Lose gconf dependancy since we don't currently use it, although arguably we should to detect which help browser we're supposed to run :/ * THANKS, src/about.c: Add Darren to the list. --- src/entry.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index c2570e0a..bf1811bd 100644 --- a/src/entry.c +++ b/src/entry.c @@ -59,7 +59,8 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); -- cgit From 62785ed80fb0b86847b4eaa3f4cf596f4c109324 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 26 Apr 2004 04:41:25 +0000 Subject: Add from the 2 Sebastian's, and make email addresses more spam proof. 2004-04-26 Glynn Foster * THANKS, src/about.c: Add from the 2 Sebastian's, and make email addresses more spam proof. * src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c, * src/progress.c, src/text.c, src/tree.c, src/util.c, * src/util.h: Patch from Sebastian Kapfer to make all zenity dialogs transients of the parent xterm. Fixes #136226. * src/zenity.glade: Patch from Sebastian Heinlein to improve things HIG wise. Fixes #140745. --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index bf1811bd..36ff704a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -80,7 +80,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); - gtk_widget_show (dialog); + zenity_util_show_dialog (dialog); gtk_main (); } -- cgit From 63661a6ea0de0250b545d794f645a36ffeb88490 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 19 Jul 2004 01:13:40 +0000 Subject: src/calendar.c, src/entry.c, src/fileselection.c, Cleanup fixes from Paul 2004-07-19 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, * src/msg.c, src/progress.c, src/text.c, src/tree.c: Cleanup fixes from Paul Bolle. --- src/entry.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 36ff704a..4d242160 100644 --- a/src/entry.c +++ b/src/entry.c @@ -98,12 +98,10 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) if (text != NULL) g_print ("%s\n", text); - gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - gtk_main_quit (); break; default: @@ -111,4 +109,5 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + gtk_main_quit (); } -- cgit From 3e05834b4c23a5d5951403719b8594ff3d9fe30b Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Sep 2004 07:51:51 +0000 Subject: Add new notification icon. Update for new files. Restructure code a little 2004-09-13 Glynn Foster * data/Makefile.am, data/zenity-notification.png: Add new notification icon. * src/Makefile.am: Update for new files. * src/about.c, src/calendar.c, src/entry.c, src/fileselection.c, src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a little bit for new utility functions for setting window icons. * src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area support. * src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h: Add support for notification area. * data/zenity.1, help/*: Update docs for notification and new file selection changes. --- src/entry.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 4d242160..46672f82 100644 --- a/src/entry.c +++ b/src/entry.c @@ -54,10 +54,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); -- cgit From 403c8104aefc11954398106ab4fa39f9a79233c6 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 20 Apr 2005 03:00:57 +0000 Subject: Clean up the code a little bit. 2005-04-20 Glynn Foster * src/entry.c, src/option.c, src/zenity.h: Clean up the code a little bit. --- src/entry.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 46672f82..2d92f2d4 100644 --- a/src/entry.c +++ b/src/entry.c @@ -72,12 +72,13 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (entry_data->entry_text) gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); - if (!entry_data->visible) - g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL); + if (entry_data->hide_text) + g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); zenity_util_show_dialog (dialog); + gtk_main (); } -- cgit From 6abd93050f533752e47b75158e95431575c652ac Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 25 Apr 2005 03:20:45 +0000 Subject: COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, src/entry.c, 2005-04-25 Glynn Foster * COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, * src/entry.c, src/fileselection.c, src/main.c, src/msg.c, * src/notification.c, src/option.c, src/progress.c, * src/text.c, src/tree.c, src/util.c: Update the FSF address to point to 51 Franklin Street, Fifth Floor as per forwarded mail from Alvaro Lopez Ortega. --- src/entry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 2d92f2d4..db5b3fe8 100644 --- a/src/entry.c +++ b/src/entry.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ -- cgit From 4c328078b6ff16a0ba648f53c3bee7a68fe4dbc5 Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Wed, 6 Jul 2005 20:13:11 +0000 Subject: Include cleanups (config.h) --- src/entry.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index db5b3fe8..e8c25857 100644 --- a/src/entry.c +++ b/src/entry.c @@ -21,6 +21,8 @@ * Authors: Glynn Foster */ +#include "config.h" + #include #include "zenity.h" #include "util.h" -- cgit From 07618f9daa007f7cabfee3b25845e9088330abcd Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 11 May 2006 01:31:35 +0000 Subject: add optional dropdown menu to entry dialog (Fixed bug #311038). Patch from 2006-05-10 Lucas Rocha * src/entry.c (zenity_entry_fill_entries, zenity_entry), src/main.c, src/option.c, src/zenity.glade, src/zenity.h: add optional dropdown menu to entry dialog (Fixed bug #311038). Patch from Diego Escalante Urrelo . --- src/entry.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 11 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index e8c25857..4b0f588a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -30,6 +30,18 @@ static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data); static GtkWidget *entry; +static gint n_entries = 0; + +static void +zenity_entry_fill_entries (GSList **entries, const gchar **args) +{ + gint i = 0; + + while (args[i] != NULL) { + *entries = g_slist_append (*entries, (gchar *) args[i]); + i++; + } +} void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) @@ -37,7 +49,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) GladeXML *glade_dialog = NULL; GtkWidget *dialog; GtkWidget *text; - + GSList *entries = NULL; + GSList *tmp; + GtkWidget *vbox; + glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); if (glade_dialog == NULL) { @@ -48,7 +63,6 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) 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); @@ -65,17 +79,41 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (entry_data->dialog_text) gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); + + vbox = glade_xml_get_widget (glade_dialog, "vbox4"); + + zenity_entry_fill_entries(&entries, entry_data->data); + + n_entries = g_slist_length (entries); + + if (n_entries > 1) { + entry = gtk_combo_box_entry_new_text (); + + for (tmp = entries; tmp; tmp = tmp->next) { + gtk_combo_box_append_text (GTK_COMBO_BOX (entry), tmp->data); + } + + if (entry_data->entry_text) { + gtk_combo_box_prepend_text (GTK_COMBO_BOX (entry), entry_data->entry_text); + gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); + } + } else { + entry = gtk_entry_new(); + + if (entry_data->entry_text) + gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); + + if (entry_data->hide_text) + g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); - 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); + gtk_widget_show (entry); - if (entry_data->hide_text) - g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); + gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); + + if (glade_dialog) + g_object_unref (glade_dialog); gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); @@ -93,7 +131,12 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - text = gtk_entry_get_text (GTK_ENTRY (entry)); + if (n_entries > 1) { + text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (entry)); + } + else { + text = gtk_entry_get_text (GTK_ENTRY (entry)); + } if (text != NULL) g_print ("%s\n", text); -- cgit From 80d39c09c1ceecbf854fa9a8632708e2ab6fe878 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 27 Jul 2006 03:29:44 +0000 Subject: entry activation makes dialog return OK (Fixes bug #347340). 2006-07-27 Lucas Rocha * src/entry.c (zenity_entry): entry activation makes dialog return OK (Fixes bug #347340). --- src/entry.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 4b0f588a..390d9b6b 100644 --- a/src/entry.c +++ b/src/entry.c @@ -99,13 +99,14 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) } } else { entry = gtk_entry_new(); + + gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); if (entry_data->entry_text) gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); if (entry_data->hide_text) g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); - } gtk_widget_show (entry); -- cgit From 8b16d4d4122e6337517ec16b9ca22dd27df0dafb Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 13 Aug 2007 20:36:29 +0000 Subject: added timeout option to all dialogs (Fixes bug #160654). Based on patch 2007-08-13 Lucas Rocha * src/*.c: added timeout option to all dialogs (Fixes bug #160654). Based on patch from Muthiah Annamalai . svn path=/trunk/; revision=1231 --- src/entry.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 390d9b6b..dcd09854 100644 --- a/src/entry.c +++ b/src/entry.c @@ -120,6 +120,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) zenity_util_show_dialog (dialog); + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } -- cgit From 3f33966167cf2216f813c091d47461c451837602 Mon Sep 17 00:00:00 2001 From: Felix Riemann Date: Mon, 20 Jul 2009 10:23:32 +0200 Subject: Bug 578393 – convert from libglade to GtkBuilder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index dcd09854..9c02095d 100644 --- a/src/entry.c +++ b/src/entry.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -46,23 +45,23 @@ zenity_entry_fill_entries (GSList **entries, const gchar **args) void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { - GladeXML *glade_dialog = NULL; + GtkBuilder *builder = NULL; GtkWidget *dialog; - GtkWidget *text; + GObject *text; GSList *entries = NULL; GSList *tmp; - GtkWidget *vbox; + GObject *vbox; - glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); + builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_entry_dialog_response), data); @@ -75,12 +74,12 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); + text = gtk_builder_get_object (builder, "zenity_entry_text"); if (entry_data->dialog_text) gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); - vbox = glade_xml_get_widget (glade_dialog, "vbox4"); + vbox = gtk_builder_get_object (builder, "vbox4"); zenity_entry_fill_entries(&entries, entry_data->data); @@ -113,11 +112,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); - if (glade_dialog) - g_object_unref (glade_dialog); - gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); + g_object_unref (builder); + zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { -- cgit From 94190df420ee849752f5726979fea65fdb3b313b Mon Sep 17 00:00:00 2001 From: Siegfried-Angel Gevatter Pujals Date: Sat, 8 Aug 2009 01:55:22 +0200 Subject: Bug 567773 – "zenity --entry --text" doesn't interpret line breaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 9c02095d..43a312d5 100644 --- a/src/entry.c +++ b/src/entry.c @@ -77,7 +77,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) text = gtk_builder_get_object (builder, "zenity_entry_text"); if (entry_data->dialog_text) - gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); + gtk_label_set_text_with_mnemonic (GTK_LABEL (text), g_strcompress (entry_data->dialog_text)); vbox = gtk_builder_get_object (builder, "vbox4"); -- cgit From 171e59e3eae4ff183d690c460f99eea788b70be8 Mon Sep 17 00:00:00 2001 From: Adrian Carpenter Date: Mon, 10 Aug 2009 03:59:34 +0100 Subject: Bug 551116 - Fix default activation in entry dialog when using the dialog with drop down menu. --- src/entry.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 43a312d5..8826e92b 100644 --- a/src/entry.c +++ b/src/entry.c @@ -42,6 +42,12 @@ zenity_entry_fill_entries (GSList **entries, const gchar **args) } } +static void +zenity_entry_combo_activate_default (GtkEntry *entry, gpointer window) +{ + gtk_window_activate_default (GTK_WINDOW (window)); +} + void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { @@ -96,6 +102,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_combo_box_prepend_text (GTK_COMBO_BOX (entry), entry_data->entry_text); gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); } + + g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), "activate", + G_CALLBACK (zenity_entry_combo_activate_default), + GTK_WINDOW (dialog)); } else { entry = gtk_entry_new(); -- cgit From 1570a2bbf07627cb5f8d9828a95db67b7d00634c Mon Sep 17 00:00:00 2001 From: Philippe Gauthier Date: Fri, 30 Oct 2009 14:51:16 -0400 Subject: Use g_timeout_add_seconds instead g_timeout_add The calls to g_timeout_add are replaced with g_timeout_add_seconds to reduce the number or program wake ups. See the GNOME Goal description: http://live.gnome.org/GnomeGoals/UseTimeoutAddSeconds --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 8826e92b..ca53caf2 100644 --- a/src/entry.c +++ b/src/entry.c @@ -129,7 +129,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } gtk_main (); -- cgit From 4421de675feeb7d490d16f5410bf6bd514d99154 Mon Sep 17 00:00:00 2001 From: Luis Medinas Date: Thu, 21 Oct 2010 00:41:09 +0100 Subject: Remove deprecated code for GTK+-3.0. --- src/entry.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index ca53caf2..d69d918a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -92,14 +92,14 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) n_entries = g_slist_length (entries); if (n_entries > 1) { - entry = gtk_combo_box_entry_new_text (); + entry = gtk_combo_box_new_with_entry (); for (tmp = entries; tmp; tmp = tmp->next) { - gtk_combo_box_append_text (GTK_COMBO_BOX (entry), tmp->data); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data); } if (entry_data->entry_text) { - gtk_combo_box_prepend_text (GTK_COMBO_BOX (entry), entry_data->entry_text); + gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text); gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); } @@ -145,7 +145,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); if (n_entries > 1) { - text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (entry)); + text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); } else { text = gtk_entry_get_text (GTK_ENTRY (entry)); -- cgit From b39ad33c35bb93c647e7f6f05d1310a0ce6895d5 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 16 Jun 2011 11:07:58 -0300 Subject: Bug 651948 - zenity list does not return default value when timeout is over --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index d69d918a..ce6cda50 100644 --- a/src/entry.c +++ b/src/entry.c @@ -129,7 +129,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } gtk_main (); -- cgit From d60e5eeeb379e5444ad218d7335b17eaa821b182 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 17 Jun 2011 10:47:07 -0300 Subject: 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 --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index ce6cda50..d8111c04 100644 --- a/src/entry.c +++ b/src/entry.c @@ -143,7 +143,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { 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) { text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); } -- cgit From 6768a40e997697d05008aecdb41815e1dbae61c6 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 26 Jul 2011 14:00:28 -0300 Subject: Fix for bug #611297 Now Zenity have --ok-label and --cancel-label in all dialogs. This patch doesn't break old zenity scripts. --- src/entry.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index d8111c04..7163e54c 100644 --- a/src/entry.c +++ b/src/entry.c @@ -53,6 +53,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { GtkBuilder *builder = NULL; GtkWidget *dialog; + GtkWidget *button; GObject *text; GSList *entries = NULL; GSList *tmp; @@ -79,6 +80,20 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (data->ok_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + + if (data->cancel_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + } text = gtk_builder_get_object (builder, "zenity_entry_text"); -- cgit From bac509bb12fafb928f9e4009e46cefc63562b4ca Mon Sep 17 00:00:00 2001 From: Frode Austvik Date: Tue, 21 Aug 2012 11:25:51 +0200 Subject: Fix the ComboBoxText construction so the dropmenu works again. This fixes lp#998445 by changing the code to construct a new ComboBoxText instead of a ComboBox, which it was (probably accidentally) changed to do in commit 4421de67. Closes: lp#998445 --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 7163e54c..2b92e59f 100644 --- a/src/entry.c +++ b/src/entry.c @@ -107,7 +107,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) n_entries = g_slist_length (entries); if (n_entries > 1) { - entry = gtk_combo_box_new_with_entry (); + entry = gtk_combo_box_text_new_with_entry (); for (tmp = entries; tmp; tmp = tmp->next) { gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data); -- cgit From 0628bd3291aad936b6b553366600590cca360bfa Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Tue, 18 Sep 2012 18:33:07 +0200 Subject: util: Add an option to request dialogs being modal As WMs cannot open windows themselves, Mutter uses zenity to open "Force Quit" dialogs for unresponsive windows; as those are strongly tied to the corresponding window, it makes sense to make them modal (in particular when attaching them to their parent). https://bugzilla.gnome.org/show_bug.cgi?id=684322 --- src/entry.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 2b92e59f..72f73b5c 100644 --- a/src/entry.c +++ b/src/entry.c @@ -80,6 +80,9 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); -- cgit From 1ac1da63f8de626ce10d350be7b29744a743ec95 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 5 Mar 2013 16:56:24 -0300 Subject: But #674881 - Timeout option overriding normal exit code --- src/entry.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 72f73b5c..da708e22 100644 --- a/src/entry.c +++ b/src/entry.c @@ -153,31 +153,40 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_main (); } +static void +zenity_entry_dialog_output (void) +{ + const gchar *text; + if (n_entries > 1) + text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); + else + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + g_print ("%s\n", text); + +} + static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; - const gchar *text; switch (response) { case GTK_RESPONSE_OK: + zenity_entry_dialog_output (); zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - if (n_entries > 1) { - text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); - } - else { - text = gtk_entry_get_text (GTK_ENTRY (entry)); - } - - if (text != NULL) - g_print ("%s\n", text); - break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zenity_entry_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); -- cgit From 009523d5da827392b027ac6da1a50f94314e3a35 Mon Sep 17 00:00:00 2001 From: Weitian Leung Date: Fri, 23 Aug 2013 09:15:07 +0800 Subject: added attach option for transient window --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index da708e22..ca5e3752 100644 --- a/src/entry.c +++ b/src/entry.c @@ -144,7 +144,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) g_object_unref (builder); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); -- cgit From 6fcbb80fd1b5268fbedcdb985ffa873a2e475840 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 04:57:05 +0000 Subject: Do not use an icon for Cancel/OK buttons GTK+ documentation recommends to not use an icons, but use "_OK"/"_Cancel" labels instead --- src/entry.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index ca5e3752..efb2234d 100644 --- a/src/entry.c +++ b/src/entry.c @@ -87,15 +87,11 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button")); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } text = gtk_builder_get_object (builder, "zenity_entry_text"); -- cgit From ba5ea0386de2a80a664fb28d3af7e8d395968314 Mon Sep 17 00:00:00 2001 From: Gama Anderson Date: Sat, 28 Feb 2015 20:06:09 +0100 Subject: ADD gchar **extra_label TO struct ZenityData this is done to keep the name of the extra buttons ADD general option "extra-button" with string array as argument This will upon consecutive calls save the name of buttons in an array of strings To all MODES, except notification.c and about.c ADD if (data->extra_label) { gint i=0; while(data->extra_label[i]!=NULL){ gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); i++; } } This add the extra buttons to the dialog. The response is the number of the button To all MODES response, except notification.c and about.c ADD default: if (response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); This will print the button name to stdout when they are pressed ADD question option "switch" This will suppress the standard "ok" and "cancel" button in question. This just wort in combination with --extra-button, otherwise error is raised. https://bugzilla.gnome.org/show_bug.cgi?id=118016 --- src/entry.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index ca5e3752..5066f71e 100644 --- a/src/entry.c +++ b/src/entry.c @@ -83,7 +83,15 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - + + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); @@ -188,7 +196,8 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - /* Esc dialog */ + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } -- cgit From d063797fdfa73e5bec96d9399ab1bf47173a62d4 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 2 Oct 2015 14:35:06 +0200 Subject: Fixing GLib-CRITICAL messages --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 80367260..8e47ebd8 100644 --- a/src/entry.c +++ b/src/entry.c @@ -192,7 +192,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; -- cgit From 4eddb202cafdcabc254aa941ad1348ff09372627 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 7 Apr 2017 14:00:42 +0200 Subject: Fix style Fixing style in all zenity code, removing useless spaces, empty lines, all code in 80 columns, etc. --- src/entry.c | 324 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 167 insertions(+), 157 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 8e47ebd8..bf3db713 100644 --- a/src/entry.c +++ b/src/entry.c @@ -23,179 +23,189 @@ #include "config.h" -#include "zenity.h" #include "util.h" +#include "zenity.h" -static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_entry_dialog_response ( + GtkWidget *widget, int response, gpointer data); static GtkWidget *entry; static gint n_entries = 0; static void -zenity_entry_fill_entries (GSList **entries, const gchar **args) -{ - gint i = 0; - - while (args[i] != NULL) { - *entries = g_slist_append (*entries, (gchar *) args[i]); - i++; - } +zenity_entry_fill_entries (GSList **entries, const gchar **args) { + gint i = 0; + + while (args[i] != NULL) { + *entries = g_slist_append (*entries, (gchar *) args[i]); + i++; + } } static void -zenity_entry_combo_activate_default (GtkEntry *entry, gpointer window) -{ - gtk_window_activate_default (GTK_WINDOW (window)); +zenity_entry_combo_activate_default (GtkEntry *entry, gpointer window) { + gtk_window_activate_default (GTK_WINDOW (window)); } -void -zenity_entry (ZenityData *data, ZenityEntryData *entry_data) -{ - GtkBuilder *builder = NULL; - GtkWidget *dialog; - GtkWidget *button; - GObject *text; - GSList *entries = NULL; - GSList *tmp; - GObject *vbox; - - builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL); - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - gtk_builder_connect_signals (builder, NULL); - - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "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); - - zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - } - - if (data->cancel_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button")); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - } - - text = gtk_builder_get_object (builder, "zenity_entry_text"); - - if (entry_data->dialog_text) - gtk_label_set_text_with_mnemonic (GTK_LABEL (text), g_strcompress (entry_data->dialog_text)); - - vbox = gtk_builder_get_object (builder, "vbox4"); - - zenity_entry_fill_entries(&entries, entry_data->data); - - n_entries = g_slist_length (entries); - - if (n_entries > 1) { - entry = gtk_combo_box_text_new_with_entry (); - - for (tmp = entries; tmp; tmp = tmp->next) { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data); - } - - if (entry_data->entry_text) { - gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text); - gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); - } - - g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), "activate", - G_CALLBACK (zenity_entry_combo_activate_default), - GTK_WINDOW (dialog)); - } else { - entry = gtk_entry_new(); - - gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); - - if (entry_data->entry_text) - gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); - - if (entry_data->hide_text) - g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); - } - - gtk_widget_show (entry); - - gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); - - g_object_unref (builder); - - zenity_util_show_dialog (dialog, data->attach); - - if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); - } - - gtk_main (); -} +void +zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { + GtkBuilder *builder = NULL; + GtkWidget *dialog; + GtkWidget *button; + GObject *text; + GSList *entries = NULL; + GSList *tmp; + GObject *vbox; -static void -zenity_entry_dialog_output (void) -{ - const gchar *text; - if (n_entries > 1) - text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); - else - text = gtk_entry_get_text (GTK_ENTRY (entry)); + builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals (builder, NULL); + + dialog = + GTK_WIDGET (gtk_builder_get_object (builder, "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); + + zenity_util_set_window_icon ( + dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_entry_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + } + + if (data->cancel_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_entry_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + } + + text = gtk_builder_get_object (builder, "zenity_entry_text"); + + if (entry_data->dialog_text) + gtk_label_set_text_with_mnemonic ( + GTK_LABEL (text), g_strcompress (entry_data->dialog_text)); - if (text != NULL) - g_print ("%s\n", text); + vbox = gtk_builder_get_object (builder, "vbox4"); + zenity_entry_fill_entries (&entries, entry_data->data); + + n_entries = g_slist_length (entries); + + if (n_entries > 1) { + entry = gtk_combo_box_text_new_with_entry (); + + for (tmp = entries; tmp; tmp = tmp->next) { + gtk_combo_box_text_append_text ( + GTK_COMBO_BOX_TEXT (entry), tmp->data); + } + + if (entry_data->entry_text) { + gtk_combo_box_text_prepend_text ( + GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text); + gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); + } + + g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), + "activate", + G_CALLBACK (zenity_entry_combo_activate_default), + GTK_WINDOW (dialog)); + } else { + entry = gtk_entry_new (); + + gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); + + if (entry_data->entry_text) + gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); + + if (entry_data->hide_text) + g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); + } + + gtk_widget_show (entry); + + gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); + + gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); + + g_object_unref (builder); + + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + + gtk_main (); +} + +static void +zenity_entry_dialog_output (void) { + const gchar *text; + if (n_entries > 1) + text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); + else + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + g_print ("%s\n", text); } static void -zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_entry_dialog_output (); - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - case ZENITY_TIMEOUT: - zenity_entry_dialog_output (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - gtk_main_quit (); +zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_entry_dialog_output (); + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + case ZENITY_TIMEOUT: + zenity_entry_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + gtk_main_quit (); } -- cgit