aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-notebook-view.c
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gustavo.noronha@collabora.com>2011-06-21 20:53:55 +0800
committerGustavo Noronha Silva <gustavo.noronha@collabora.com>2011-06-28 02:38:05 +0800
commit1fe3a4c564c9d28a9291c2cbc0dbbb97f2140a01 (patch)
tree8e71c517cc1c20cc8ec9911dca5544cb947e5490 /mail/e-mail-notebook-view.c
parent1dee8198ac409e65a588557ce7c3c7b71bedb68c (diff)
downloadgsoc2013-evolution-1fe3a4c564c9d28a9291c2cbc0dbbb97f2140a01.tar
gsoc2013-evolution-1fe3a4c564c9d28a9291c2cbc0dbbb97f2140a01.tar.gz
gsoc2013-evolution-1fe3a4c564c9d28a9291c2cbc0dbbb97f2140a01.tar.bz2
gsoc2013-evolution-1fe3a4c564c9d28a9291c2cbc0dbbb97f2140a01.tar.lz
gsoc2013-evolution-1fe3a4c564c9d28a9291c2cbc0dbbb97f2140a01.tar.xz
gsoc2013-evolution-1fe3a4c564c9d28a9291c2cbc0dbbb97f2140a01.tar.zst
gsoc2013-evolution-1fe3a4c564c9d28a9291c2cbc0dbbb97f2140a01.zip
Limit the size of tab labels to a reasonable size
We use half the size allocated to the whole view as a reference, and force the label to be at most that size, taking advantage of ellipsis otherwise. Notice that we also force the natural size as the requested size if it is not too big as well, because labels ellipsisized using the minimum size usually, which is undesired. This is a fix for https://bugs.meego.com/show_bug.cgi?id=18313
Diffstat (limited to 'mail/e-mail-notebook-view.c')
-rw-r--r--mail/e-mail-notebook-view.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c
index 544902d964..c4e0ed3fd1 100644
--- a/mail/e-mail-notebook-view.c
+++ b/mail/e-mail-notebook-view.c
@@ -368,21 +368,62 @@ tab_remove_gtk_cb (GtkWidget *button,
}
+static void
+adjust_label_size_request (GtkWidget *view,
+ GtkAllocation *allocation,
+ GtkWidget *label)
+{
+ GtkRequisition requisition;
+ int max_width = allocation->width / 2;
+
+ /* We make sure the label is not over-ellipisized, but doesn't
+ * get too big to cause the tab to not fit either. */
+ gtk_widget_get_preferred_size (label, NULL, &requisition);
+ if (requisition.width < max_width)
+ gtk_widget_set_size_request (label, requisition.width, -1);
+ else
+ gtk_widget_set_size_request (label, max_width, -1);
+}
+
+static void
+disconnect_label_adjusting (EMailNotebookView *view,
+ GtkWidget *label)
+{
+ g_signal_handlers_disconnect_by_func (
+ view,
+ adjust_label_size_request,
+ label);
+}
+
static GtkWidget *
create_tab_label (EMailNotebookView *view,
EMailView *page,
const gchar *str)
{
GtkWidget *container, *widget;
+ GtkAllocation allocation;
widget = gtk_hbox_new (FALSE, 0);
gtk_widget_show (widget);
container = widget;
widget = gtk_label_new (str);
+ gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
gtk_widget_show (widget);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, FALSE, 0);
+ gtk_widget_get_allocation (GTK_WIDGET (view), &allocation);
+ adjust_label_size_request (GTK_WIDGET (view), &allocation, widget);
+
+ g_signal_connect (
+ view, "size-allocate",
+ G_CALLBACK (adjust_label_size_request), widget);
+
+ g_object_weak_ref (
+ G_OBJECT (widget),
+ (GWeakNotify) disconnect_label_adjusting,
+ view);
+
widget = gtk_button_new ();
gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
gtk_button_set_image (