aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-10-30 02:38:16 +0800
committerMilan Crha <mcrha@redhat.com>2012-10-30 02:38:16 +0800
commit354794e33714b149635538913a7ac7251a18e7dd (patch)
treed529dbb5a5c8e1f3b60c985bcfdfdf12cd7a7f4e /widgets
parentac5d61b687ab34dca5ab1b8e51fa14458ba87686 (diff)
downloadgsoc2013-evolution-354794e33714b149635538913a7ac7251a18e7dd.tar
gsoc2013-evolution-354794e33714b149635538913a7ac7251a18e7dd.tar.gz
gsoc2013-evolution-354794e33714b149635538913a7ac7251a18e7dd.tar.bz2
gsoc2013-evolution-354794e33714b149635538913a7ac7251a18e7dd.tar.lz
gsoc2013-evolution-354794e33714b149635538913a7ac7251a18e7dd.tar.xz
gsoc2013-evolution-354794e33714b149635538913a7ac7251a18e7dd.tar.zst
gsoc2013-evolution-354794e33714b149635538913a7ac7251a18e7dd.zip
Bug #267787 - Preferences too large for small screens
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-preferences-window.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/widgets/misc/e-preferences-window.c b/widgets/misc/e-preferences-window.c
index 722ee23c07..741cd74fd8 100644
--- a/widgets/misc/e-preferences-window.c
+++ b/widgets/misc/e-preferences-window.c
@@ -551,6 +551,8 @@ e_preferences_window_setup (EPreferencesWindow *window)
{
gint i, num;
GtkNotebook *notebook;
+ GtkRequisition requisition;
+ gint width = -1, height = -1, content_width = -1, content_height = -1;
EPreferencesWindowPrivate *priv;
g_return_if_fail (E_IS_PREFERENCES_WINDOW (window));
@@ -560,6 +562,14 @@ e_preferences_window_setup (EPreferencesWindow *window)
if (priv->setup)
return;
+ gtk_window_get_default_size (GTK_WINDOW (window), &width, &height);
+ if (width < 0 || height < 0) {
+ gtk_widget_get_preferred_size (GTK_WIDGET (window), &requisition, NULL);
+
+ width = requisition.width;
+ height = requisition.height;
+ }
+
notebook = GTK_NOTEBOOK (priv->notebook);
num = gtk_notebook_get_n_pages (notebook);
@@ -576,10 +586,56 @@ e_preferences_window_setup (EPreferencesWindow *window)
content = create_fn (window);
if (content) {
+ GtkScrolledWindow *scrolled;
+
+ scrolled = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
+ gtk_scrolled_window_add_with_viewport (scrolled, content);
+ gtk_scrolled_window_set_min_content_width (scrolled, 320);
+ gtk_scrolled_window_set_min_content_height (scrolled, 240);
+ gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (scrolled, GTK_SHADOW_NONE);
+
+ gtk_viewport_set_shadow_type (GTK_VIEWPORT (gtk_bin_get_child (GTK_BIN (scrolled))),
+ GTK_SHADOW_NONE);
+
gtk_widget_show (content);
- gtk_container_add (GTK_CONTAINER (align), content);
+
+ gtk_widget_get_preferred_size (GTK_WIDGET (content), &requisition, NULL);
+
+ if (requisition.width > content_width)
+ content_width = requisition.width;
+ if (requisition.height > content_height)
+ content_height = requisition.height;
+
+ gtk_widget_show (GTK_WIDGET (scrolled));
+
+ gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET (scrolled));
}
}
+ if (content_width > 0 && content_height > 0 && width > 0 && height > 0) {
+ GdkScreen *screen;
+ GdkRectangle monitor_area;
+ gint x = 0, y = 0, monitor;
+
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+ gtk_window_get_position (GTK_WINDOW (window), &x, &y);
+
+ monitor = gdk_screen_get_monitor_at_point (screen, x, y);
+ if (monitor < 0 || monitor >= gdk_screen_get_n_monitors (screen))
+ monitor = 0;
+
+ gdk_screen_get_monitor_workarea (screen, monitor, &monitor_area);
+
+ if (content_width > monitor_area.width - width)
+ content_width = monitor_area.width - width;
+
+ if (content_height > monitor_area.height - height)
+ content_height = monitor_area.height - height;
+
+ if (content_width > 0 && content_height > 0)
+ gtk_window_set_default_size (GTK_WINDOW (window), width + content_width, height + content_height);
+ }
+
priv->setup = TRUE;
}