From: John Darrington Date: Sat, 3 Sep 2011 12:14:50 +0000 (+0200) Subject: File Open dialog: disable encoding selector when not applicable X-Git-Tag: v0.7.9~144 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40774acff41f07dda235710fd8af0eb47f8f299b;p=pspp-builds.git File Open dialog: disable encoding selector when not applicable --- diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index f6cdb7b2..598de893 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -706,6 +706,22 @@ psppire_window_load (PsppireWindow *w, const gchar *file) return ok; } + +static void +on_selection_changed (GtkFileChooser *chooser, GtkWidget *encoding_selector) +{ + const gchar *sysname; + + const gchar *name = gtk_file_chooser_get_filename (chooser); + + if ( NULL == name ) + return; + + sysname = convert_glib_filename_to_system_filename (name, NULL); + + gtk_widget_set_sensitive (encoding_selector, ! any_reader_may_open (sysname)); +} + GtkWidget * psppire_window_file_chooser_dialog (PsppireWindow *toplevel) { @@ -769,8 +785,13 @@ psppire_window_file_chooser_dialog (PsppireWindow *toplevel) free (dir_name); } - gtk_file_chooser_set_extra_widget ( - GTK_FILE_CHOOSER (dialog), psppire_encoding_selector_new ("Auto", true)); + + { + GtkWidget *encoding_selector = psppire_encoding_selector_new ("Auto", true); + gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), encoding_selector); + + g_signal_connect (dialog, "selection-changed", G_CALLBACK (on_selection_changed), encoding_selector); + } return dialog; }