From 637388a8deff82135b20e00e2b24a56bcbca039c Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 23 Mar 2009 19:27:35 +0100 Subject: [PATCH] Do not try to compute a tab colour unless it's a proper URI --- extensions/colorful-tabs.c | 39 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/extensions/colorful-tabs.c b/extensions/colorful-tabs.c index bddb403b..2eea40e5 100644 --- a/extensions/colorful-tabs.c +++ b/extensions/colorful-tabs.c @@ -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 visible and modify its background. */ - 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); - colorstr = g_strndup (hash, 6 + 1); - g_free (hash); - colorstr[0] = '#'; - gdk_color_parse (colorstr, &color); - if (color.red < 35000) - color.red += 25000 + (color.blue + 1) / 2; - if (color.green < 35000) - color.green += 25000 + (color.red + 1) / 2; - if (color.blue < 35000) - color.blue += 25000 + (color.green + 1) / 2; - gtk_event_box_set_visible_window (GTK_EVENT_BOX (label), TRUE); - gtk_widget_modify_bg (label, GTK_STATE_NORMAL, &color); - gtk_widget_modify_bg (label, GTK_STATE_ACTIVE, &color); + 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); + colorstr = g_strndup (hash, 6 + 1); + g_free (hash); + colorstr[0] = '#'; + gdk_color_parse (colorstr, &color); + if (color.red < 35000) + color.red += 25000 + (color.blue + 1) / 2; + if (color.green < 35000) + color.green += 25000 + (color.red + 1) / 2; + if (color.blue < 35000) + color.blue += 25000 + (color.green + 1) / 2; + gtk_event_box_set_visible_window (GTK_EVENT_BOX (label), TRUE); + 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 -- 2.39.5