[nautilus-actions] Reset window to default size when preferences exceed the screen size



commit 1ec51bc9afd79989d795d5308e29e4a805fc6350
Author: Pierre Wieser <pwieser trychlos org>
Date:   Fri Sep 25 09:07:58 2009 +0200

    Reset window to default size when preferences exceed the screen size

 ChangeLog              |    4 ++++
 src/nact/base-iprefs.c |   21 +++++++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b937c65..0f485d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
 	* data/nautilus-actions.schemas.in:
 	Defines a new key for the "import-mode" preference.
 
+	* src/nact/base-iprefs.c:
+	Reset default size of the window if recorded size and position
+	exceed current screen size.
+
 	* src/nact/nact-assistant-export.ui:
 	All titles are verbs.
 
diff --git a/src/nact/base-iprefs.c b/src/nact/base-iprefs.c
index 85bddaa..03e6706 100644
--- a/src/nact/base-iprefs.c
+++ b/src/nact/base-iprefs.c
@@ -193,12 +193,14 @@ void
 base_iprefs_position_window( BaseWindow *window )
 {
 	GtkWindow *toplevel;
-	gchar *key = v_iprefs_get_window_id( window );
+	gchar *key;
 
 	g_return_if_fail( BASE_IS_WINDOW( window ));
 	g_return_if_fail( BASE_IS_IPREFS( window ));
 
 	if( st_initialized && !st_finalized ){
+
+		key = v_iprefs_get_window_id( window );
 		if( key ){
 			toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
 			base_iprefs_position_named_window( window, toplevel, key );
@@ -214,7 +216,9 @@ base_iprefs_position_window( BaseWindow *window )
  * set.
  * @key: the string id of this toplevel.
  *
- * Positions the specified window on the screen.
+ * Positions the specified window on the screen, maximizing it by the
+ * actual current screen size. Note that this is a rough approximation
+ * as some of the screen is reserved by deskbars and so...
  */
 void
 base_iprefs_position_named_window( BaseWindow *window, GtkWindow *toplevel, const gchar *key )
@@ -222,6 +226,9 @@ base_iprefs_position_named_window( BaseWindow *window, GtkWindow *toplevel, cons
 	static const gchar *thisfn = "base_iprefs_position_named_window";
 	GSList *list;
 	gint x=0, y=0, width=0, height=0;
+	GdkDisplay *display;
+	GdkScreen *screen;
+	gint screen_width, screen_height;
 
 	g_return_if_fail( BASE_IS_WINDOW( window ));
 	g_return_if_fail( BASE_IS_IPREFS( window ));
@@ -235,6 +242,16 @@ base_iprefs_position_named_window( BaseWindow *window, GtkWindow *toplevel, cons
 			g_debug( "%s: key=%s, x=%d, y=%d, width=%d, height=%d", thisfn, key, x, y, width, height );
 			free_int_list( list );
 
+			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 );
+
+			if(( x+width > screen_width ) ||
+				( y+height > screen_height )){
+				gtk_window_get_default_size( toplevel, &width, &height );
+			}
+
 			gtk_window_move( toplevel, x, y );
 			gtk_window_resize( toplevel, width, height );
 		}



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