[gnumeric] Show range selection cursors even while selecting new regions
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Show range selection cursors even while selecting new regions
- Date: Sat, 26 Nov 2011 00:16:07 +0000 (UTC)
commit a7f83526b1a1ede8f13a91ec62ec9b4decae22bf
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Fri Nov 25 17:15:27 2011 -0700
Show range selection cursors even while selecting new regions
2011-11-25 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/gnm-pane.h (gnm_pane_expr_cursor_bound_set): change argument of
gnm_pane_expr_cursor_bound_set
* src/gnm-pane.c (gnm_pane_expr_cursor_bound_set): change argument of
gnm_pane_expr_cursor_bound_set, receive the colour to use.
(gnm_pane_rangesel_stop): do not enable highlights
(gnm_pane_rangesel_start): do not disable highlights
2011-11-25 Andreas J. Guelzow <aguelzow pyrshep ca>
* gnumeric-expr-entry.c (gnm_expr_entry_colour_ranges): new
(gee_scan_for_range): use gnm_expr_entry_colour_ranges
ChangeLog | 9 +++
NEWS | 3 +
src/gnm-pane.c | 13 +---
src/gnm-pane.h | 2 +-
src/widgets/ChangeLog | 5 ++
src/widgets/gnumeric-expr-entry.c | 142 +++++++++++++++++--------------------
6 files changed, 84 insertions(+), 90 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 662e95d..4480f0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-11-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/gnm-pane.h (gnm_pane_expr_cursor_bound_set): change argument of
+ gnm_pane_expr_cursor_bound_set
+ * src/gnm-pane.c (gnm_pane_expr_cursor_bound_set): change argument of
+ gnm_pane_expr_cursor_bound_set, receive the colour to use.
+ (gnm_pane_rangesel_stop): do not enable highlights
+ (gnm_pane_rangesel_start): do not disable highlights
+
2011-11-24 Morten Welinder <terra gnome org>
* configure.in: Post-release bump.
diff --git a/NEWS b/NEWS
index b6aeaed..6a1a712 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.11.1
+Andreas:
+ * Show range selection cursors even while selecting new regions
+
Morten:
* Build fixes relating to embedded ui files [#664828]
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index cc5b178..0e81aa7 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -2161,8 +2161,6 @@ gnm_pane_rangesel_start (GnmPane *pane, GnmRange const *r)
* and we are selecting on a different sheet than the expr being edited */
if (scg_sheet (scg) != wb_control_cur_sheet (scg_wbc (scg)))
item_cursor_set_visibility (pane->cursor.std, FALSE);
- if (NULL != gee)
- gnm_expr_entry_disable_highlight (gee);
item = goc_item_new (pane->grid_items,
item_cursor_get_type (),
"SheetControlGUI", scg,
@@ -2176,8 +2174,6 @@ void
gnm_pane_rangesel_stop (GnmPane *pane)
{
GnmExprEntry *gee = wbcg_get_entry_logical (pane->simple.scg->wbcg);
- if (NULL != gee)
- gnm_expr_entry_enable_highlight (gee);
g_return_if_fail (pane->cursor.rangesel != NULL);
g_object_unref (G_OBJECT (pane->cursor.rangesel));
@@ -2237,21 +2233,16 @@ gnm_pane_mouse_cursor_set (GnmPane *pane, GdkCursor *c)
void
gnm_pane_expr_cursor_bound_set (GnmPane *pane, GnmRange const *r,
- gboolean main_color)
+ gchar const *color)
{
- gchar const *colours[5]
- = {"green","yellow", "orange", "red", "purple"};
- gint i;
ItemCursor *cursor;
- i = g_slist_length (pane->cursor.expr_range) % 5;
-
cursor = (ItemCursor *) goc_item_new
(GOC_GROUP (GOC_CANVAS (pane)->root),
item_cursor_get_type (),
"SheetControlGUI", pane->simple.scg,
"style", ITEM_CURSOR_EXPR_RANGE,
- "color", main_color ? "blue" : colours[i],
+ "color", color,
NULL);
item_cursor_bound_set (cursor, r);
diff --git a/src/gnm-pane.h b/src/gnm-pane.h
index 9fd7987..b71c85e 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,
- gboolean main_color);
+ gchar const *color);
void gnm_pane_expr_cursor_stop (GnmPane *pane);
/************************************************************************/
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 779412d..4479d3c 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-25 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * gnumeric-expr-entry.c (gnm_expr_entry_colour_ranges): new
+ (gee_scan_for_range): use gnm_expr_entry_colour_ranges
+
2011-11-24 Morten Welinder <terra gnome org>
* Release 1.11.0
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 1bbda66..411605a 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -585,6 +585,52 @@ gee_destroy_feedback_range (GnmExprEntry *gee)
gnm_pane_expr_cursor_stop (pane););
}
+static void
+gnm_expr_entry_colour_ranges (GnmExprEntry *gee, int start, int end, GnmRangeRef *rr, int colour)
+{
+ static struct {
+ guint16 red;
+ guint16 green;
+ guint16 blue;
+ gchar const *name;
+ } colours[] = {{0x0, 0x0, 0xFFFF, "00:00:ff:ff"},
+ {0x0, 0xFFFF, 0x0, "00:ff:00: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"}};
+ 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);
+
+ colour = colour % G_N_ELEMENTS (colours);
+
+ gnm_rangeref_normalize_pp (rr, &gee->pp,
+ &start_sheet,
+ &end_sheet,
+ &r);
+ if (start_sheet != sheet ||
+ end_sheet != sheet)
+ return;
+ if (range_is_singleton (&r) &&
+ NULL != (merge = gnm_sheet_merge_is_corner
+ (sheet, &r.start)))
+ r = *merge;
+
+ SCG_FOREACH_PANE (gee->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);
+
+ pango_attr_list_change (list, at);
+}
+
/* WARNING : DO NOT CALL THIS FROM FROM UPDATE. It may create another
* canvas-item which would in turn call update and confuse the
* canvas.
@@ -592,87 +638,26 @@ gee_destroy_feedback_range (GnmExprEntry *gee)
static void
gee_scan_for_range (GnmExprEntry *gee)
{
- GnmRange range;
- Sheet *sheet = scg_sheet (gee->scg);
- Sheet *parse_sheet;
-
parse_pos_init_editpos (&gee->pp, scg_view (gee->scg));
gee_destroy_feedback_range (gee);
- if (!gee->feedback_disabled && gee_is_editing (gee)) {
- if (gee->texpr != NULL) {
- GSList *ptr;
- GSList *list = gnm_expr_top_get_ranges (gee->texpr);
- for (ptr = list ; ptr != NULL ; ptr = ptr->next) {
- GnmValue *v = ptr->data;
- GnmRange r;
- Sheet *start_sheet, *end_sheet;
- GnmRangeRef const *rr = value_get_rangeref (v);
- GnmRange const *merge; /* [#127415] */
- gnm_rangeref_normalize_pp (rr, &gee->pp,
- &start_sheet,
- &end_sheet,
- &r);
-
- if (start_sheet != sheet || end_sheet != sheet)
- continue;
- if (range_is_singleton (&r) &&
- NULL != (merge = gnm_sheet_merge_is_corner
- (sheet, &r.start)))
- r = *merge;
- SCG_FOREACH_PANE (gee->scg, pane,
- gnm_pane_expr_cursor_bound_set
- (pane, &r, FALSE););
+ if (!gee->feedback_disabled && gee_is_editing (gee) && gee->lexer_items != NULL) {
+ GnmLexerItem *gli = gee->lexer_items;
+ int colour = 0;
+ do {
+ if (gli->token == RANGEREF) {
+ char const *text = gtk_entry_get_text (gee->entry);
+ char *rtext = g_strndup (text + gli->start,
+ gli->end - gli->start);
+ char const *tmp;
+ GnmRangeRef rr;
+ tmp = rangeref_parse (&rr, rtext,
+ &gee->pp, gee_convs (gee));
+ if (tmp != rtext)
+ gnm_expr_entry_colour_ranges (gee, gli->start, gli->end, &rr,
+ colour++);
+ g_free (rtext);
}
-
- g_slist_free_full (list, (GDestroyNotify)value_release);
- } else if (gee->lexer_items != NULL) {
- GnmLexerItem *gli = gee->lexer_items;
- do {
- if (gli->token == RANGEREF) {
- char const *text = gtk_entry_get_text (gee->entry);
- char *rtext = g_strndup (text + gli->start,
- gli->end - gli->start);
- char const *tmp;
- GnmRangeRef rr;
- tmp = rangeref_parse (&rr, rtext,
- &gee->pp, gee_convs (gee));
- if (tmp != rtext) {
- GnmRange r;
- GnmRange const *merge; /* [#127415] */
- Sheet *start_sheet, *end_sheet;
- gnm_rangeref_normalize_pp (&rr, &gee->pp,
- &start_sheet,
- &end_sheet,
- &r);
- if (start_sheet != sheet ||
- end_sheet != sheet)
- continue;
- if (range_is_singleton (&r) &&
- NULL != (merge = gnm_sheet_merge_is_corner
- (sheet, &r.start)))
- r = *merge;
- SCG_FOREACH_PANE
- (gee->scg, pane,
- gnm_pane_expr_cursor_bound_set
- (pane, &r, FALSE););
- }
- g_free (rtext);
- }
- } while (gli++->token != 0);
- }
- gnm_expr_entry_find_range (gee);
- if (gnm_expr_entry_get_rangesel (gee, &range, &parse_sheet) &&
- parse_sheet == sheet) {
- GnmRange const *merge; /* [#127415] */
- if (range_is_singleton (&range) &&
- NULL != (merge = gnm_sheet_merge_is_corner
- (parse_sheet, &range.start)))
- range = *merge;
-
- SCG_FOREACH_PANE (gee->scg, pane,
- gnm_pane_expr_cursor_bound_set
- (pane, &range, TRUE););
- }
+ } while (gli++->token != 0);
}
}
@@ -2778,6 +2763,7 @@ gnm_expr_entry_enable_highlight (GnmExprEntry *gee)
g_return_if_fail (gee != NULL);
gee->feedback_disabled = FALSE;
gee_update_lexer_items (gee);
+ gee_scan_for_range (gee);
}
/*****************************************************************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]