X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-window.c;h=edaa372670755020b0cfc9594e8cb0c6d5fde3db;hb=refs%2Fbuilds%2F20110525030502%2Fpspp;hp=fbb91a78cc0f4edd45cacb5c83a56f3fe2de2343;hpb=21563eaa0213cd007c660324f0364327d362cd78;p=pspp diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index fbb91a78cc..edaa372670 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -33,6 +33,7 @@ #include "helper.h" #include "psppire-conf.h" #include "psppire-data-window.h" +#include "psppire-encoding-selector.h" #include "psppire-syntax-window.h" #include "psppire-window-register.h" #include "psppire.h" @@ -691,8 +692,6 @@ psppire_window_save_as (PsppireWindow *w) } } - -static void add_most_recent (const char *file_name); static void delete_recent (const char *file_name); gboolean @@ -712,7 +711,6 @@ psppire_window_load (PsppireWindow *w, const gchar *file) if ( ok ) { psppire_window_set_filename (w, file); - add_most_recent (file); w->dirty = FALSE; } else @@ -788,6 +786,9 @@ 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)); + return dialog; } @@ -807,11 +808,15 @@ psppire_window_open (PsppireWindow *de) gchar *sysname = convert_glib_filename_to_system_filename (name, NULL); + gchar *encoding = psppire_encoding_selector_get_encoding ( + gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (dialog))); + if (any_reader_may_open (sysname)) open_data_window (de, name); else - open_syntax_window (name); + open_syntax_window (name, encoding); + g_free (encoding); g_free (sysname); g_free (name); } @@ -824,16 +829,31 @@ psppire_window_open (PsppireWindow *de) } -/* Puts FILE_NAME into the recent list. - If it's already in the list, it moves it to the top -*/ -static void -add_most_recent (const char *file_name) +/* Puts FILE_NAME (encoded in the glib file name encoding) into the recent list + with associated MIME_TYPE. If it's already in the list, it moves it to the + top. */ +void +add_most_recent (const char *file_name, const char *mime_type) { gchar *uri = g_filename_to_uri (file_name, NULL, NULL); if ( uri ) - gtk_recent_manager_add_item (gtk_recent_manager_get_default (), uri); + { + GtkRecentData recent_data; + + recent_data.display_name = NULL; + recent_data.description = NULL; + recent_data.mime_type = CONST_CAST (gchar *, mime_type); + recent_data.app_name = CONST_CAST (gchar *, g_get_application_name ()); + recent_data.app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL); + recent_data.groups = NULL; + recent_data.is_private = FALSE; + + gtk_recent_manager_add_full (gtk_recent_manager_get_default (), + uri, &recent_data); + + g_free (recent_data.app_exec); + } g_free (uri); }