From ec6542fa1826da640e080721fc4278231c7b40f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Sun, 19 Apr 2009 18:14:12 +0000 Subject: [PATCH] Watch the 'show-hidden' property of the file chooser widget using GObject's "notify" signal which gives accurate results and remove the hack using the "selection-changed" signal. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3714 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 3 +++ src/dialogs.c | 29 ++++++++++++----------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44af59ca..649add96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ file view. Remove the filename field as it is also provided by GTK itself with more features like auto-completion. + Watch the 'show-hidden' property of the file chooser widget using + GObject's "notify" signal which gives accurate results and remove + the hack using the "selection-changed" signal. 2009-04-17 Enrico Tröger diff --git a/src/dialogs.c b/src/dialogs.c index 5135b274..fe5e6aa3 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -67,10 +67,8 @@ enum #if ! GEANY_USE_WIN32_DIALOG static GtkWidget *add_file_open_extra_widget(void); -#endif -#if ! GEANY_USE_WIN32_DIALOG static void on_file_open_dialog_response (GtkDialog *dialog, gint response, @@ -107,35 +105,32 @@ on_file_open_dialog_response (GtkDialog *dialog, gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(ui_widgets.open_filesel), app->project->base_path, NULL); } -#endif -#if ! GEANY_USE_WIN32_DIALOG -static void -on_file_open_selection_changed (GtkFileChooser *filechooser, - gpointer user_data) +static void on_file_open_notify(GObject *filechooser, GParamSpec *pspec, gpointer data) { - gboolean is_on = gtk_file_chooser_get_show_hidden(filechooser); + const gchar *name; + GValue *value; + + name = g_intern_string(pspec->name); + value = g_new0(GValue, 1); + g_value_init(value, pspec->value_type); + g_object_get_property(filechooser, name, value); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( - ui_lookup_widget(GTK_WIDGET(filechooser), "check_hidden")), is_on); + ui_lookup_widget(GTK_WIDGET(filechooser), "check_hidden")), g_value_get_boolean(value)); } -#endif -#if ! GEANY_USE_WIN32_DIALOG static void -on_file_open_check_hidden_toggled (GtkToggleButton *togglebutton, - gpointer user_data) +on_file_open_check_hidden_toggled(GtkToggleButton *togglebutton, gpointer user_data) { gboolean is_on = gtk_toggle_button_get_active(togglebutton); gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(ui_widgets.open_filesel), is_on); } -#endif -#if ! GEANY_USE_WIN32_DIALOG static void create_open_file_dialog(void) { GtkWidget *filetype_combo, *encoding_combo; @@ -202,8 +197,8 @@ static void create_open_file_dialog(void) gtk_combo_box_append_text(GTK_COMBO_BOX(encoding_combo), _("Detect from file")); gtk_combo_box_set_active(GTK_COMBO_BOX(encoding_combo), GEANY_ENCODINGS_MAX); - g_signal_connect(ui_widgets.open_filesel, "selection-changed", - G_CALLBACK(on_file_open_selection_changed), NULL); + g_signal_connect(ui_widgets.open_filesel, "notify::show-hidden", + G_CALLBACK(on_file_open_notify), NULL); g_signal_connect(ui_widgets.open_filesel, "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL); g_signal_connect(ui_widgets.open_filesel, "response",