aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/shortcut-bar/e-icon-bar.c
diff options
context:
space:
mode:
authorLarry Ewing <lewing@helixcode.com>2000-08-17 02:46:39 +0800
committerLarry Ewing <lewing@src.gnome.org>2000-08-17 02:46:39 +0800
commit224c97090305d7fbe20d76d50001118a4ade959b (patch)
tree6ee7ea84086cac4cb5619f52028ace0b9de98a66 /widgets/shortcut-bar/e-icon-bar.c
parent3fe16616273837ac06323c703e4b0c7152e1abaa (diff)
downloadgsoc2013-evolution-224c97090305d7fbe20d76d50001118a4ade959b.tar
gsoc2013-evolution-224c97090305d7fbe20d76d50001118a4ade959b.tar.gz
gsoc2013-evolution-224c97090305d7fbe20d76d50001118a4ade959b.tar.bz2
gsoc2013-evolution-224c97090305d7fbe20d76d50001118a4ade959b.tar.lz
gsoc2013-evolution-224c97090305d7fbe20d76d50001118a4ade959b.tar.xz
gsoc2013-evolution-224c97090305d7fbe20d76d50001118a4ade959b.tar.zst
gsoc2013-evolution-224c97090305d7fbe20d76d50001118a4ade959b.zip
get rid of COLOR_TEXT. (struct _EIconBarItem): add pixbuf member to hold
2000-08-16 Larry Ewing <lewing@helixcode.com> * e-icon-bar.h (enum): get rid of COLOR_TEXT. (struct _EIconBarItem): add pixbuf member to hold unmodified pixbuf. * e-icon-bar.c (e_icon_bar_style_set): update the image and the colors based on the new style. (e_icon_bar_add_item): store the full alpha pixbuf so that we can update the background color if the style changes. Use the style colors where appropriate. (e_icon_bar_on_editing_stopped): revert to style colors. (e_icon_bar_on_editing_started): use style fg instead of COLOR_TEXT. * e-shortcut-bar.c (e_shortcut_bar_add_group): add an #ifndef E_USE_STYLES around the call to e_shortcut_bar_set_canvas_style to allow people to test out the style stuff that is in progress. svn path=/trunk/; revision=4856
Diffstat (limited to 'widgets/shortcut-bar/e-icon-bar.c')
-rw-r--r--widgets/shortcut-bar/e-icon-bar.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/widgets/shortcut-bar/e-icon-bar.c b/widgets/shortcut-bar/e-icon-bar.c
index 832506201d..11cf2c14b6 100644
--- a/widgets/shortcut-bar/e-icon-bar.c
+++ b/widgets/shortcut-bar/e-icon-bar.c
@@ -127,6 +127,7 @@ static void e_icon_bar_ensure_edited_item_visible (EIconBar *icon_bar);
static void e_icon_bar_update_highlight (EIconBar *icon_bar);
static void e_icon_bar_vadjustment_value_changed (GtkAdjustment *adjustment,
EIconBar *icon_bar);
+static void e_icon_bar_style_set (GtkWidget *widget, GtkStyle *previous_style);
enum
{
@@ -208,6 +209,7 @@ e_icon_bar_class_init (EIconBarClass *class)
widget_class->focus_out_event = e_icon_bar_focus_out;
widget_class->drag_motion = e_icon_bar_drag_motion;
widget_class->drag_leave = e_icon_bar_drag_leave;
+ widget_class->style_set = e_icon_bar_style_set;
ecanvas_class->reflow = e_icon_bar_reflow;
@@ -248,8 +250,8 @@ e_icon_bar_init (EIconBar *icon_bar)
colormap = gtk_widget_get_colormap (GTK_WIDGET (icon_bar));
icon_bar->colors[E_ICON_BAR_COLOR_TEXT].red = 65535;
- icon_bar->colors[E_ICON_BAR_COLOR_TEXT].green = 65535;
- icon_bar->colors[E_ICON_BAR_COLOR_TEXT].blue = 65535;
+ icon_bar->colors[E_ICON_BAR_COLOR_TEXT].green = 0;
+ icon_bar->colors[E_ICON_BAR_COLOR_TEXT].blue = 0;
icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT].red = 0;
icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT].green = 0;
@@ -569,6 +571,46 @@ rgb_from_gdk_color (GdkColor *color)
return a;
}
+static void
+e_icon_bar_style_set (GtkWidget *widget, GtkStyle *previous_style) {
+ EIconBar *icon_bar;
+ EIconBarItem *item;
+ gint item_num;
+ GdkPixbuf *flattened;
+ GtkStyle *style = widget->style;
+ GdkColormap *colormap;
+
+ colormap = gtk_widget_get_colormap (widget);
+ gdk_color_alloc (colormap, &style->fg [GTK_STATE_NORMAL]);
+
+ icon_bar = E_ICON_BAR (widget);
+
+ for (item_num = 0; item_num < icon_bar->items->len; item_num++) {
+
+ item = &g_array_index (icon_bar->items,
+ EIconBarItem, item_num);
+
+ flattened = flatten_alpha (item->pixbuf,
+ rgb_from_gdk_color (&style->bg [GTK_STATE_NORMAL]));
+
+ gnome_canvas_item_set(item->image,
+ "GnomeCanvasPixbuf::pixbuf", flattened ? flattened : item->pixbuf,
+ NULL);
+ gnome_canvas_item_set (item->text,
+ "font_gdk", style->font,
+ "fill_color_gdk", &style->fg [GTK_STATE_NORMAL],
+ NULL);
+
+ if (flattened)
+ /* the canvas item holds the reference now */
+ gdk_pixbuf_unref (flattened);
+
+ }
+
+ e_icon_bar_recalc_item_positions (icon_bar);
+}
+
+
/**
* e_icon_bar_add_item:
* @icon_bar: An #EIconBar.
@@ -617,7 +659,7 @@ e_icon_bar_add_item (EIconBar *icon_bar,
item.text = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
e_text_get_type (),
"font_gdk", font,
- "fill_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_TEXT],
+ "fill_color_gdk", &style->fg [GTK_STATE_NORMAL],
"use_ellipsis", TRUE,
"anchor", anchor,
"editable", TRUE,
@@ -636,6 +678,9 @@ e_icon_bar_add_item (EIconBar *icon_bar,
GTK_SIGNAL_FUNC (e_icon_bar_on_item_event),
icon_bar);
+ item.pixbuf = image;
+ gdk_pixbuf_ref (image);
+
flattened = flatten_alpha (image,
rgb_from_gdk_color (&style->bg [GTK_STATE_NORMAL]));
@@ -735,6 +780,7 @@ e_icon_bar_remove_item (EIconBar *icon_bar,
gtk_object_destroy (GTK_OBJECT (item->text));
gtk_object_destroy (GTK_OBJECT (item->image));
+ gdk_pixbuf_unref (item->pixbuf);
g_array_remove_index (icon_bar->items, item_num);
@@ -1401,7 +1447,7 @@ e_icon_bar_on_editing_stopped (EIconBar *icon_bar,
/* Reset the fg & bg colors. */
gnome_canvas_item_set (item,
- "fill_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_TEXT],
+ "fill_color_gdk", &(GTK_WIDGET(icon_bar)->style->fg [GTK_STATE_NORMAL]),
NULL);
if (icon_bar->edit_rect_item) {