[evolution/gnome-3-6] Bug #267787 - Preferences too large for small screens



commit 35ca2c6284df0e3479d83542350ce349c12eebb1
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 29 19:39:20 2012 +0100

    Bug #267787 - Preferences too large for small screens

 widgets/misc/e-preferences-window.c |   58 ++++++++++++++++++++++++++++++++++-
 1 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/widgets/misc/e-preferences-window.c b/widgets/misc/e-preferences-window.c
index 722ee23..741cd74 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;
 }



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