]> www.fi.muni.cz Git - evince.git/commitdiff
Remember window position and maximized state
authorMarco Pesenti Gritti <mpg@redhat.com>
Wed, 6 Jul 2005 12:21:08 +0000 (12:21 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Wed, 6 Jul 2005 12:21:08 +0000 (12:21 +0000)
2005-07-06  Marco Pesenti Gritti  <mpg@redhat.com>

        * shell/ev-window.c: (setup_view_from_metadata),
        (window_state_event_cb), (window_configure_event_cb),
        (ev_window_init):

        Remember window position and maximized state

ChangeLog
shell/ev-window.c

index 76c3db4753ab3994cbf6ccb297f277c517832a7b..8d35f09c23a531efbf50f1a827d5f92bf33241c5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-07-06  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * shell/ev-window.c: (setup_view_from_metadata),
+       (window_state_event_cb), (window_configure_event_cb),
+       (ev_window_init):
+
+       Remember window position and maximized state
+
 2005-07-06  Christian Persch  <chpe@cvs.gnome.org>
 
        * configure.ac:
@@ -18,7 +26,7 @@
 
        Fix the build without DBUS.
 
-2005-07-06  Marco Pesenti Gritti  <set EMAIL_ADDRESS environment variable>
+2005-07-06  Marco Pesenti Gritti  <mpg@redhat.com>
 
        * shell/ev-metadata-manager.c: (parse_value), (save_values),
        (ev_metadata_manager_set_int), (ev_metadata_manager_set_double),
index 4aef9afc62f339a8b7d83968098a12259cbf68c5..d7bfa777defd6666ecc81671b502156445850df6 100644 (file)
@@ -944,6 +944,9 @@ setup_view_from_metadata (EvWindow *window)
        GEnumValue *enum_value;
        GValue width = { 0, };
        GValue height = { 0, };
+       GValue maximized = { 0, };
+       GValue x = { 0, };
+       GValue y = { 0, };
        GValue sizing_mode = { 0, };
        GValue zoom = { 0, };
        GValue continuous = { 0, };
@@ -952,11 +955,22 @@ setup_view_from_metadata (EvWindow *window)
        GValue fullscreen = { 0, };
 
        /* Window size */
-       if (ev_metadata_manager_get (uri, "window_width", &width) &&
-           ev_metadata_manager_get (uri, "window_height", &height)) {
-               gtk_window_set_default_size (GTK_WINDOW (window),
-                                            g_value_get_int (&width),
-                                            g_value_get_int (&height));
+       if (ev_metadata_manager_get (uri, "window_maximized", &maximized)) {
+               if (g_value_get_boolean (&maximized) && !GTK_WIDGET_VISIBLE (window)) {
+                       gtk_window_maximize (GTK_WINDOW (window));
+               }
+
+               if (!g_value_get_boolean (&maximized) &&
+                   ev_metadata_manager_get (uri, "window_x", &x) &&
+                   ev_metadata_manager_get (uri, "window_y", &y) &&
+                   ev_metadata_manager_get (uri, "window_width", &width) &&
+                   ev_metadata_manager_get (uri, "window_height", &height)) {
+                       gtk_window_set_default_size (GTK_WINDOW (window),
+                                                    g_value_get_int (&width),
+                                                    g_value_get_int (&height));
+                       gtk_window_move (GTK_WINDOW (window), g_value_get_int (&x),
+                                        g_value_get_int (&y));
+               }
        }
 
        /* Sizing mode */
@@ -3166,19 +3180,41 @@ sidebar_page_main_widget_update_cb (GObject *ev_sidebar_page,
 }
 
 static gboolean
-window_configure_event_cb (EvWindow *window, gpointer dummy)
+window_state_event_cb (EvWindow *window, GdkEventWindowState *event, gpointer dummy)
 {
 #ifdef ENABLE_METADATA
-       int width, height;
+       char *uri = window->priv->uri;
 
-       if (window->priv->uri == NULL) {
-               return FALSE;
+       if (uri && !(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
+               gboolean maximized;
+
+               maximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
+               ev_metadata_manager_set_boolean (uri, "window_maximized", maximized);
        }
+#endif
+
+       return FALSE;
+}
 
-       gtk_window_get_size (GTK_WINDOW (window), &width, &height);
+static gboolean
+window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer dummy)
+{
+#ifdef ENABLE_METADATA
+       char *uri = window->priv->uri;
+       GdkWindowState state;
+       int x, y, width, height;
+
+       state = gdk_window_get_state (GTK_WIDGET (window)->window);
 
-       ev_metadata_manager_set_int (window->priv->uri, "window_width", width);
-       ev_metadata_manager_set_int (window->priv->uri, "window_height", height);
+       if (uri && !(state & GDK_WINDOW_STATE_FULLSCREEN)) {
+               gtk_window_get_position (GTK_WINDOW (window), &x, &y);
+               gtk_window_get_size (GTK_WINDOW (window), &width, &height);
+
+               ev_metadata_manager_set_int (uri, "window_x", x);
+               ev_metadata_manager_set_int (uri, "window_y", y);
+               ev_metadata_manager_set_int (uri, "window_width", width);
+               ev_metadata_manager_set_int (uri, "window_height", height);
+       }
 #endif
 
        return FALSE;
@@ -3197,6 +3233,8 @@ ev_window_init (EvWindow *ev_window)
 
        g_signal_connect (ev_window, "configure_event",
                          G_CALLBACK (window_configure_event_cb), NULL);
+       g_signal_connect (ev_window, "window_state_event",
+                         G_CALLBACK (window_state_event_cb), NULL);
 
        ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);