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/fileselection.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/fileselection.c (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c new file mode 100644 index 00000000..52c0021a --- /dev/null +++ b/src/fileselection.c @@ -0,0 +1,80 @@ +/* + * fileselection.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_fileselection_dialog_response (GtkWindow *window, int button, gpointer data); + +int 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; + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_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 + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + + if (file_data->uri) + gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); + + 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) +{ + 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/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 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/fileselection.c | 81 +++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 40 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 74122f87..6655f925 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -29,60 +29,61 @@ static void zenity_fileselection_dialog_response (GtkWidget *widget, int respons void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { - GladeXML *glade_dialog; - GtkWidget *dialog; + GladeXML *glade_dialog; + GtkWidget *dialog; - glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); + glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_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_fileselection_dialog"); + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_dialog"); - if (glade_dialog) - g_object_unref (glade_dialog); + if (glade_dialog) + g_object_unref (glade_dialog); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_fileselection_dialog_response), data); + 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); + 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-file.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-file.png")); - if (file_data->uri) - gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); + if (file_data->uri) + gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); - gtk_widget_show (dialog); - gtk_main (); + gtk_widget_show (dialog); + gtk_main (); } static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - - 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; + ZenityData *zen_data = data; + + 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; + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; + gtk_main_quit (); + break; - default: - zen_data->exit_code = 1; - 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/fileselection.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 6655f925..ec46f0c1 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -57,6 +57,8 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (file_data->uri) gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); -- 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/fileselection.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index ec46f0c1..69fc6583 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -35,7 +35,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -73,19 +73,20 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code + (ZENITY_OK); 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; + 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 0e4c879656dcb3a0f4ffbcc65e30b6120f65c05e Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Mon, 9 Jun 2003 18:57:01 +0000 Subject: Allow multiple file selections. --- src/fileselection.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 69fc6583..4e87d043 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -25,6 +25,8 @@ #include "zenity.h" #include "util.h" +ZenityData *zen_data; + static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data); void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) @@ -32,6 +34,8 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) GladeXML *glade_dialog; GtkWidget *dialog; + zen_data = data; + glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); if (glade_dialog == NULL) { @@ -47,7 +51,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) g_object_unref (glade_dialog); g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_fileselection_dialog_response), data); + G_CALLBACK (zenity_fileselection_dialog_response), file_data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -62,6 +66,9 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->uri) gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); + if (file_data->multi) + gtk_file_selection_set_select_multiple (GTK_FILE_SELECTION (dialog), TRUE); + gtk_widget_show (dialog); gtk_main (); } @@ -69,13 +76,32 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; + ZenityFileData *file_data = data; + gchar **selections; + gchar *separator = g_strdup(file_data->separator); + int i; switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code - (ZENITY_OK); - g_printerr ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget))); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + selections = gtk_file_selection_get_selections (GTK_FILE_SELECTION (widget)); + for (i=0;selections[i] != NULL; i++) { + g_printerr ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); + if (selections[i+1] != NULL) { + /* FIXME: This is a blatant copy of Gman's arse in tree.c */ + if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL) + g_printerr ("\n"); + else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL) + g_printerr ("\t"); + else + g_printerr ("%s",separator); + } else { + g_printerr ("\n"); + } + } + g_strfreev(selections); + g_free(separator); + gtk_main_quit (); break; -- cgit From cfe29d9ad04761e7a97964af5e8f20fca7d22cfc Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 10 Jun 2003 21:30:22 +0000 Subject: Allow /t and /n in dialog text. Some code cleanup. --- src/fileselection.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 4e87d043..d392b0d0 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -87,18 +87,10 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer selections = gtk_file_selection_get_selections (GTK_FILE_SELECTION (widget)); for (i=0;selections[i] != NULL; i++) { g_printerr ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); - if (selections[i+1] != NULL) { - /* FIXME: This is a blatant copy of Gman's arse in tree.c */ - if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL) - g_printerr ("\n"); - else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL) - g_printerr ("\t"); - else + if (selections[i+1] != NULL) g_printerr ("%s",separator); - } else { - g_printerr ("\n"); - } } + g_printerr("\n"); g_strfreev(selections); g_free(separator); -- cgit From 652c90596e2c4fff6b7b748afcb01df6e21d22d9 Mon Sep 17 00:00:00 2001 From: "Kevin C. Krinke" Date: Sun, 13 Jul 2003 23:03:18 +0000 Subject: user input data output to STDOUT via g_print instead of outputting to 2003-07-11 Kevin C. Krinke * src/calendar.c, src/entry.c, src/fileselection.c, src/text.c, src/tree.c: user input data output to STDOUT via g_print instead of outputting to STDERR via g_printerr. This makes it possible to destinguish user input data from GTK+ warnings / errors. * THANKS, src/about.c: I figure this is my second patch submission so I belong in the credits... --- src/fileselection.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index d392b0d0..cfc966f3 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -86,11 +86,11 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); selections = gtk_file_selection_get_selections (GTK_FILE_SELECTION (widget)); for (i=0;selections[i] != NULL; i++) { - g_printerr ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); + g_print ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); if (selections[i+1] != NULL) - g_printerr ("%s",separator); + g_print ("%s",separator); } - g_printerr("\n"); + g_print("\n"); g_strfreev(selections); g_free(separator); -- cgit From 104a45c0f772ec07866c717861d8cbf1128b1e58 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 31 Dec 2003 01:52:25 +0000 Subject: Release 2.5.1, a ridiculous bump so that we sync with the GNOME desktop 2003-12-30 Glynn Foster * configure.in: Release 2.5.1, a ridiculous bump so that we sync with the GNOME desktop releases. 2003-12-30 Jan Arne Petersen * src/fileselection.c: (zenity_fileselection), (zenity_fileselection_dialog_response): Replace GtkFileSelection with GtkFileChooser. --- src/fileselection.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index cfc966f3..955226d1 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -31,24 +31,17 @@ static void zenity_fileselection_dialog_response (GtkWidget *widget, int respons void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { - GladeXML *glade_dialog; GtkWidget *dialog; + gchar *dir; + gchar *basename; zen_data = data; - glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); - - if (glade_dialog == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - 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); + dialog = gtk_file_chooser_dialog_new (NULL, NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_fileselection_dialog_response), file_data); @@ -63,11 +56,19 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (file_data->uri) - gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); + if (file_data->uri) { + dir = g_path_get_dirname (file_data->uri); + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); + if (file_data->uri[strlen (file_data->uri) - 1] != '/') { + basename = g_path_get_basename (file_data->uri); + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); + g_free (basename); + } + g_free (dir); + } if (file_data->multi) - gtk_file_selection_set_select_multiple (GTK_FILE_SELECTION (dialog), TRUE); + gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); gtk_widget_show (dialog); gtk_main (); @@ -77,21 +78,22 @@ static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityFileData *file_data = data; - gchar **selections; + GSList *selections, *iter; gchar *separator = g_strdup(file_data->separator); int i; switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - selections = gtk_file_selection_get_selections (GTK_FILE_SELECTION (widget)); - for (i=0;selections[i] != NULL; i++) { - g_print ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); - if (selections[i+1] != NULL) + selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); + for (iter = selections;iter != NULL; iter = iter->next) { + g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); + g_free (iter->data); + if (iter->next != NULL) g_print ("%s",separator); } g_print("\n"); - g_strfreev(selections); + g_slist_free(selections); g_free(separator); gtk_main_quit (); -- 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/fileselection.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 955226d1..6a9b018c 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -54,8 +54,6 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); @@ -107,6 +105,7 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + gtk_main_quit (); break; } } -- 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/fileselection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 6a9b018c..a783b34a 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -68,7 +68,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->multi) gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); - 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/fileselection.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index a783b34a..995ba03f 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -94,18 +94,16 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer g_slist_free(selections); g_free(separator); - gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - gtk_main_quit (); break; default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - gtk_main_quit (); break; } + gtk_main_quit (); } -- cgit From 03f3e5b060977c9566bd66bc8e4eaac14c4ee781 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Sep 2004 04:56:26 +0000 Subject: Update Update. Patch from Lucas Rocha to implement save and directory 2004-09-13 Glynn Foster * THANKS: Update * src/about.c: Update. * src/fileselection.c, src/main.c, src/zenity.h: Patch from Lucas Rocha to implement save and directory selection in the file selection dialog. Fixes #138342. --- src/fileselection.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 995ba03f..fdd40fdd 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -34,11 +34,22 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) GtkWidget *dialog; gchar *dir; gchar *basename; + GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; zen_data = data; + if (file_data->directory) { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; + else + action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + } else { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_SAVE; + } + dialog = gtk_file_chooser_dialog_new (NULL, NULL, - GTK_FILE_CHOOSER_ACTION_OPEN, + action, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); -- 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/fileselection.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index fdd40fdd..4d50fb76 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -60,10 +60,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_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-file.png")); + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); -- cgit From a197b56c07a7ae337901ffe3f3d404fe840480f7 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 16 Feb 2005 10:28:11 +0000 Subject: Fix bug #167577, that leaks a seperator. Patch from Paolo Borelli 2005-02-16 Glynn Foster * src/fileselection.c, THANKS, src/about.c: Fix bug #167577, that leaks a seperator. Patch from Paolo Borelli --- src/fileselection.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 4d50fb76..69304374 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -85,7 +85,6 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer { ZenityFileData *file_data = data; GSList *selections, *iter; - gchar *separator = g_strdup(file_data->separator); int i; switch (response) { @@ -96,12 +95,10 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); g_free (iter->data); if (iter->next != NULL) - g_print ("%s",separator); + g_print ("%s",file_data->separator); } g_print("\n"); g_slist_free(selections); - g_free(separator); - break; case GTK_RESPONSE_CANCEL: -- cgit From 6d386ddda5e4552aeda28b104242626ff05b10c5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Thu, 21 Apr 2005 00:56:05 +0000 Subject: Fix for #171838, from Carlos Parra. 2005-04-20 Glynn Foster * src/fileselection.c: Fix for #171838, from Carlos Parra. --- src/fileselection.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 69304374..4e51eec2 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -64,7 +64,10 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); + + if (g_path_is_absolute (file_data->uri) == TRUE) + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); + if (file_data->uri[strlen (file_data->uri) - 1] != '/') { basename = g_path_get_basename (file_data->uri); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); -- 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/fileselection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 4e51eec2..b2144a15 100644 --- a/src/fileselection.c +++ b/src/fileselection.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/fileselection.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index b2144a15..95178ec7 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -21,7 +21,10 @@ * Authors: Glynn Foster */ +#include "config.h" + #include +#include #include "zenity.h" #include "util.h" -- cgit From d6f1d76768fe99c0f67545a9b6da98411733ffca Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 8 Jul 2005 13:39:27 +0000 Subject: marks static many functions and global variables. Contribution from MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2005-07-08 Lucas Rocha * src/about.c, src/option.c, src/fileselection.c: marks static many functions and global variables. Contribution from Benoît Dejean. --- src/fileselection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 95178ec7..91c0a0f3 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -28,7 +28,7 @@ #include "zenity.h" #include "util.h" -ZenityData *zen_data; +static ZenityData *zen_data; static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data); -- cgit From 21f7bc6a54636c749cf5514e091feb68cc88907b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 8 Jul 2005 23:21:34 +0000 Subject: general code cleanups. Contribution from Benoît Dejean. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2005-07-08 Lucas Rocha * src/about.c, src/calendar.c, src/fileselection.c, src/option.c, src/progress.c, src/text.c, src/tree.c, src/util.c: general code cleanups. Contribution from Benoît Dejean. --- src/fileselection.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 91c0a0f3..53859229 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -91,7 +91,6 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer { ZenityFileData *file_data = data; GSList *selections, *iter; - int i; switch (response) { case GTK_RESPONSE_OK: -- cgit From 6645316bc935dfc2b4f8a1cad95a98f90cd710c1 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 23 Mar 2006 20:08:17 +0000 Subject: add --confirm-overwrite to file selection dialog to pop a confirmation 2006-03-23 Lucas Rocha * src/fileselection.c, zenity.h, option.c: add --confirm-overwrite to file selection dialog to pop a confirmation dialog when selecting an existing filename. --- src/fileselection.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 53859229..3f355bab 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -57,6 +57,9 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), + file_data->confirm_overwrite); + g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_fileselection_dialog_response), file_data); -- 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/fileselection.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 3f355bab..c91c816a 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -86,6 +86,11 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); 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 8cda6025f0a11278c8d2f01482ad1656a2b5e5b1 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 21 Apr 2008 20:47:38 +0000 Subject: Add support for file filter in file selection dialog through the new 2008-04-21 Lucas Rocha Add support for file filter in file selection dialog through the new --file-filter command line option (Fixes bug #409843). * src/option.c, src/zenity.h: added supporting variable and new GOptionEntry entry for the new command line option. * src/fileselection.c (zenity_fileselection): add file filters based on command line input. svn path=/trunk/; revision=1362 --- src/fileselection.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index c91c816a..46d1941d 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -85,6 +85,52 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->multi) gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); + if (file_data->filter) { + /* Filter format: Executables | *.exe *.bat *.com */ + gint filter_i; + + for (filter_i = 0; file_data->filter [filter_i]; filter_i++) { + GtkFileFilter *filter = gtk_file_filter_new(); + gchar *filter_str = file_data->filter [filter_i]; + gchar **pattern, **patterns; + gchar *name = NULL; + gint i; + + /* Set name */ + for (i = 0; filter_str[i] != '\0'; i++) + if (filter_str[i] == '|') + break; + + if (filter_str[i] == '|') { + name = g_strndup (filter_str, i); + g_strstrip (name); + } + + if (name) { + gtk_file_filter_set_name (filter, name); + + /* Point i to the right position for split */ + for (++i; filter_str[i] == ' '; i++); + } else { + gtk_file_filter_set_name (filter, filter_str); + i = 0; + } + + /* Get patterns */ + patterns = g_strsplit_set (filter_str + i, " ", -1); + + for (pattern = patterns; *pattern; pattern++) + gtk_file_filter_add_pattern (filter, *pattern); + + if (name) + g_free (name); + + g_strfreev (patterns); + + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + } + } + zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { -- cgit From ec484005101b3720feb95c8d76a65bcd6b0472c2 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 9 Jan 2009 00:08:01 +0000 Subject: correctly handle --filename option on file selection mode (Fixes bug 2009-01-09 Lucas Rocha * src/fileselection.c (zenity_fileselection): correctly handle --filename option on file selection mode (Fixes bug #564552). Patch from Gilles Detillieux. svn path=/trunk/; revision=1461 --- src/fileselection.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 46d1941d..4cfa0514 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -76,7 +76,10 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->uri[strlen (file_data->uri) - 1] != '/') { basename = g_path_get_basename (file_data->uri); - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); + if (file_data->save) + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); + else + (void) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), file_data->uri); g_free (basename); } g_free (dir); -- 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/fileselection.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 4cfa0514..dd4ab0d3 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include #include "zenity.h" #include "util.h" -- 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/fileselection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index dd4ab0d3..026bb310 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -136,7 +136,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_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 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/fileselection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 026bb310..07d85c0d 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -136,7 +136,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_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/fileselection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 07d85c0d..349ff32d 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -150,7 +150,7 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer 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); selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); for (iter = selections;iter != NULL; iter = iter->next) { g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); -- 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/fileselection.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 349ff32d..cf82f028 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -67,6 +67,9 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); -- 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/fileselection.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index cf82f028..b4b0a65e 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -145,30 +145,41 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) gtk_main (); } +static void +zenity_fileselection_dialog_output (GtkWidget *widget, ZenityFileData *file_data) +{ + GSList *selections, *iter; + selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); + for (iter = selections;iter != NULL; iter = iter->next) { + g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); + g_free (iter->data); + if (iter->next != NULL) + g_print ("%s",file_data->separator); + } + g_print("\n"); + g_slist_free(selections); +} + static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityFileData *file_data = data; - GSList *selections, *iter; - + switch (response) { case GTK_RESPONSE_OK: + zenity_fileselection_dialog_output (widget, file_data); zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); - for (iter = selections;iter != NULL; iter = iter->next) { - g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); - g_free (iter->data); - if (iter->next != NULL) - g_print ("%s",file_data->separator); - } - g_print("\n"); - g_slist_free(selections); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zenity_fileselection_dialog_output (widget, file_data); + 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/fileselection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index b4b0a65e..9edbb6ae 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -136,7 +136,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) } } - 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/fileselection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 9edbb6ae..30495558 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -52,8 +52,8 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) dialog = gtk_file_chooser_dialog_new (NULL, NULL, action, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_OK"), GTK_RESPONSE_OK, NULL); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), -- 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/fileselection.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 9edbb6ae..fbf0e5de 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -62,6 +62,14 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_fileselection_dialog_response), file_data); + 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->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -181,7 +189,8 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer 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/fileselection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 3ccd11dd..27db0f40 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -189,7 +189,7 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer 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/fileselection.c | 344 +++++++++++++++++++++++++++------------------------- 1 file changed, 180 insertions(+), 164 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 27db0f40..521464b0 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -23,176 +23,192 @@ #include "config.h" -#include -#include "zenity.h" #include "util.h" +#include "zenity.h" +#include -static ZenityData *zen_data; - -static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data); - -void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) -{ - GtkWidget *dialog; - gchar *dir; - gchar *basename; - GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; - - zen_data = data; - - if (file_data->directory) { - if (file_data->save) - action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; - else - action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; - } else { - if (file_data->save) - action = GTK_FILE_CHOOSER_ACTION_SAVE; - } - - dialog = gtk_file_chooser_dialog_new (NULL, NULL, - action, - _("_Cancel"), GTK_RESPONSE_CANCEL, - _("_OK"), GTK_RESPONSE_OK, - NULL); - - gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), - file_data->confirm_overwrite); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_fileselection_dialog_response), file_data); - - 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->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-file.png")); - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - if (file_data->uri) { - dir = g_path_get_dirname (file_data->uri); - - if (g_path_is_absolute (file_data->uri) == TRUE) - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); - - if (file_data->uri[strlen (file_data->uri) - 1] != '/') { - basename = g_path_get_basename (file_data->uri); - if (file_data->save) - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); - else - (void) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), file_data->uri); - g_free (basename); - } - g_free (dir); - } - - if (file_data->multi) - gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); - - if (file_data->filter) { - /* Filter format: Executables | *.exe *.bat *.com */ - gint filter_i; - - for (filter_i = 0; file_data->filter [filter_i]; filter_i++) { - GtkFileFilter *filter = gtk_file_filter_new(); - gchar *filter_str = file_data->filter [filter_i]; - gchar **pattern, **patterns; - gchar *name = NULL; - gint i; - - /* Set name */ - for (i = 0; filter_str[i] != '\0'; i++) - if (filter_str[i] == '|') - break; - - if (filter_str[i] == '|') { - name = g_strndup (filter_str, i); - g_strstrip (name); - } - - if (name) { - gtk_file_filter_set_name (filter, name); - - /* Point i to the right position for split */ - for (++i; filter_str[i] == ' '; i++); - } else { - gtk_file_filter_set_name (filter, filter_str); - i = 0; - } - - /* Get patterns */ - patterns = g_strsplit_set (filter_str + i, " ", -1); - - for (pattern = patterns; *pattern; pattern++) - gtk_file_filter_add_pattern (filter, *pattern); - - if (name) - g_free (name); - - g_strfreev (patterns); - - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); - } - } - - 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 ZenityData *zen_data; + +static void zenity_fileselection_dialog_response ( + GtkWidget *widget, int response, gpointer data); + +void +zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { + GtkWidget *dialog; + gchar *dir; + gchar *basename; + GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; + + zen_data = data; + + if (file_data->directory) { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; + else + action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + } else { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_SAVE; + } + + dialog = gtk_file_chooser_dialog_new (NULL, + NULL, + action, + _ ("_Cancel"), + GTK_RESPONSE_CANCEL, + _ ("_OK"), + GTK_RESPONSE_OK, + NULL); + + gtk_file_chooser_set_do_overwrite_confirmation ( + GTK_FILE_CHOOSER (dialog), file_data->confirm_overwrite); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_fileselection_dialog_response), + file_data); + + 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->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-file.png")); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + if (file_data->uri) { + dir = g_path_get_dirname (file_data->uri); + + if (g_path_is_absolute (file_data->uri) == TRUE) + gtk_file_chooser_set_current_folder ( + GTK_FILE_CHOOSER (dialog), dir); + + if (file_data->uri[strlen (file_data->uri) - 1] != '/') { + basename = g_path_get_basename (file_data->uri); + if (file_data->save) + gtk_file_chooser_set_current_name ( + GTK_FILE_CHOOSER (dialog), basename); + else + (void) gtk_file_chooser_set_filename ( + GTK_FILE_CHOOSER (dialog), file_data->uri); + g_free (basename); + } + g_free (dir); + } + + if (file_data->multi) + gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); + + if (file_data->filter) { + /* Filter format: Executables | *.exe *.bat *.com */ + gint filter_i; + + for (filter_i = 0; file_data->filter[filter_i]; filter_i++) { + GtkFileFilter *filter = gtk_file_filter_new (); + gchar *filter_str = file_data->filter[filter_i]; + gchar **pattern, **patterns; + gchar *name = NULL; + gint i; + + /* Set name */ + for (i = 0; filter_str[i] != '\0'; i++) + if (filter_str[i] == '|') + break; + + if (filter_str[i] == '|') { + name = g_strndup (filter_str, i); + g_strstrip (name); + } + + if (name) { + gtk_file_filter_set_name (filter, name); + + /* Point i to the right position for split */ + for (++i; filter_str[i] == ' '; i++) + ; + } else { + gtk_file_filter_set_name (filter, filter_str); + i = 0; + } + + /* Get patterns */ + patterns = g_strsplit_set (filter_str + i, " ", -1); + + for (pattern = patterns; *pattern; pattern++) + gtk_file_filter_add_pattern (filter, *pattern); + + if (name) + g_free (name); + + g_strfreev (patterns); + + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + } + } + + 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_fileselection_dialog_output (GtkWidget *widget, ZenityFileData *file_data) -{ - GSList *selections, *iter; - selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); - for (iter = selections;iter != NULL; iter = iter->next) { - g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); - g_free (iter->data); - if (iter->next != NULL) - g_print ("%s",file_data->separator); - } - g_print("\n"); - g_slist_free(selections); +zenity_fileselection_dialog_output ( + GtkWidget *widget, ZenityFileData *file_data) { + GSList *selections, *iter; + selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); + for (iter = selections; iter != NULL; iter = iter->next) { + g_print ("%s", + g_filename_to_utf8 ((gchar *) iter->data, -1, NULL, NULL, NULL)); + g_free (iter->data); + if (iter->next != NULL) + g_print ("%s", file_data->separator); + } + g_print ("\n"); + g_slist_free (selections); } static void -zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityFileData *file_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_fileselection_dialog_output (widget, file_data); - 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_fileselection_dialog_output (widget, file_data); - 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_fileselection_dialog_response ( + GtkWidget *widget, int response, gpointer data) { + ZenityFileData *file_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_fileselection_dialog_output (widget, file_data); + 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_fileselection_dialog_output (widget, file_data); + 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 From 110a851747398a59e8aa921faed57fca4b59792b Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Mon, 22 May 2017 09:30:49 -0400 Subject: Use GtkFileChooserNative --- src/fileselection.c | 69 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 22 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 521464b0..63c18439 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -30,14 +30,18 @@ static ZenityData *zen_data; static void zenity_fileselection_dialog_response ( - GtkWidget *widget, int response, gpointer data); + gpointer obj, int response, gpointer data); void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { - GtkWidget *dialog; gchar *dir; gchar *basename; GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; +#if GTK_CHECK_VERSION(3, 20, 0) + GtkFileChooserNative *dialog; +#else + GtkWidget *dialog; +#endif zen_data = data; @@ -51,22 +55,37 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { action = GTK_FILE_CHOOSER_ACTION_SAVE; } +#if GTK_CHECK_VERSION(3, 20, 0) + dialog = gtk_file_chooser_native_new (data->dialog_title, + NULL, /* TODO: Get parent from xid */ + action, + _ ("_OK"), + _ ("_Cancel") + ); + + if (data->modal) + gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG(dialog), TRUE); + + if (data->extra_label) + g_warning ("Cannot add extra labels to GtkFileChooserNative"); +#else dialog = gtk_file_chooser_dialog_new (NULL, NULL, action, _ ("_Cancel"), GTK_RESPONSE_CANCEL, _ ("_OK"), - GTK_RESPONSE_OK, + GTK_RESPONSE_ACCEPT, NULL); - gtk_file_chooser_set_do_overwrite_confirmation ( - GTK_FILE_CHOOSER (dialog), file_data->confirm_overwrite); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - g_signal_connect (G_OBJECT (dialog), - "response", - G_CALLBACK (zenity_fileselection_dialog_response), - file_data); + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + zenity_util_set_window_icon ( + dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); if (data->extra_label) { gint i = 0; @@ -76,15 +95,15 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { i++; } } +#endif - 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-file.png")); + gtk_file_chooser_set_do_overwrite_confirmation ( + GTK_FILE_CHOOSER (dialog), file_data->confirm_overwrite); - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_fileselection_dialog_response), + file_data); if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); @@ -156,7 +175,11 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { } } +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_native_dialog_show (GTK_NATIVE_DIALOG(dialog)); +#else zenity_util_show_dialog (dialog, data->attach); +#endif if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, @@ -169,9 +192,9 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { static void zenity_fileselection_dialog_output ( - GtkWidget *widget, ZenityFileData *file_data) { + GtkFileChooser *chooser, ZenityFileData *file_data) { GSList *selections, *iter; - selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); + selections = gtk_file_chooser_get_filenames (chooser); for (iter = selections; iter != NULL; iter = iter->next) { g_print ("%s", g_filename_to_utf8 ((gchar *) iter->data, -1, NULL, NULL, NULL)); @@ -185,12 +208,14 @@ zenity_fileselection_dialog_output ( static void zenity_fileselection_dialog_response ( - GtkWidget *widget, int response, gpointer data) { + gpointer obj, int response, gpointer data) { ZenityFileData *file_data = data; + GtkFileChooser *chooser = GTK_FILE_CHOOSER(obj); + switch (response) { - case GTK_RESPONSE_OK: - zenity_fileselection_dialog_output (widget, file_data); + case GTK_RESPONSE_ACCEPT: + zenity_fileselection_dialog_output (chooser, file_data); zenity_util_exit_code_with_data (ZENITY_OK, zen_data); break; @@ -199,7 +224,7 @@ zenity_fileselection_dialog_response ( break; case ZENITY_TIMEOUT: - zenity_fileselection_dialog_output (widget, file_data); + zenity_fileselection_dialog_output (chooser, file_data); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); break; -- cgit From ad6a345133ab026465903fc89b8275bf9c5ea8a5 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 26 May 2017 14:27:44 +0200 Subject: Formating latest patch --- src/fileselection.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/fileselection.c') diff --git a/src/fileselection.c b/src/fileselection.c index 63c18439..465f08ae 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -60,11 +60,10 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { NULL, /* TODO: Get parent from xid */ action, _ ("_OK"), - _ ("_Cancel") - ); + _ ("_Cancel")); if (data->modal) - gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG(dialog), TRUE); + gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE); if (data->extra_label) g_warning ("Cannot add extra labels to GtkFileChooserNative"); @@ -176,7 +175,7 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { } #if GTK_CHECK_VERSION(3, 20, 0) - gtk_native_dialog_show (GTK_NATIVE_DIALOG(dialog)); + gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog)); #else zenity_util_show_dialog (dialog, data->attach); #endif @@ -211,7 +210,7 @@ zenity_fileselection_dialog_response ( gpointer obj, int response, gpointer data) { ZenityFileData *file_data = data; - GtkFileChooser *chooser = GTK_FILE_CHOOSER(obj); + GtkFileChooser *chooser = GTK_FILE_CHOOSER (obj); switch (response) { case GTK_RESPONSE_ACCEPT: -- cgit