return false;
}
-/* Returns true if file with name NAME exists. */
+/* Returns true if file with name NAME exists, and that file is not a
+ directory */
bool
fn_exists (const char *name)
{
struct stat temp;
- return stat (name, &temp) == 0;
+ if ( stat (name, &temp) != 0 )
+ return false;
+
+ return ! S_ISDIR (temp.st_mode);
}
\f
/* Environment variables. */
#define N_(msgid) msgid
#include "data/any-reader.h"
+#include "data/file-name.h"
#include "data/dataset.h"
#include "helper.h"
sysname = convert_glib_filename_to_system_filename (name, NULL);
+ if ( ! fn_exists (sysname))
+ {
+ gtk_widget_set_sensitive (encoding_selector, FALSE);
+ return;
+ }
+
gtk_widget_set_sensitive (encoding_selector, ! any_reader_may_open (sysname));
}
{
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);
+ gtk_widget_set_sensitive (encoding_selector, FALSE);
+
+ g_signal_connect (dialog, "selection-changed", G_CALLBACK (on_selection_changed),
+ encoding_selector);
+
+ gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), encoding_selector);
}
return dialog;