From: Jim Evins Date: Sun, 31 Aug 2003 00:39:25 +0000 (+0000) Subject: Use theme colors for shadow and selections. X-Git-Tag: glabels-2_3_0~614 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=03a364f16bab38c0551af5e804e5394c9b875c80;p=glabels Use theme colors for shadow and selections. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@275 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/wdgt-mini-preview.c b/glabels2/src/wdgt-mini-preview.c index 5f39fa60..6108224c 100644 --- a/glabels2/src/wdgt-mini-preview.c +++ b/glabels2/src/wdgt-mini-preview.c @@ -31,9 +31,8 @@ #include "debug.h" #define WDGT_MINI_PREVIEW_MAX_PIXELS 175 -#define SHADOW_X_OFFSET 3 -#define SHADOW_Y_OFFSET 3 -#define SHADOW_COLOR GL_COLOR_A (33, 33, 33, 192) +#define SHADOW_X_OFFSET 5 +#define SHADOW_Y_OFFSET 5 #define RES 5 /* Resolution in degrees for Business Card CD outlines */ @@ -80,6 +79,11 @@ static GnomeCanvasItem *cdbc_item (GnomeCanvasGroup *group, gdouble y1, glTemplate *template); +static void style_set_cb (GtkWidget *widget, + GtkStyle *previous_style, + gpointer data); + + /****************************************************************************/ @@ -200,8 +204,10 @@ gl_wdgt_mini_preview_construct (glWdgtMiniPreview * preview, gint height, gint width) { - GtkWidget *whbox; + GtkWidget *whbox; GnomeCanvasGroup *group; + GtkStyle *style; + guint shadow_color; gl_debug (DEBUG_MINI_PREVIEW, "START"); @@ -223,6 +229,8 @@ gl_wdgt_mini_preview_construct (glWdgtMiniPreview * preview, group = gnome_canvas_root (GNOME_CANVAS (preview->canvas)); /* draw shadow */ + style = gtk_widget_get_style (GTK_WIDGET(preview)); + shadow_color = gl_color_from_gdk_color (&style->bg[GTK_STATE_ACTIVE]); preview->shadow_item = gnome_canvas_item_new (group, gnome_canvas_rect_get_type (), @@ -230,7 +238,7 @@ gl_wdgt_mini_preview_construct (glWdgtMiniPreview * preview, "y1", (gdouble)SHADOW_Y_OFFSET, "x2", (gdouble)(SHADOW_X_OFFSET + width), "y2", (gdouble)(SHADOW_Y_OFFSET + height), - "fill_color_rgba", SHADOW_COLOR, + "fill_color_rgba", shadow_color, NULL); /* draw an initial paper outline */ @@ -254,6 +262,11 @@ gl_wdgt_mini_preview_construct (glWdgtMiniPreview * preview, g_signal_connect (G_OBJECT (preview->canvas), "event", G_CALLBACK (canvas_event_cb), preview); + + /* Style changed handler */ + g_signal_connect (G_OBJECT (preview), "style_set", + G_CALLBACK (style_set_cb), NULL); + gl_debug (DEBUG_MINI_PREVIEW, "END"); } @@ -551,23 +564,29 @@ canvas_event_cb (GnomeCanvas * canvas, /* Highlight given label outlines. */ /****************************************************************************/ void -gl_wdgt_mini_preview_highlight_range (glWdgtMiniPreview * preview, - gint first_label, - gint last_label) +gl_wdgt_mini_preview_highlight_range (glWdgtMiniPreview *preview, + gint first_label, + gint last_label) { - GnomeCanvasItem *item = NULL; - GList *p = NULL; - gint i; + GtkStyle *style; + guint select_color; + GnomeCanvasItem *item = NULL; + GList *p = NULL; + gint i; gl_debug (DEBUG_MINI_PREVIEW, "START"); + style = gtk_widget_get_style (GTK_WIDGET(preview)); + select_color = gl_color_from_gdk_color (&style->base[GTK_STATE_SELECTED]); + gl_debug (DEBUG_MINI_PREVIEW, "select color = 0x%08x", select_color); + for (p = preview->label_items, i = 1; p != NULL; i++, p = p->next) { item = GNOME_CANVAS_ITEM (p->data); if ((i >= first_label) && (i <= last_label)) { gnome_canvas_item_set (item, - "fill_color", "light blue", + "fill_color_rgba", select_color, NULL); } else { gnome_canvas_item_set (item, @@ -576,9 +595,36 @@ gl_wdgt_mini_preview_highlight_range (glWdgtMiniPreview * preview, } + preview->highlight_first = first_label; + preview->highlight_last = last_label; + gl_debug (DEBUG_MINI_PREVIEW, "END"); } +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Refresh colors, if style changed. */ +/*--------------------------------------------------------------------------*/ +static void +style_set_cb (GtkWidget *widget, + GtkStyle *previous_style, + gpointer data) +{ + glWdgtMiniPreview *preview = GL_WDGT_MINI_PREVIEW (widget); + GtkStyle *style; + guint shadow_color; + + style = gtk_widget_get_style (GTK_WIDGET(preview)); + + shadow_color = gl_color_from_gdk_color (&style->bg[GTK_STATE_ACTIVE]); + gnome_canvas_item_set (preview->shadow_item, + "fill_color_rgba", shadow_color, + NULL); + + gl_wdgt_mini_preview_highlight_range (preview, + preview->highlight_first, + preview->highlight_last); +} + /*--------------------------------------------------------------------------*/ /* PRIVATE. Draw CD business card item (cut-off in w and/or h). */ /*--------------------------------------------------------------------------*/ diff --git a/glabels2/src/wdgt-mini-preview.h b/glabels2/src/wdgt-mini-preview.h index 29c22cf8..fdb07483 100644 --- a/glabels2/src/wdgt-mini-preview.h +++ b/glabels2/src/wdgt-mini-preview.h @@ -53,6 +53,9 @@ struct _glWdgtMiniPreview { gint labels_per_sheet; GList *label_items; + + gint highlight_first; + gint highlight_last; }; struct _glWdgtMiniPreviewClass {