aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-editor/e-contact-editor.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-10-30 05:53:15 +0800
committerMilan Crha <mcrha@redhat.com>2012-10-30 05:53:15 +0800
commite1807b3155ee48635387efd0b2afd2f98f3b48b7 (patch)
tree48361ae9012f67a8710dd5006af855b0c01bc768 /addressbook/gui/contact-editor/e-contact-editor.c
parent354794e33714b149635538913a7ac7251a18e7dd (diff)
downloadgsoc2013-evolution-e1807b3155ee48635387efd0b2afd2f98f3b48b7.tar
gsoc2013-evolution-e1807b3155ee48635387efd0b2afd2f98f3b48b7.tar.gz
gsoc2013-evolution-e1807b3155ee48635387efd0b2afd2f98f3b48b7.tar.bz2
gsoc2013-evolution-e1807b3155ee48635387efd0b2afd2f98f3b48b7.tar.lz
gsoc2013-evolution-e1807b3155ee48635387efd0b2afd2f98f3b48b7.tar.xz
gsoc2013-evolution-e1807b3155ee48635387efd0b2afd2f98f3b48b7.tar.zst
gsoc2013-evolution-e1807b3155ee48635387efd0b2afd2f98f3b48b7.zip
Bug #317153 - Contact editor too large for small screens
Diffstat (limited to 'addressbook/gui/contact-editor/e-contact-editor.c')
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c53
1 files changed, 46 insertions, 7 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index ca4b1cb86c..d2111f0def 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