return recode_string (CONV_UTF8_TO_PSPP, text, len);
}
+/* This function must be used whenever a filename generated by glib,
+ (eg, from gtk_file_chooser_get_filename) and passed to the C library,
+ (eg through a pspp syntax string).
+*/
+gchar *
+convert_glib_filename_to_system_filename (const gchar *fname, GError **err)
+{
+ gchar *output_name;
+
+#ifdef G_OS_WIN32
+ const gchar *target_encoding;
+ gchar *utf8_name = NULL;
+
+ g_get_charset (&target_encoding);
+
+ output_name = g_convert (fname, -1, target_encoding,
+ "UTF-8", NULL, NULL, err);
+#else
+ output_name = strdup (fname);
+#endif
+
+ return output_name;
+}
+
+
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
gchar * pspp_locale_to_utf8 (const gchar *text, gssize len, GError **err);
gchar * utf8_to_pspp_locale (const gchar *text, gssize len, GError **err);
+gchar * convert_glib_filename_to_system_filename (const gchar *fname,
+ GError **err);
+
void connect_help (GtkBuilder *);
static gboolean
load_file (PsppireWindow *de, const gchar *file_name)
{
+ gchar *native_file_name;
struct getl_interface *sss;
struct string filename;
ds_init_empty (&filename);
- syntax_gen_string (&filename, ss_cstr (file_name));
+
+ native_file_name =
+ convert_glib_filename_to_system_filename (file_name, NULL);
+
+ syntax_gen_string (&filename, ss_cstr (native_file_name));
+
+ g_free (native_file_name);
sss = create_syntax_string_source ("GET FILE=%s.",
ds_cstr (&filename));
ds_destroy (&filename);
if (execute_syntax (sss) )
- {
- psppire_window_set_filename (de, file_name);
- return TRUE;
- }
+ return TRUE;
return FALSE;
}
GtkTextIter iter;
PsppireSyntaxWindow *sw = PSPPIRE_SYNTAX_WINDOW (window);
- gchar *glibfilename = g_filename_from_utf8 (filename, -1, 0, 0, NULL);
-
- if ( ! glibfilename )
- return FALSE;
-
/* FIXME: What if it's a very big file ? */
- if ( ! g_file_get_contents (glibfilename, &text, NULL, NULL) )
- {
- g_free (glibfilename);
- return FALSE;
- }
-
- g_free (glibfilename);
+ if ( ! g_file_get_contents (filename, &text, NULL, NULL) )
+ return FALSE;
gtk_text_buffer_get_iter_at_line (sw->buffer, &iter, 0);
gtk_text_buffer_insert (sw->buffer, &iter, text, -1);
- psppire_window_set_filename (window, filename);
-
gtk_text_buffer_set_modified (sw->buffer, FALSE);
return TRUE;
candidate_name = uniquify (name, &x);
}
- window->basename = g_path_get_basename (candidate_name);
+ window->basename = g_filename_display_basename (candidate_name);
g_value_unset (&def);
}
static void
insert_menuitem_into_menu (PsppireWindow *window, gpointer key)
{
- GtkWidget *item = gtk_check_menu_item_new_with_label (key);
+ gchar *filename = g_filename_display_name (key);
+ GtkWidget *item = gtk_check_menu_item_new_with_label (filename);
+
+ g_free (filename);
g_signal_connect (item, "toggled", G_CALLBACK (menu_toggled), NULL);
g_signal_connect (item, "activate", G_CALLBACK (menu_activate), key);
if ( ok )
{
+ psppire_window_set_filename (w, file);
add_most_recent (file, the_recent_mgr);
w->dirty = FALSE;
}