X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-window.c;h=e03bd809ab03a97375c2a93f50f57cd6b4b5df6e;hb=917906bd153b0a915facd98ccf919db0150219f4;hp=628ed45cb2ec56426820edda1525600d6b1e9df9;hpb=c1c6d7c7e942d47f65b112fdd7cdc64361ef2ea4;p=pspp-builds.git diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index 628ed45c..e03bd809 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -16,6 +16,7 @@ #include + #include #include #include @@ -39,7 +40,6 @@ static void psppire_window_class_init (PsppireWindowClass *class); static void psppire_window_init (PsppireWindow *window); -static PsppireWindowClass *the_class; static GObjectClass *parent_class; GType @@ -97,7 +97,7 @@ psppire_window_set_title (PsppireWindow *window) window->basename ? window->basename : "", mdash, window->description); - if ( window->unsaved) + if (window->unsaved) g_string_prepend_c (title, '*'); gtk_window_set_title (GTK_WINDOW (window), title->str); @@ -271,7 +271,6 @@ psppire_window_class_init (PsppireWindowClass *class) PROP_FILENAME, filename_spec); - the_class = class; parent_class = g_type_class_peek_parent (class); } @@ -497,9 +496,9 @@ psppire_window_set_filename (PsppireWindow *w, const gchar *filename) } void -psppire_window_set_unsaved (PsppireWindow *w, gboolean unsaved) +psppire_window_set_unsaved (PsppireWindow *w) { - w->unsaved = unsaved; + w->unsaved = TRUE; psppire_window_set_title (w); } @@ -577,11 +576,43 @@ psppire_window_save (PsppireWindow *w) i->save (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); + +gboolean +psppire_window_load (PsppireWindow *w, const gchar *file) +{ + gboolean ok; + PsppireWindowIface *i = PSPPIRE_WINDOW_MODEL_GET_IFACE (w); + + g_assert (PSPPIRE_IS_WINDOW_MODEL (w)); + + g_assert (i); + + g_return_val_if_fail (i->load, FALSE); + + ok = i->load (w, file); + + if ( ok ) + { + add_most_recent (file, the_recent_mgr); + w->unsaved = FALSE; + } + else + delete_recent (file, the_recent_mgr); + + psppire_window_set_title (w); + + return ok; +} + /* Puts FILE_NAME into the recent list. If it's already in the list, it moves it to the top */ -void +static void add_most_recent (const char *file_name, GtkRecentManager *rm) { gchar *uri = g_filename_to_uri (file_name, NULL, NULL); @@ -592,3 +623,20 @@ add_most_recent (const char *file_name, GtkRecentManager *rm) g_free (uri); } + + +/* + If FILE_NAME exists in the recent list, then delete it. + */ +static void +delete_recent (const char *file_name, GtkRecentManager *rm) +{ + gchar *uri = g_filename_to_uri (file_name, NULL, NULL); + + if ( uri ) + gtk_recent_manager_remove_item (rm, uri, NULL); + + g_free (uri); + +} +