aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mail
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@novell.com>2010-03-25 03:23:10 +0800
committerFederico Mena Quintero <federico@novell.com>2010-03-26 05:43:32 +0800
commit1457c12bb1aae829a67a754a3785a3654ed717c4 (patch)
treeeea182c546dd08b9d77ccc08c63eff1b1607ea97 /modules/mail
parent5c105c137f166922678cd7b48e9875ab7d56c9e0 (diff)
downloadgsoc2013-evolution-1457c12bb1aae829a67a754a3785a3654ed717c4.tar
gsoc2013-evolution-1457c12bb1aae829a67a754a3785a3654ed717c4.tar.gz
gsoc2013-evolution-1457c12bb1aae829a67a754a3785a3654ed717c4.tar.bz2
gsoc2013-evolution-1457c12bb1aae829a67a754a3785a3654ed717c4.tar.lz
gsoc2013-evolution-1457c12bb1aae829a67a754a3785a3654ed717c4.tar.xz
gsoc2013-evolution-1457c12bb1aae829a67a754a3785a3654ed717c4.tar.zst
gsoc2013-evolution-1457c12bb1aae829a67a754a3785a3654ed717c4.zip
Ensure that the width of the mail sidebar is not too wide
We just clamp this to one fourth of the screen's width; we do some voodoo to guess the monitor we are in. Signed-off-by: Federico Mena Quintero <federico@novell.com>
Diffstat (limited to 'modules/mail')
-rw-r--r--modules/mail/e-mail-shell-sidebar.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/modules/mail/e-mail-shell-sidebar.c b/modules/mail/e-mail-shell-sidebar.c
index 1b55f0524f..42376ca52a 100644
--- a/modules/mail/e-mail-shell-sidebar.c
+++ b/modules/mail/e-mail-shell-sidebar.c
@@ -178,6 +178,44 @@ mail_shell_sidebar_constructed (GObject *object)
shell_sidebar);
}
+static int
+guess_screen_width (EMailShellSidebar *sidebar)
+{
+ GtkWidget *widget;
+ GdkScreen *screen;
+ int screen_width;
+
+ widget = GTK_WIDGET (sidebar);
+
+ screen_width = 0;
+
+ screen = gtk_widget_get_screen (widget);
+ if (screen) {
+ GtkWidget *toplevel;
+ int monitor;
+ GdkRectangle rect;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (toplevel && GTK_WIDGET_REALIZED (toplevel))
+ monitor = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (toplevel));
+ else {
+ /* We don't know in which monitor the window manager
+ * will put us. So we will just use the geometry of the
+ * first monitor.
+ */
+ monitor = 0;
+ }
+
+ gdk_screen_get_monitor_geometry (screen, monitor, &rect);
+ screen_width = rect.width;
+ }
+
+ if (screen_width == 0)
+ screen_width = 1024;
+
+ return screen_width;
+}
+
static void
mail_shell_sidebar_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
@@ -193,10 +231,15 @@ mail_shell_sidebar_size_request (GtkWidget *widget, GtkRequisition *requisition)
* will get merged soon and then we can remove this crap.
*/
+ EMailShellSidebar *sidebar;
PangoLayout *layout;
PangoRectangle ink_rect;
GtkStyle *style;
int border;
+ int sidebar_width;
+ int screen_width;
+
+ sidebar = E_MAIL_SHELL_SIDEBAR (widget);
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
@@ -207,8 +250,12 @@ mail_shell_sidebar_size_request (GtkWidget *widget, GtkRequisition *requisition)
style = gtk_widget_get_style (widget);
+ screen_width = guess_screen_width (sidebar);
+
border = 2 * style->xthickness + 4; /* Thickness of frame shadow plus some slack for padding */
- requisition->width = MAX (requisition->width, ink_rect.width + border);
+ sidebar_width = ink_rect.width + border;
+ sidebar_width = MIN (sidebar_width, screen_width / 4);
+ requisition->width = MAX (requisition->width, sidebar_width);
}
static guint32