From 224c97090305d7fbe20d76d50001118a4ade959b Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Wed, 16 Aug 2000 18:46:39 +0000 Subject: get rid of COLOR_TEXT. (struct _EIconBarItem): add pixbuf member to hold 2000-08-16 Larry Ewing * 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 --- widgets/shortcut-bar/e-icon-bar.c | 54 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'widgets/shortcut-bar/e-icon-bar.c') 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) { -- cgit v1.2.3