From 54bd29176c5f9d2cdccd290496e82f82c97f19ed Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 9 Oct 2007 20:50:10 +0000 Subject: [PATCH] use the "file-set" signal if possible (introduced with gtk+ 2.12). Enable 2007-10-09 Sven Neumann * libgimpwidgets/gimppropwidgets.c (gimp_prop_file_chooser_button_setup): use the "file-set" signal if possible (introduced with gtk+ 2.12). Enable display of hidden files if the initial filename is a hidden file. svn path=/trunk/; revision=23787 --- ChangeLog | 7 ++++++ libgimpwidgets/gimppropwidgets.c | 39 ++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 649bf3cbc6..450cc215e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-10-09 Sven Neumann + + * libgimpwidgets/gimppropwidgets.c + (gimp_prop_file_chooser_button_setup): use the "file-set" signal + if possible (introduced with gtk+ 2.12). Enable display of hidden + files if the initial filename is a hidden file. + 2007-10-09 Sven Neumann * app/plug-in/gimppluginmanager-restore.c diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c index b9c692b5cd..d626e9098b 100644 --- a/libgimpwidgets/gimppropwidgets.c +++ b/libgimpwidgets/gimppropwidgets.c @@ -2219,6 +2219,13 @@ gimp_prop_file_chooser_button_setup (GtkWidget *button, if (filename) { + gchar *basename = g_path_get_basename (filename); + + if (basename && basename[0] == '.') + gtk_file_chooser_set_show_hidden (GTK_FILE_CHOOSER (button), TRUE); + + g_free (basename); + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (button), filename); g_free (filename); } @@ -2237,20 +2244,28 @@ gimp_prop_file_chooser_button_setup (GtkWidget *button, set_param_spec (G_OBJECT (button), widget, param_spec); - /* this evil hack is here to work around bug #327243 */ - { - GSource *source = g_idle_source_new (); + /* GtkFileChooserButton::file-set is new in GTK+ 2.12 */ + if (g_signal_lookup ("file-set", GTK_TYPE_FILE_CHOOSER_BUTTON)) + { + g_signal_connect (button, "file-set", + G_CALLBACK (gimp_prop_file_chooser_button_callback), + config); + } + else + { + /* this evil hack is here to work around bug #327243 */ + GSource *source = g_idle_source_new (); - g_object_set_data (G_OBJECT (button), - "gimp-prop-file-chooser-connect", config); + g_object_set_data (G_OBJECT (button), + "gimp-prop-file-chooser-connect", config); - g_source_set_priority (source, G_PRIORITY_LOW); - g_source_set_closure (source, - g_cclosure_new_object (G_CALLBACK (gimp_prop_file_chooser_button_connect_idle), - G_OBJECT (button))); - g_source_attach (source, NULL); - g_source_unref (source); - } + g_source_set_priority (source, G_PRIORITY_LOW); + g_source_set_closure (source, + g_cclosure_new_object (G_CALLBACK (gimp_prop_file_chooser_button_connect_idle), + G_OBJECT (button))); + g_source_attach (source, NULL); + g_source_unref (source); + } connect_notify (config, param_spec->name, G_CALLBACK (gimp_prop_file_chooser_button_notify),