Do not try to compute a tab colour unless it's a proper URI

This commit is contained in:
Christian Dywan 2009-03-23 19:27:35 +01:00
parent 350dbe5e07
commit 637388a8de

View file

@ -45,22 +45,29 @@ colorful_tabs_view_notify_uri_cb (MidoriView* view,
dark, we lighten it up a litte. Finally we make the event box dark, we lighten it up a litte. Finally we make the event box
visible and modify its background. */ visible and modify its background. */
uri = soup_uri_new (midori_view_get_display_uri (view)); if ((uri = soup_uri_new (midori_view_get_display_uri (view))))
hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri->host, -1); {
soup_uri_free (uri); hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri->host, -1);
colorstr = g_strndup (hash, 6 + 1); soup_uri_free (uri);
g_free (hash); colorstr = g_strndup (hash, 6 + 1);
colorstr[0] = '#'; g_free (hash);
gdk_color_parse (colorstr, &color); colorstr[0] = '#';
if (color.red < 35000) gdk_color_parse (colorstr, &color);
color.red += 25000 + (color.blue + 1) / 2; if (color.red < 35000)
if (color.green < 35000) color.red += 25000 + (color.blue + 1) / 2;
color.green += 25000 + (color.red + 1) / 2; if (color.green < 35000)
if (color.blue < 35000) color.green += 25000 + (color.red + 1) / 2;
color.blue += 25000 + (color.green + 1) / 2; if (color.blue < 35000)
gtk_event_box_set_visible_window (GTK_EVENT_BOX (label), TRUE); color.blue += 25000 + (color.green + 1) / 2;
gtk_widget_modify_bg (label, GTK_STATE_NORMAL, &color); gtk_event_box_set_visible_window (GTK_EVENT_BOX (label), TRUE);
gtk_widget_modify_bg (label, GTK_STATE_ACTIVE, &color); gtk_widget_modify_bg (label, GTK_STATE_NORMAL, &color);
gtk_widget_modify_bg (label, GTK_STATE_ACTIVE, &color);
}
else
{
gtk_widget_modify_bg (label, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_bg (label, GTK_STATE_ACTIVE, NULL);
}
} }
static void static void