diff options
author | Gustavo Noronha Silva <gustavo.noronha@collabora.com> | 2011-06-21 20:53:55 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:34 +0800 |
commit | ad593d8365ec053bc2f421aeeaa6d3de292f33e6 (patch) | |
tree | a3b29cae414539b85237044252a5b76feb09c525 /mail/e-mail-notebook-view.c | |
parent | 76ee6f3e7fe18a6bc17276cbb58828d7834ccf80 (diff) | |
download | gsoc2013-evolution-ad593d8365ec053bc2f421aeeaa6d3de292f33e6.tar gsoc2013-evolution-ad593d8365ec053bc2f421aeeaa6d3de292f33e6.tar.gz gsoc2013-evolution-ad593d8365ec053bc2f421aeeaa6d3de292f33e6.tar.bz2 gsoc2013-evolution-ad593d8365ec053bc2f421aeeaa6d3de292f33e6.tar.lz gsoc2013-evolution-ad593d8365ec053bc2f421aeeaa6d3de292f33e6.tar.xz gsoc2013-evolution-ad593d8365ec053bc2f421aeeaa6d3de292f33e6.tar.zst gsoc2013-evolution-ad593d8365ec053bc2f421aeeaa6d3de292f33e6.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.c | 41 |
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 ( |