X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-window.c;h=f0d6d9162968f27c89576fc4d405b8d719898702;hb=d112adc6bdbab5593d533fdc8853e80a2cb358e7;hp=b7529ed06f1fdaf7bb32c5e3d2cc8a7297d6ad12;hpb=ca259adce7a069f58545de7511e17d73c9e0a868;p=pspp-builds.git diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index b7529ed0..f0d6d916 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -16,11 +16,13 @@ #include + #include #include #include #include #include +#include #include @@ -30,6 +32,7 @@ #include "psppire-window.h" #include "psppire-window-register.h" +#include "psppire-conf.h" static void psppire_window_base_finalize (PsppireWindowClass *, gpointer); static void psppire_window_base_init (PsppireWindowClass *class); @@ -189,6 +192,29 @@ psppire_window_get_property (GObject *object, } +static void +on_realize (GtkWindow *window, gpointer data) +{ + PsppireConf *conf = psppire_conf_new (); + + const gchar *base = G_OBJECT_TYPE_NAME (window); + + psppire_conf_set_window_geometry (conf, base, window); +} + + +static gboolean +on_configure (GtkWidget *window, GdkEventConfigure *event, gpointer data) +{ + const gchar *base = G_OBJECT_TYPE_NAME (window); + + PsppireConf *conf = psppire_conf_new (); + + psppire_conf_save_window_geometry (conf, base, event); + + return FALSE; +} + static void psppire_window_finalize (GObject *object) @@ -401,6 +427,12 @@ psppire_window_init (PsppireWindow *window) g_object_set (window, "icon-name", "psppicon", NULL); + g_signal_connect (window, "configure-event", + G_CALLBACK (on_configure), window); + + g_signal_connect (window, "realize", + G_CALLBACK (on_realize), window); + } @@ -545,3 +577,65 @@ 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); + else + delete_recent (file, the_recent_mgr); + + psppire_window_set_unsaved (w, FALSE); + + return ok; +} + + +/* 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) +{ + gchar *uri = g_filename_to_uri (file_name, NULL, NULL); + + if ( uri ) + gtk_recent_manager_add_item (rm, uri); + + 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); + +} +