The File Open dialog box looks at the contents of the selected file
in order to decide whether to set the sensitivity of the encoding
selector. But if the file was a directory this caused error messages
on windoze. Closes bug #34773
-/* 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;
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. */
}
\f
/* Environment variables. */
#define N_(msgid) msgid
#include "data/any-reader.h"
#define N_(msgid) msgid
#include "data/any-reader.h"
+#include "data/file-name.h"
#include "data/dataset.h"
#include "helper.h"
#include "data/dataset.h"
#include "helper.h"
sysname = convert_glib_filename_to_system_filename (name, NULL);
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));
}
gtk_widget_set_sensitive (encoding_selector, ! any_reader_may_open (sysname));
}
{
GtkWidget *encoding_selector = 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);
+ 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);