aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@novell.com>2010-03-18 08:07:24 +0800
committerFederico Mena Quintero <federico@novell.com>2010-03-23 04:07:22 +0800
commitc8ead63857d9bdd38d02ce031ea983a7a879295e (patch)
tree809197faa9bc7015f520569140201639c6584c85
parent00617a0d227b7f6274ab3bc825ff9183eae8dbd9 (diff)
downloadgsoc2013-evolution-c8ead63857d9bdd38d02ce031ea983a7a879295e.tar
gsoc2013-evolution-c8ead63857d9bdd38d02ce031ea983a7a879295e.tar.gz
gsoc2013-evolution-c8ead63857d9bdd38d02ce031ea983a7a879295e.tar.bz2
gsoc2013-evolution-c8ead63857d9bdd38d02ce031ea983a7a879295e.tar.lz
gsoc2013-evolution-c8ead63857d9bdd38d02ce031ea983a7a879295e.tar.xz
gsoc2013-evolution-c8ead63857d9bdd38d02ce031ea983a7a879295e.tar.zst
gsoc2013-evolution-c8ead63857d9bdd38d02ce031ea983a7a879295e.zip
Start the mailer's folder sidebar with a reasonable width
We do this by measuring a template string, which contains a sample name for an email account. This is what normally gets displayed in the folder tree, so such a sample string should give a reasonable width. Signed-off-by: Federico Mena Quintero <federico@novell.com>
-rw-r--r--modules/mail/e-mail-shell-sidebar.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/modules/mail/e-mail-shell-sidebar.c b/modules/mail/e-mail-shell-sidebar.c
index 70b59ad40a..1b55f0524f 100644
--- a/modules/mail/e-mail-shell-sidebar.c
+++ b/modules/mail/e-mail-shell-sidebar.c
@@ -178,6 +178,39 @@ mail_shell_sidebar_constructed (GObject *object)
shell_sidebar);
}
+static void
+mail_shell_sidebar_size_request (GtkWidget *widget, GtkRequisition *requisition)
+{
+ /* We override the normal size-request handler so that we can
+ * spit out a treeview with a suitable width. We measure the length
+ * of a typical string and use that as the requisition's width.
+ *
+ * EMFolderTreeClass, our parent class, is based on GtkTreeView, which
+ * doesn't really have a good way of figuring out a minimum width for
+ * the tree. This is really GTK+'s fault at large, as it only has
+ * "minimum size / allocated size", instead of "minimum size / preferred
+ * size / allocated size". Hopefully the extended-layout branch of GTK+
+ * will get merged soon and then we can remove this crap.
+ */
+
+ PangoLayout *layout;
+ PangoRectangle ink_rect;
+ GtkStyle *style;
+ int border;
+
+ GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
+
+ /* This string is a mockup only; it doesn't need to be translated */
+ layout = gtk_widget_create_pango_layout (widget, "typical.account@mailservice.com");
+ pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
+ g_object_unref (layout);
+
+ style = gtk_widget_get_style (widget);
+
+ border = 2 * style->xthickness + 4; /* Thickness of frame shadow plus some slack for padding */
+ requisition->width = MAX (requisition->width, ink_rect.width + border);
+}
+
static guint32
mail_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
{
@@ -194,6 +227,7 @@ static void
mail_shell_sidebar_class_init (EMailShellSidebarClass *class)
{
GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
EShellSidebarClass *shell_sidebar_class;
parent_class = g_type_class_peek_parent (class);
@@ -204,6 +238,9 @@ mail_shell_sidebar_class_init (EMailShellSidebarClass *class)
object_class->dispose = mail_shell_sidebar_dispose;
object_class->constructed = mail_shell_sidebar_constructed;
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->size_request = mail_shell_sidebar_size_request;
+
shell_sidebar_class = E_SHELL_SIDEBAR_CLASS (class);
shell_sidebar_class->check_state = mail_shell_sidebar_check_state;