[gnumeric] Colour the range expressions to match the range cursor.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Colour the range expressions to match the range cursor.
- Date: Mon, 28 Nov 2011 19:04:33 +0000 (UTC)
commit 597546e40ae2af7262e63838be35b5636acbe36a
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Mon Nov 28 12:02:03 2011 -0700
Colour the range expressions to match the range cursor.
2011-11-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* gnumeric-expr-entry.c (gnm_expr_entry_colour_ranges): add arg
and use the attached attribute list rather than the list from the entry
(gee_scan_for_range): attach an attribute list as data to the entry
2011-11-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/item-edit.c (item_edit_draw): use the attr list attached as
data
ChangeLog | 5 +++++
NEWS | 4 ++++
src/item-edit.c | 22 +++++++++-------------
src/widgets/ChangeLog | 6 ++++++
src/widgets/gnumeric-expr-entry.c | 24 ++++++++++++++++--------
5 files changed, 40 insertions(+), 21 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ed38228..d040d1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2011-11-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * src/item-edit.c (item_edit_draw): use the attr list attached as
+ data
+
+2011-11-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/item-edit.c (gnm_apply_attribute_list_cb): new
(gnm_apply_attribute_list): new
(item_edit_draw): retrieve and apply range selection colour
diff --git a/NEWS b/NEWS
index 1c293a4..c72641c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
Gnumeric 1.11.2
+Andreas:
+ * Colour the range expressions to match the range cursor.
+
+
--------------------------------------------------------------------------
Gnumeric 1.11.1
diff --git a/src/item-edit.c b/src/item-edit.c
index 782a07d..f9da479 100644
--- a/src/item-edit.c
+++ b/src/item-edit.c
@@ -125,21 +125,15 @@ item_edit_draw (GocItem const *item, cairo_t *cr)
char const *text = gtk_entry_get_text (ie->entry);
PangoDirection dir = pango_find_base_dir (text, -1);
PangoLayout *layout = gtk_entry_get_layout (ie->entry);
- PangoAttrList *entry_attributes = pango_layout_get_attributes (layout);
- int len;
+ PangoAttrList *entry_attributes
+ = g_object_get_data(G_OBJECT (ie->entry),
+ "gnm:range-attributes");
- if (go_pango_attr_list_is_empty (entry_attributes))
- entry_attributes = NULL;
- else if (0 == (len = gtk_entry_text_index_to_layout_index (ie->entry, 0))) {
- entry_attributes = pango_attr_list_copy (entry_attributes);
- } else {
- PangoAttrList *attributes = pango_attr_list_copy (entry_attributes);
- go_pango_attr_list_erase (attributes, 0, len);
- if (go_pango_attr_list_is_empty (attributes)) {
- pango_attr_list_unref (attributes);
+ if (entry_attributes != NULL) {
+ if (go_pango_attr_list_is_empty (entry_attributes))
entry_attributes = NULL;
- } else
- entry_attributes = attributes;
+ else
+ entry_attributes = pango_attr_list_ref (entry_attributes);
}
get_top_left (ie, &top, &left, dir);
@@ -215,6 +209,8 @@ item_edit_draw (GocItem const *item, cairo_t *cr)
} else {
pango_cairo_show_layout (cr, ie->layout);
}
+ pango_attr_list_unref (entry_attributes);
+
if (ie->cursor_visible) {
int cursor_pos = gtk_editable_get_position (GTK_EDITABLE (ie->entry));
double incr = (dir == PANGO_DIRECTION_RTL)? -.5: .5, x, ytop, ybottom;
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index c77b262..d5aaccb 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,9 @@
+2011-11-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * gnumeric-expr-entry.c (gnm_expr_entry_colour_ranges): add arg
+ and use the attached attribute list rather than the list from the entry
+ (gee_scan_for_range): attach an attribute list as data to the entry
+
2011-11-27 Morten Welinder <terra gnome org>
* Release 1.11.1
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 1aef866..7cad481 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -592,7 +592,8 @@ gee_destroy_feedback_range (GnmExprEntry *gee)
}
static void
-gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef *rr, int colour)
+gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef *rr, int colour,
+ PangoAttrList **attrs)
{
static struct {
guint16 red;
@@ -605,16 +606,16 @@ gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef
{0x0, 0x80FF, 0x80FF, "00:80:80:ff"},
{0xA0FF, 0xA0FF, 0x0, "a0:a0:00:ff"},
{0xA0FF, 0x0, 0xA0FF, "a0:00:a0:ff"}};
- GtkEntry *entry = gee->entry;
- PangoLayout *layout = gtk_entry_get_layout (entry);
PangoAttribute *at;
- PangoAttrList *list = pango_layout_get_attributes (layout);
GnmRange r;
GnmRange const *merge; /*[#127415]*/
Sheet *start_sheet, *end_sheet;
Sheet *sheet = scg_sheet (gee->scg);
SheetControlGUI *scg = NULL;
+ if (*attrs == NULL)
+ *attrs = pango_attr_list_new ();
+
colour = colour % G_N_ELEMENTS (colours);
gnm_rangeref_normalize_pp (rr, &gee->pp,
@@ -637,10 +638,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););
at = pango_attr_foreground_new (colours[colour].red, colours[colour].green, colours[colour].blue);
- at->start_index = gtk_entry_text_index_to_layout_index (entry, start);
- at->end_index = gtk_entry_text_index_to_layout_index (entry, end);
+ at->start_index = start;
+ at->end_index = end;
- pango_attr_list_change (list, at);
+ pango_attr_list_change (*attrs, at);
}
/* WARNING : DO NOT CALL THIS FROM FROM UPDATE. It may create another
@@ -650,6 +651,8 @@ gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef
static void
gee_scan_for_range (GnmExprEntry *gee)
{
+ PangoAttrList *attrs = NULL;
+
parse_pos_init_editpos (&gee->pp, scg_view (gee->scg));
gee_destroy_feedback_range (gee);
if (!gee->feedback_disabled && gee_is_editing (gee) && gee->lexer_items != NULL) {
@@ -666,11 +669,16 @@ gee_scan_for_range (GnmExprEntry *gee)
&gee->pp, gee_convs (gee));
if (tmp != rtext)
gnm_expr_entry_colour_ranges (gee, gli->start, gli->end, &rr,
- colour++);
+ colour++, &attrs);
g_free (rtext);
}
} while (gli++->token != 0);
}
+ if (attrs)
+ g_object_set_data_full (G_OBJECT (gee->entry), "gnm:range-attributes", attrs,
+ (GDestroyNotify) pango_attr_list_unref);
+ else
+ g_object_set_data (G_OBJECT (gee->entry), "gnm:range-attributes", NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]