[Xfce4-commits] <midori:master> Add Midori.Tab.fg/bg_color and Midori.View.set_colors
Christian Dywan
noreply at xfce.org
Sat Mar 23 03:18:01 CET 2013
Updating branch refs/heads/master
to 45be1e6c6e8e1a78a5697aeced20ee2e833a79a0 (commit)
from 2d55ae3206559eb1c5fc0fe923de71d0ded54341 (commit)
commit 45be1e6c6e8e1a78a5697aeced20ee2e833a79a0
Author: Christian Dywan <christian at twotoasts.de>
Date: Sat Mar 23 02:23:12 2013 +0100
Add Midori.Tab.fg/bg_color and Midori.View.set_colors
Update extensions to use the new API.
Midori.View internally sets its built-in tab label colors.
extensions/colorful-tabs.c | 43 ++++---------------------------------------
extensions/tab-panel.c | 19 +++++++++++++------
midori/midori-tab.vala | 3 +++
midori/midori-view.c | 19 ++++++++++++++++++-
midori/midori-view.h | 7 ++++++-
5 files changed, 44 insertions(+), 47 deletions(-)
diff --git a/extensions/colorful-tabs.c b/extensions/colorful-tabs.c
index 569d3ab..10cb9e4 100644
--- a/extensions/colorful-tabs.c
+++ b/extensions/colorful-tabs.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2009 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2009-2013 Christian Dywan <christian at twotoasts.de>
Copyright (C) 2010 Samuel Creshal <creshal at arcor.de>
This library is free software; you can redistribute it and/or
@@ -13,38 +13,16 @@
#include <midori/midori.h>
static void
-colorful_tabs_modify_fg (GtkWidget* label,
- GdkColor* color)
-{
- GList* children = gtk_container_get_children (GTK_CONTAINER (label));
- for (; children != NULL; children = g_list_next (children))
- {
- 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
colorful_tabs_view_notify_uri_cb (MidoriView* view,
GParamSpec* pspec,
MidoriExtension* extension)
{
- GtkWidget* label;
gchar* hostname;
gchar* colorstr;
GdkColor color;
GdkColor fgcolor;
GdkPixbuf* icon;
- label = midori_view_get_proxy_tab_label (view);
-
if (!midori_uri_is_blank (midori_view_get_display_uri (view))
&& (hostname = midori_uri_parse_hostname (midori_view_get_display_uri (view), NULL))
&& midori_view_get_icon_uri (view) != NULL)
@@ -89,11 +67,6 @@ colorful_tabs_view_notify_uri_cb (MidoriView* view,
else
gdk_color_parse ("#000", &fgcolor);
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (label), TRUE);
-
- colorful_tabs_modify_fg (label, &fgcolor);
- gtk_widget_modify_bg (label, GTK_STATE_NORMAL, &color);
-
if (color.red < 10000)
color.red = 5000;
else
@@ -107,14 +80,10 @@ colorful_tabs_view_notify_uri_cb (MidoriView* view,
else
color.green -= 5000;
- gtk_widget_modify_bg (label, GTK_STATE_ACTIVE, &color);
+ midori_view_set_colors (view, &fgcolor, &color);
}
else
- {
- gtk_widget_modify_bg (label, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_bg (label, GTK_STATE_ACTIVE, NULL);
- colorful_tabs_modify_fg (label, NULL);
- }
+ midori_view_set_colors (view, NULL, NULL);
}
static void
@@ -150,11 +119,7 @@ colorful_tabs_deactivate_cb (MidoriExtension* extension,
children = midori_browser_get_tabs (MIDORI_BROWSER (browser));
for (; children; children = g_list_next (children))
{
- GtkWidget* label = midori_view_get_proxy_tab_label (children->data);
- 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);
- colorful_tabs_modify_fg (label, NULL);
+ midori_view_set_colors (children->data, NULL, NULL);
g_signal_handlers_disconnect_by_func (
children->data, colorful_tabs_view_notify_uri_cb, extension);
}
diff --git a/extensions/tab-panel.c b/extensions/tab-panel.c
index 0dac18f..7b429f6 100644
--- a/extensions/tab-panel.c
+++ b/extensions/tab-panel.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2008-2009 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2008-2013 Christian Dywan <christian at twotoasts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -354,13 +354,14 @@ tab_panel_view_notify_icon_cb (GtkWidget* view,
{
GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
GtkTreeIter iter;
- GtkWidget* label = midori_view_get_proxy_tab_label (MIDORI_VIEW (view));
- GtkStyle* style = gtk_widget_get_style (label);
+ GdkColor* fg = midori_tab_get_fg_color (MIDORI_TAB (view));
+ GdkColor* bg = midori_tab_get_bg_color (MIDORI_TAB (view));
+
if (tab_panel_get_iter_for_view (model, &iter, view))
gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
3, icon,
- 6, &style->bg[GTK_STATE_NORMAL],
- 7, &style->fg[GTK_STATE_NORMAL],
+ 6, bg,
+ 7, fg,
-1);
}
}
@@ -383,11 +384,15 @@ tab_panel_view_notify_title_cb (GtkWidget* view,
{
GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
GtkTreeIter iter;
+ GdkColor* fg = midori_tab_get_fg_color (MIDORI_TAB (view));
+ GdkColor* bg = midori_tab_get_bg_color (MIDORI_TAB (view));
if (tab_panel_get_iter_for_view (model, &iter, view))
{
gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
4, title,
5, midori_view_get_label_ellipsize (MIDORI_VIEW (view)),
+ 6, bg,
+ 7, fg,
-1);
}
}
@@ -449,10 +454,12 @@ tab_panel_browser_add_tab_cb (MidoriBrowser* browser,
GtkTreeIter iter;
gboolean buttons = katze_object_get_boolean (settings, "close-buttons-on-tabs");
gint ellipsize = midori_view_get_label_ellipsize (MIDORI_VIEW (view));
+ GdkColor* fg = midori_tab_get_fg_color (MIDORI_TAB (view));
+ GdkColor* bg = midori_tab_get_bg_color (MIDORI_TAB (view));
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, 7, NULL, -1);
+ 3, icon, 4, title, 5, ellipsize, 6, bg, 7, fg, -1);
}
if (!g_signal_handler_find (view, G_SIGNAL_MATCH_FUNC,
diff --git a/midori/midori-tab.vala b/midori/midori-tab.vala
index a7b8671..1509452 100644
--- a/midori/midori-tab.vala
+++ b/midori/midori-tab.vala
@@ -57,6 +57,9 @@ namespace Midori {
public Security security { get; protected set; default = Security.NONE; }
public LoadStatus load_status { get; protected set; default = LoadStatus.FINISHED; }
public string? statusbar_text { get; protected set; default = null; }
+ /* Since: 0.5.0 */
+ public Gdk.Color? fg_color { get; protected set; default = null; }
+ public Gdk.Color? bg_color { get; protected set; default = null; }
private double current_progress = 0.0;
public double progress { get {
diff --git a/midori/midori-view.c b/midori/midori-view.c
index eb96151..bcf52e4 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2007-2010 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2007-2013 Christian Dywan <christian at twotoasts.de>
Copyright (C) 2009 Jean-François Guchens <zcx000 at gmail.com>
This library is free software; you can redistribute it and/or
@@ -5677,3 +5677,20 @@ midori_view_get_for_widget (GtkWidget* web_view)
return MIDORI_VIEW (view);
}
+void
+midori_view_set_colors (MidoriView* view,
+ GdkColor* fg_color,
+ GdkColor* bg_color)
+{
+ midori_tab_set_fg_color (MIDORI_TAB (view), fg_color);
+ midori_tab_set_bg_color (MIDORI_TAB (view), bg_color);
+
+ GtkWidget* label = midori_view_get_proxy_tab_label (view);
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (label),
+ fg_color != NULL || bg_color != NULL);
+ gtk_widget_modify_fg (label, GTK_STATE_NORMAL, fg_color);
+ gtk_widget_modify_fg (label, GTK_STATE_ACTIVE, fg_color);
+ gtk_widget_modify_bg (label, GTK_STATE_NORMAL, bg_color);
+ gtk_widget_modify_bg (label, GTK_STATE_ACTIVE, bg_color);
+}
+
diff --git a/midori/midori-view.h b/midori/midori-view.h
index 9e426c2..05f9f38 100644
--- a/midori/midori-view.h
+++ b/midori/midori-view.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2008 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2008-2013 Christian Dywan <christian at twotoasts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -243,6 +243,11 @@ midori_view_list_plugins (MidoriView* view,
GString* markup,
gboolean html);
+void
+midori_view_set_colors (MidoriView* view,
+ GdkColor* fg_color,
+ GdkColor* bg_color);
+
G_END_DECLS
#endif /* __MIDORI_VIEW_H__ */
More information about the Xfce4-commits
mailing list