[evolution] Bug #317153 - Contact editor too large for small screens



commit e1807b3155ee48635387efd0b2afd2f98f3b48b7
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 29 22:53:15 2012 +0100

    Bug #317153 - Contact editor too large for small screens

 addressbook/gui/contact-editor/contact-editor.ui  |   28 +++++++++--
 addressbook/gui/contact-editor/e-contact-editor.c |   53 ++++++++++++++++++---
 2 files changed, 70 insertions(+), 11 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/contact-editor.ui b/addressbook/gui/contact-editor/contact-editor.ui
index 3f5b1f6..939b7c6 100644
--- a/addressbook/gui/contact-editor/contact-editor.ui
+++ b/addressbook/gui/contact-editor/contact-editor.ui
@@ -82,12 +82,15 @@
               <object class="GtkScrolledWindow" id="scrolledwindow1">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">never</property>
+                <property name="hscrollbar_policy">automatic</property>
                 <property name="vscrollbar_policy">automatic</property>
+                <property name="min-content-width">320</property>
+                <property name="min-content-height">240</property>
                 <child>
                   <object class="GtkViewport" id="viewport1">
                     <property name="visible">True</property>
                     <property name="resize_mode">queue</property>
+                    <property name="shadow-type">none</property>
                     <child>
                       <object class="GtkVBox" id="vbox33">
                         <property name="visible">True</property>
@@ -813,6 +816,8 @@
                                       <packing>
                                         <property name="left_attach">1</property>
                                         <property name="right_attach">2</property>
+                                        <property name="top_attach">0</property>
+                                        <property name="bottom_attach">1</property>
                                         <property name="y_options"></property>
                                       </packing>
                                     </child>
@@ -837,6 +842,8 @@
                                       <packing>
                                         <property name="left_attach">3</property>
                                         <property name="right_attach">4</property>
+                                        <property name="top_attach">0</property>
+                                        <property name="bottom_attach">1</property>
                                         <property name="y_options"></property>
                                       </packing>
                                     </child>
@@ -858,6 +865,10 @@
                                         <property name="visible">True</property>
                                       </object>
                                       <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="right_attach">1</property>
+                                        <property name="top_attach">0</property>
+                                        <property name="bottom_attach">1</property>
                                         <property name="x_options">GTK_FILL</property>
                                         <property name="y_options">GTK_FILL</property>
                                       </packing>
@@ -867,6 +878,8 @@
                                         <property name="visible">True</property>
                                       </object>
                                       <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="right_attach">1</property>
                                         <property name="top_attach">1</property>
                                         <property name="bottom_attach">2</property>
                                         <property name="x_options">GTK_FILL</property>
@@ -880,6 +893,8 @@
                                       <packing>
                                         <property name="left_attach">2</property>
                                         <property name="right_attach">3</property>
+                                        <property name="top_attach">0</property>
+                                        <property name="bottom_attach">1</property>
                                         <property name="x_options">GTK_FILL</property>
                                         <property name="y_options">GTK_FILL</property>
                                       </packing>
@@ -938,11 +953,14 @@
               <object class="GtkScrolledWindow" id="scrolledwindow-size-leader">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">never</property>
+                <property name="hscrollbar_policy">automatic</property>
                 <property name="vscrollbar_policy">automatic</property>
+                <property name="min-content-width">320</property>
+                <property name="min-content-height">240</property>
                 <child>
                   <object class="GtkViewport" id="viewport2">
                     <property name="visible">True</property>
+                    <property name="shadow-type">none</property>
                     <property name="resize_mode">queue</property>
                     <child>
                       <object class="GtkVBox" id="vbox-size-leader">
@@ -1567,12 +1585,15 @@
               <object class="GtkScrolledWindow" id="scrolledwindow3">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">never</property>
+                <property name="hscrollbar_policy">automatic</property>
                 <property name="vscrollbar_policy">automatic</property>
+                <property name="min-content-width">320</property>
+                <property name="min-content-height">240</property>
                 <child>
                   <object class="GtkViewport" id="viewport3">
                     <property name="visible">True</property>
                     <property name="resize_mode">queue</property>
+                    <property name="shadow-type">none</property>
                     <child>
                       <object class="GtkVBox" id="vbox39">
                         <property name="visible">True</property>
@@ -2323,7 +2344,6 @@
             </child>
             <child>
               <object class="GtkScrolledWindow" id="scrolledwindow41">
-                <property name="height_request">38</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="border_width">12</property>
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index ca4b1cb..d2111f0 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -3026,7 +3026,9 @@ sensitize_all (EContactEditor *editor)
 static void
 init_all (EContactEditor *editor)
 {
-	GtkRequisition tab_req;
+	const gchar *contents[] = { "viewport1", "viewport2", "viewport3", "text-comments" };
+	gint ii;
+	GtkRequisition tab_req, requisition;
 	GtkWidget *widget;
 
 	init_simple   (editor);
@@ -3038,13 +3040,50 @@ init_all (EContactEditor *editor)
 
 	/* with so many scrolled windows, we need to
 	 * do some manual sizing */
-	widget = e_builder_get_widget (editor->builder, "vbox-size-leader");
-	gtk_widget_get_preferred_size (widget, &tab_req, NULL);
+	requisition.width = -1;
+	requisition.height = -1;
 
-	widget = e_builder_get_widget (
-		editor->builder, "scrolledwindow-size-leader"),
-	gtk_widget_set_size_request (
-		widget, tab_req.width, tab_req.height + 8);
+	for (ii = 0; ii < G_N_ELEMENTS (contents); ii++) {
+		widget = e_builder_get_widget (editor->builder, contents[ii]);
+
+		gtk_widget_get_preferred_size (widget, NULL, &tab_req);
+
+		if (tab_req.width > requisition.width)
+			requisition.width = tab_req.width;
+		if (tab_req.height > requisition.height)
+			requisition.height = tab_req.height;
+	}
+
+	if (requisition.width > 0 && requisition.height > 0) {
+		GtkWindow *window;
+		GdkScreen *screen;
+		GdkRectangle monitor_area;
+		gint x = 0, y = 0, monitor, width, height;
+
+		window = GTK_WINDOW (e_builder_get_widget (editor->builder, "contact editor"));
+
+		gtk_widget_get_preferred_size (GTK_WIDGET (window), &tab_req, NULL);
+		width = tab_req.width - 320 + 24;
+		height = tab_req.height - 240 + 24;
+
+		screen = gtk_window_get_screen (window);
+		gtk_window_get_position (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 (requisition.width > monitor_area.width - width)
+			requisition.width = monitor_area.width - width;
+
+		if (requisition.height > monitor_area.height - height)
+			requisition.height = monitor_area.height - height;
+
+		if (requisition.width > 0 && requisition.height > 0)
+			gtk_window_set_default_size (window, width + requisition.width, height + requisition.height);
+	}
 }
 
 static void



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