[gnumeric] GUI: simplify code for colouring deps.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: simplify code for colouring deps.
- Date: Tue, 26 Mar 2013 00:37:37 +0000 (UTC)
commit 1b2fb3a6c0515b28a1355f92e42718beea138491
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 25 20:37:06 2013 -0400
GUI: simplify code for colouring deps.
ChangeLog | 6 ++++++
src/gnm-pane.c | 2 +-
src/gnm-pane.h | 2 +-
src/item-cursor.c | 21 ++++++++-------------
src/widgets/ChangeLog | 5 +++++
src/widgets/gnumeric-expr-entry.c | 24 ++++++++++--------------
6 files changed, 31 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 320f3f0..16430e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2013-03-25 Morten Welinder <terra gnome org>
+ * src/item-cursor.c (gnm_item_cursor_class_init): Change type of
+ color to GOColor.
+
+ * src/gnm-pane.c (gnm_pane_expr_cursor_bound_set): Take GOColor,
+ not colour name.
+
* src/item-bar.c: Rename: ItemBar to GnmItemBar.
* src/gnumeric.css: use deprecated px-free syntax for padding, so
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 6b5434e..06821b5 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -2254,7 +2254,7 @@ gnm_pane_mouse_cursor_set (GnmPane *pane, GdkCursor *c)
void
gnm_pane_expr_cursor_bound_set (GnmPane *pane, GnmRange const *r,
- gchar const *color)
+ GOColor color)
{
GnmItemCursor *cursor;
diff --git a/src/gnm-pane.h b/src/gnm-pane.h
index b71c85e..7ae172c 100644
--- a/src/gnm-pane.h
+++ b/src/gnm-pane.h
@@ -42,7 +42,7 @@ void gnm_pane_special_cursor_start (GnmPane *pane, int style, int button);
void gnm_pane_special_cursor_stop (GnmPane *pane);
void gnm_pane_mouse_cursor_set (GnmPane *pane, GdkCursor *c);
void gnm_pane_expr_cursor_bound_set (GnmPane *pane, GnmRange const *r,
- gchar const *color);
+ GOColor color);
void gnm_pane_expr_cursor_stop (GnmPane *pane);
/************************************************************************/
diff --git a/src/item-cursor.c b/src/item-cursor.c
index d9c64d7..3b6075b 100644
--- a/src/item-cursor.c
+++ b/src/item-cursor.c
@@ -1394,7 +1394,6 @@ item_cursor_set_property (GObject *obj, guint param_id,
GValue const *value, GParamSpec *pspec)
{
GnmItemCursor *ic = GNM_ITEM_CURSOR (obj);
- char const *color_name;
switch (param_id) {
case ITEM_CURSOR_PROP_SHEET_CONTROL_GUI:
@@ -1406,14 +1405,9 @@ item_cursor_set_property (GObject *obj, guint param_id,
case ITEM_CURSOR_PROP_BUTTON :
ic->drag_button = g_value_get_int (value);
break;
- case ITEM_CURSOR_PROP_COLOR: {
- GOColor color;
- color_name = g_value_get_string (value);
- if (go_color_from_str (color_name, &color)) {
- go_color_to_gdk_rgba (color, &ic->color);
- ic->use_color = 1;
- }
- }
+ case ITEM_CURSOR_PROP_COLOR:
+ go_color_to_gdk_rgba (g_value_get_uint (value), &ic->color);
+ ic->use_color = 1;
}
}
@@ -1446,10 +1440,11 @@ gnm_item_cursor_class_init (GObjectClass *gobject_klass)
0, G_MAXINT, 0,
GSF_PARAM_STATIC | G_PARAM_WRITABLE));
g_object_class_install_property (gobject_klass, ITEM_CURSOR_PROP_COLOR,
- g_param_spec_string ("color", "Color",
- "name of the cursor's color",
- "black",
- GSF_PARAM_STATIC | G_PARAM_WRITABLE));
+ g_param_spec_uint ("color", "Color",
+ "Name of the cursor's color",
+ 0, 0xffffffff,
+ GO_COLOR_BLACK,
+ GSF_PARAM_STATIC | G_PARAM_WRITABLE));
item_klass->realize = item_cursor_realize;
item_klass->unrealize = item_cursor_unrealize;
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 181fb42..715619d 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-25 Morten Welinder <terra gnome org>
+
+ * gnumeric-expr-entry.c (gnm_expr_entry_colour_ranges): Make sure
+ we only have the colours once here.
+
2013-03-09 Morten Welinder <terra gnome org>
* Release 1.12.1
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 35535ab..322118d 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -599,17 +599,14 @@ static void
gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef *rr, int colour,
PangoAttrList **attrs, gboolean insert_cursor)
{
- static struct {
- guint16 red;
- guint16 green;
- guint16 blue;
- gchar const *name;
- } colours[] = {{0x0, 0xFFFF, 0x0, "00:ff:00:ff"},
- {0x0, 0x0, 0xFFFF, "00:00:ff:ff"},
- {0xFFFF, 0x0, 0x0, "ff:00:00:ff"},
- {0x0, 0x80FF, 0x80FF, "00:80:80:ff"},
- {0xA0FF, 0xA0FF, 0x0, "a0:a0:00:ff"},
- {0xA0FF, 0x0, 0xA0FF, "a0:00:a0:ff"}};
+ static const GOColor colours[] = {
+ GO_COLOR_FROM_RGB (0x00, 0xff, 0x00),
+ GO_COLOR_FROM_RGB (0x00, 0x00, 0xff),
+ GO_COLOR_FROM_RGB (0xff, 0x00, 0x00),
+ GO_COLOR_FROM_RGB (0x00, 0x80, 0x80),
+ GO_COLOR_FROM_RGB (0xa0, 0xa0, 0x00),
+ GO_COLOR_FROM_RGB (0xa0, 0x00, 0xa0)
+ };
PangoAttribute *at;
GnmRange r;
GnmRange const *merge; /*[#127415]*/
@@ -646,11 +643,10 @@ gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef
}
SCG_FOREACH_PANE (scg, pane, gnm_pane_expr_cursor_bound_set
- (pane, &r, colours[colour].name););
+ (pane, &r, colours[colour]););
}
- at = pango_attr_foreground_new (colours[colour].red, colours[colour].green,
- colours[colour].blue);
+ at = go_color_to_pango (colours[colour], TRUE);
at->start_index = start;
at->end_index = end;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]