From cd4cd3f52e1e63220b9e9d4c25da6d162ab1f087 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 25 Apr 2011 17:56:56 +0200 Subject: [PATCH] Make Tab Panel use the correct foreground colours In particular when used in combination with Colorful Tabs. --- extensions/colorful-tabs.c | 35 +++++++++++++++++------------------ extensions/tab-panel.c | 11 +++++++---- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/extensions/colorful-tabs.c b/extensions/colorful-tabs.c index 5979f4e6..f8a47fb1 100644 --- a/extensions/colorful-tabs.c +++ b/extensions/colorful-tabs.c @@ -13,14 +13,23 @@ #include static void -colorful_tabs_modify_fg (GtkWidget* child, - GdkColor* color) +colorful_tabs_modify_fg (GtkWidget* label, + GdkColor* color) { - if (GTK_IS_LABEL (child)) + GtkWidget* box = gtk_bin_get_child (GTK_BIN (label)); + GList* children = gtk_container_get_children (GTK_CONTAINER (box)); + for (; children != NULL; children = g_list_next (children)) { - gtk_widget_modify_fg (child, GTK_STATE_ACTIVE, color); - gtk_widget_modify_fg (child, GTK_STATE_NORMAL, color); + if (GTK_IS_LABEL (children->data)) + { + gtk_widget_modify_fg (children->data, GTK_STATE_ACTIVE, color); + gtk_widget_modify_fg (children->data, GTK_STATE_NORMAL, color); + /* Also modify the label itself, for Tab Panel */ + gtk_widget_modify_fg (label, GTK_STATE_NORMAL, color); + break; + } } + g_list_free (children); } static void @@ -28,7 +37,6 @@ colorful_tabs_view_notify_uri_cb (MidoriView* view, GParamSpec* pspec, MidoriExtension* extension) { - GtkWidget* box; GtkWidget* label; SoupURI* uri; gchar* colorstr; @@ -82,14 +90,9 @@ colorful_tabs_view_notify_uri_cb (MidoriView* view, else gdk_color_parse ("#000", &fgcolor); - box = gtk_bin_get_child (GTK_BIN (label)); - gtk_event_box_set_visible_window (GTK_EVENT_BOX (label), TRUE); - gtk_container_foreach (GTK_CONTAINER (box), - (GtkCallback) colorful_tabs_modify_fg, - &fgcolor); - + colorful_tabs_modify_fg (label, &fgcolor); gtk_widget_modify_bg (label, GTK_STATE_NORMAL, &color); if (color.red < 10000) @@ -111,9 +114,7 @@ colorful_tabs_view_notify_uri_cb (MidoriView* view, { gtk_widget_modify_bg (label, GTK_STATE_NORMAL, NULL); gtk_widget_modify_bg (label, GTK_STATE_ACTIVE, NULL); - gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (label))), - (GtkCallback) colorful_tabs_modify_fg, - NULL); + colorful_tabs_modify_fg (label, NULL); } } @@ -153,9 +154,7 @@ colorful_tabs_deactivate_cb (MidoriExtension* extension, gtk_event_box_set_visible_window (GTK_EVENT_BOX (label), FALSE); gtk_widget_modify_bg (label, GTK_STATE_NORMAL, NULL); gtk_widget_modify_bg (label, GTK_STATE_ACTIVE, NULL); - gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (label))), - (GtkCallback) colorful_tabs_modify_fg, - NULL); + colorful_tabs_modify_fg (label, NULL); g_signal_handlers_disconnect_by_func ( view, colorful_tabs_view_notify_uri_cb, extension); } diff --git a/extensions/tab-panel.c b/extensions/tab-panel.c index aeedd130..4d58447e 100644 --- a/extensions/tab-panel.c +++ b/extensions/tab-panel.c @@ -360,6 +360,7 @@ tab_panel_view_notify_icon_cb (GtkWidget* view, gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 3, icon, 6, &style->bg[GTK_STATE_NORMAL], + 7, &style->fg[GTK_STATE_NORMAL], -1); } } @@ -452,7 +453,7 @@ tab_panel_browser_add_tab_cb (MidoriBrowser* browser, gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &iter, NULL, page, 0, view, 1, GTK_STOCK_CLOSE, 2, buttons, - 3, icon, 4, title, 5, ellipsize, 6, NULL, -1); + 3, icon, 4, title, 5, ellipsize, 6, NULL, 7, NULL, -1); } if (!g_signal_handler_find (view, G_SIGNAL_MATCH_FUNC, @@ -530,8 +531,9 @@ tab_panel_app_add_browser_cb (MidoriApp* app, panel = katze_object_get_object (browser, "panel"); - model = gtk_tree_store_new (7, MIDORI_TYPE_VIEW, - G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR); + model = gtk_tree_store_new (8, MIDORI_TYPE_VIEW, + G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_STRING, + G_TYPE_INT, GDK_TYPE_COLOR, GDK_TYPE_COLOR); g_object_set_data (G_OBJECT (browser), "tab-panel-ext-model", model); treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); @@ -549,7 +551,8 @@ tab_panel_app_add_browser_cb (MidoriApp* app, renderer_text = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer_text, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_text, - "text", 4, "ellipsize", 5, "cell-background-gdk", 6, NULL); + "text", 4, "ellipsize", 5, + "cell-background-gdk", 6, "foreground-gdk", 7, NULL); gtk_tree_view_column_set_expand (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); column = gtk_tree_view_column_new ();