Set the proper screen size of ModestShell window
authorSergio Villar Senín <svillar@igalia.com>
Thu, 11 Feb 2010 11:38:19 +0000 (12:38 +0100)
committerSergio Villar Senín <svillar@igalia.com>
Fri, 12 Feb 2010 17:21:19 +0000 (18:21 +0100)
src/gtk/modest-shell.c

index c506ec6..a9a296e 100644 (file)
 #include <modest-ui-actions.h>
 #include <modest-gtk-window-mgr.h>
 #include <modest-runtime.h>
+#include <X11/Xutil.h>
+
+#define SCN_WIDTH  1024
+#define SCN_HEIGHT 600
 
 /* 'private'/'protected' functions */
 static void modest_shell_class_init (ModestShellClass *klass);
@@ -121,6 +125,26 @@ modest_shell_class_init (ModestShellClass *klass)
 }
 
 static void
+set_screen_size (GtkWindow *self)
+{
+       /* Get screen dimensions */
+       Screen *screen = XDefaultScreenOfDisplay(XOpenDisplay(NULL));
+       int scn_width = XWidthOfScreen(screen);
+       int scn_height = XHeightOfScreen(screen);
+
+       /* if screensize is larger than netbook size, show in window, else fullscreen */
+       if (scn_width > SCN_WIDTH || scn_height > SCN_HEIGHT) {
+               scn_width = SCN_WIDTH;
+               scn_height = SCN_HEIGHT;
+               gtk_window_resize (self, scn_width, scn_height);
+       } else {
+               gtk_window_fullscreen (self);
+               /* Very important for Moblin */
+               gtk_window_set_decorated (self, FALSE);
+       }
+}
+
+static void
 modest_shell_instance_init (ModestShell *obj)
 {
        ModestShellPrivate *priv;
@@ -237,10 +261,7 @@ modest_shell_instance_init (ModestShell *obj)
                          "key-press-event", 
                          G_CALLBACK (on_key_pressed), obj);
 
-       gtk_window_set_default_size (GTK_WINDOW (obj), 
-                                    640, 480);
-
-
+       set_screen_size ((GtkWindow *) obj);
 }
 
 static void