X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-window.c;h=54ece05de51b7386573d0179b8bca49f6f73ab25;hb=a70c4580757c19cd5054a470c2c5d497a1e71b4c;hp=f294364502aeccfe47409bb6c9b9ae390be077d9;hpb=b251c0a41e3825c4fdc873b975791b620850a90a;p=pspp-builds.git diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index f2943645..54ece05d 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -33,11 +33,11 @@ #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" -static void psppire_window_base_finalize (PsppireWindowClass *, gpointer); static void psppire_window_base_init (PsppireWindowClass *class); static void psppire_window_class_init (PsppireWindowClass *class); static void psppire_window_init (PsppireWindow *window); @@ -56,7 +56,7 @@ psppire_window_get_type (void) { sizeof (PsppireWindowClass), (GBaseInitFunc) psppire_window_base_init, - (GBaseFinalizeFunc) psppire_window_base_finalize, + (GBaseFinalizeFunc) NULL, (GClassInitFunc) psppire_window_class_init, (GClassFinalizeFunc) NULL, NULL, @@ -84,12 +84,6 @@ enum }; -gchar * -uniquify (const gchar *str, int *x) -{ - return g_strdup_printf ("%s%d", str, (*x)++); -} - static void psppire_window_set_title (PsppireWindow *window) { @@ -271,18 +265,6 @@ psppire_window_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } -static GParamSpec * -null_if_empty_param (const gchar *name, const gchar *nick, - const gchar *blurb, const gchar *default_value, - GParamFlags flags) -{ - GParamSpec *param; - - param = g_param_spec_string (name, nick, blurb, default_value, flags); - ((GParamSpecString *) param)->null_fold_if_empty = TRUE; - return param; -} - static void psppire_window_class_init (PsppireWindowClass *class) { @@ -339,12 +321,6 @@ psppire_window_base_init (PsppireWindowClass *class) -static void -psppire_window_base_finalize (PsppireWindowClass *class, - gpointer class_data) -{ -} - static void menu_toggled (GtkCheckMenuItem *mi, gpointer data) { @@ -703,10 +679,7 @@ psppire_window_save_as (PsppireWindow *w) } } -extern GtkRecentManager *the_recent_mgr; - -static void add_most_recent (const char *file_name, GtkRecentManager *rm); -static void delete_recent (const char *file_name, GtkRecentManager *rm); +static void delete_recent (const char *file_name); gboolean psppire_window_load (PsppireWindow *w, const gchar *file) @@ -725,11 +698,10 @@ psppire_window_load (PsppireWindow *w, const gchar *file) if ( ok ) { psppire_window_set_filename (w, file); - add_most_recent (file, the_recent_mgr); w->dirty = FALSE; } else - delete_recent (file, the_recent_mgr); + delete_recent (file); return ok; } @@ -801,6 +773,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; } @@ -820,22 +795,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)) - { - PsppireWindow *window; - - if (PSPPIRE_IS_DATA_WINDOW (de) - && psppire_data_window_is_empty (PSPPIRE_DATA_WINDOW (de))) - window = de; - else - window = PSPPIRE_WINDOW (psppire_data_window_new (NULL)); - - psppire_window_load (window, name); - gtk_widget_show (GTK_WIDGET (window)); - } + open_data_window (de, name); else - open_syntax_window (name); + open_syntax_window (name, encoding); + g_free (encoding); g_free (sysname); g_free (name); } @@ -848,16 +816,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, GtkRecentManager *rm) +/* 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 (rm, 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); } @@ -868,12 +851,12 @@ add_most_recent (const char *file_name, GtkRecentManager *rm) If FILE_NAME exists in the recent list, then delete it. */ static void -delete_recent (const char *file_name, GtkRecentManager *rm) +delete_recent (const char *file_name) { gchar *uri = g_filename_to_uri (file_name, NULL, NULL); if ( uri ) - gtk_recent_manager_remove_item (rm, uri, NULL); + gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, NULL); g_free (uri); }