Ellipsize tab labels differently to emphasize subtitles
This commit is contained in:
parent
a582d8dcc0
commit
8588c3b43f
1 changed files with 20 additions and 1 deletions
|
@ -1558,6 +1558,24 @@ midori_view_set_property (GObject* object,
|
||||||
#define title midori_view_get_display_title (view)
|
#define title midori_view_get_display_title (view)
|
||||||
if (view->tab_label)
|
if (view->tab_label)
|
||||||
{
|
{
|
||||||
|
/* If the title starts with the presumed name of the website, we
|
||||||
|
ellipsize differently, to emphasize the subtitle */
|
||||||
|
if (gtk_label_get_angle (GTK_LABEL (view->tab_title)) == 0.0)
|
||||||
|
{
|
||||||
|
SoupURI* uri = soup_uri_new (view->uri);
|
||||||
|
const gchar* host = uri ? (uri->host ? uri->host : "") : "";
|
||||||
|
const gchar* name = g_str_has_prefix (host, "www.") ? &host[4] : host;
|
||||||
|
guint i = 0;
|
||||||
|
while (name[i++])
|
||||||
|
if (name[i] == '.')
|
||||||
|
break;
|
||||||
|
if (!g_ascii_strncasecmp (title, name, i))
|
||||||
|
gtk_label_set_ellipsize (GTK_LABEL (view->tab_title), PANGO_ELLIPSIZE_START);
|
||||||
|
else
|
||||||
|
gtk_label_set_ellipsize (GTK_LABEL (view->tab_title), PANGO_ELLIPSIZE_END);
|
||||||
|
if (uri)
|
||||||
|
soup_uri_free (uri);
|
||||||
|
}
|
||||||
gtk_label_set_text (GTK_LABEL (view->tab_title), title);
|
gtk_label_set_text (GTK_LABEL (view->tab_title), title);
|
||||||
gtk_widget_set_tooltip_text (view->tab_title, title);
|
gtk_widget_set_tooltip_text (view->tab_title, title);
|
||||||
}
|
}
|
||||||
|
@ -2381,6 +2399,7 @@ midori_view_update_tab_title (GtkWidget* label,
|
||||||
if (angle == 0.0 || angle == 360.0)
|
if (angle == 0.0 || angle == 360.0)
|
||||||
{
|
{
|
||||||
gtk_widget_set_size_request (label, width * size, -1);
|
gtk_widget_set_size_request (label, width * size, -1);
|
||||||
|
if (gtk_label_get_ellipsize (GTK_LABEL (label)) != PANGO_ELLIPSIZE_START)
|
||||||
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
|
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue