[nautilus-actions] src/nact/base-gtk-utils.c: limit window size to usable screen
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] src/nact/base-gtk-utils.c: limit window size to usable screen
- Date: Sun, 27 Nov 2011 19:59:02 +0000 (UTC)
commit 7e97d421438512a0a4b426a1d715095b589abdc6
Author: Pierre Wieser <pwieser trychlos org>
Date: Sun Nov 27 20:58:08 2011 +0100
src/nact/base-gtk-utils.c: limit window size to usable screen
ChangeLog | 3 +++
src/nact/base-gtk-utils.c | 38 +++++++++++++++++++++++++++-----------
2 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7261061..2e86738 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2011-11-27 Pierre Wieser <pwieser trychlos org>
+ * src/nact/base-gtk-utils.c (base_gtk_utils_restore_window_position):
+ Limit the window size, maximizing with the screen size.
+
* nact/nact-tree-view.h:
* nact/nact-tree-view.c: Define parent property.
diff --git a/src/nact/base-gtk-utils.c b/src/nact/base-gtk-utils.c
index 7cbeb66..67fbb50 100644
--- a/src/nact/base-gtk-utils.c
+++ b/src/nact/base-gtk-utils.c
@@ -87,17 +87,33 @@ base_gtk_utils_restore_window_position( const BaseWindow *window, const gchar *w
free_int_list( list );
}
- if( width > 0 && height > 0 ){
- 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_move( toplevel, x, y );
- gtk_window_resize( toplevel, width, height );
- }
- }
+ x = MAX( 1, x );
+ y = MAX( 1, y );
+ 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.
+ */
+ screen_height -= DEFAULT_HEIGHT;
+#if ! GTK_CHECK_VERSION( 3, 0, 0 )
+ screen_height -= DEFAULT_HEIGHT;
+#endif
+
+ width = MIN( width, screen_width-x );
+ height = MIN( 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 );
+
+ 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]