[nautilus-actions] Try to target ideal size and position the first time we open the main window



commit dfc2bfedb4d9f4b6c1fd340f60edd2158af087f1
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Sep 11 22:24:14 2013 +0200

    Try to target ideal size and position the first time we open the main window

 ChangeLog               |    4 ++++
 src/core/na-gtk-utils.c |   37 +++++++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1399c26..db8c97a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-09-11 Pierre Wieser <pwieser trychlos org>
 
+       * src/core/na-gtk-utils.c (na_gtk_utils_restore_window_position):
+       Bad hack to try immediately target ideal size and position the first time
+       we open the main window.
+
        Only allow the 'About Nautilus-Actions...' item inside of the
        Nautilus-Actions root menu.
 
diff --git a/src/core/na-gtk-utils.c b/src/core/na-gtk-utils.c
index d225e7e..1b27e33 100644
--- a/src/core/na-gtk-utils.c
+++ b/src/core/na-gtk-utils.c
@@ -31,6 +31,7 @@
 #include <config.h>
 #endif
 
+#include <glib.h>
 #include <string.h>
 
 #include "na-gtk-utils.h"
@@ -158,22 +159,34 @@ na_gtk_utils_restore_window_position( GtkWindow *toplevel, const gchar *wsp_name
        width = MAX( 1, width );
        height = MAX( 1, height );
 
-       display = gdk_display_get_default();
-       screen = gdk_display_get_screen( display, 0 );
-       screen_width = gdk_screen_get_width( screen );
-       screen_height = gdk_screen_get_height( screen );
-
-       /* very dirty hack based on the assumption that Gnome 2.x has a bottom
-        * and a top panel bars, while Gnome 3.x only has one.
-        * Don't know how to get usable height of screen, and don't bother today.
+       /* bad hack for the first time we open the main window
+        * try to target an ideal size and position
         */
-       screen_height -= DEFAULT_HEIGHT;
+       if( !strcmp( wsp_name, NA_IPREFS_MAIN_WINDOW_WSP ) &&
+                       x == 1 && y == 1 && width == 1 && height == 1 ){
+                               x = 50;
+                               y = 70;
+                               width = 1030;
+                               height = 560;
+
+       } else {
+               display = gdk_display_get_default();
+               screen = gdk_display_get_screen( display, 0 );
+               screen_width = gdk_screen_get_width( screen );
+               screen_height = gdk_screen_get_height( screen );
+
+               /* very dirty hack based on the assumption that Gnome 2.x has a bottom
+                * and a top panel bars, while Gnome 3.x only has one.
+                * Don't know how to get usable height of screen, and don't bother today.
+                */
+               screen_height -= DEFAULT_HEIGHT;
 #if ! GTK_CHECK_VERSION( 3, 0, 0 )
-       screen_height -= DEFAULT_HEIGHT;
+               screen_height -= DEFAULT_HEIGHT;
 #endif
 
-       width = MIN( width, screen_width-x );
-       height = MIN( height, screen_height-y );
+               width = MAX( width, screen_width-x );
+               height = MAX( height, screen_height-y );
+       }
 
        g_debug( "%s: wsp_name=%s, screen=(%d,%d), x=%d, y=%d, width=%d, height=%d",
                        thisfn, wsp_name, screen_width, screen_height, x, y, width, height );


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]