[gnumeric] Show all ranges while editing a range.



commit e66742cc31e37c174b0be00a6b95b9a3526a464e
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Jun 11 11:37:07 2010 -0600

    Show all ranges while editing a range.
    
    2010-06-10 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/gnm-pane-impl.h: make cursor.expr_range into a GSList
    	* src/gnm-pane.h (gnm_pane_expr_cursor_bound_set): add main_colour arg
    	* src/gnm-pane.c (gnm_pane_expr_cursor_bound_set): add main_colour
    	  arg and don't delete existing cursors
    
    2010-06-11  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gnumeric-expr-entry.c (gee_scan_for_range): create cursors for all
    	  ranges

 ChangeLog                         |    7 +++++
 NEWS                              |    1 +
 src/gnm-pane-impl.h               |    2 +-
 src/gnm-pane.c                    |   48 ++++++++++++++++++++-------------
 src/gnm-pane.h                    |    3 +-
 src/widgets/ChangeLog             |    5 +++
 src/widgets/gnumeric-expr-entry.c |   53 +++++++++++++++++++++++++++++++-----
 7 files changed, 90 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index eee5858..074fe7d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,13 @@
 
 2010-06-10 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* src/gnm-pane-impl.h: make cursor.expr_range into a GSList
+	* src/gnm-pane.h (gnm_pane_expr_cursor_bound_set): add main_colour arg 
+	* src/gnm-pane.c (gnm_pane_expr_cursor_bound_set): add main_colour 
+	  arg and don't delete existing cursors
+
+2010-06-10 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* src/func-builtin.c (help_if): remove inconsistent period
 	
 2010-06-10  Morten Welinder  <terra gnome org>
diff --git a/NEWS b/NEWS
index 37e8697..12ac94d 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ Andreas:
 	* Improve ACCRINT and its description. [#611436]
 	* Fix tests for homogeneity and independence for non-square
 	  tables. [#621227]
+	* Show all ranges while editing a range.
 
 Jean:
 	* Do not ungrab a not grabbed item. [#620369]
diff --git a/src/gnm-pane-impl.h b/src/gnm-pane-impl.h
index 1ffe0f3..47ae6c8 100644
--- a/src/gnm-pane-impl.h
+++ b/src/gnm-pane-impl.h
@@ -63,7 +63,7 @@ struct _GnmPane {
 		ItemCursor *std, *rangesel, *special;
 		GSList *animated;
 
-		ItemCursor *expr_range;	/* highlight refs while editing */
+		GSList *expr_range;	/* highlight refs while editing */
 	} cursor;
 
 	struct {
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 9ffb4cd..841a5d8 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -855,6 +855,8 @@ gnm_pane_dispose (GObject *obj)
 
 	g_slist_free (pane->cursor.animated);
 	pane->cursor.animated = NULL;
+	go_slist_free_custom (pane->cursor.expr_range, g_object_unref);
+	pane->cursor.expr_range = NULL;
 
 	if (pane->mouse_cursor) {
 		gdk_cursor_unref (pane->mouse_cursor);
@@ -871,7 +873,7 @@ gnm_pane_dispose (GObject *obj)
 	 * unexpectedly.  */
 	pane->grid = NULL;
 	pane->editor = NULL;
-	pane->cursor.std = pane->cursor.rangesel = pane->cursor.special = pane->cursor.expr_range = NULL;
+	pane->cursor.std = pane->cursor.rangesel = pane->cursor.special = NULL;
 	pane->size_guide.guide = NULL;
 	pane->size_guide.start = NULL;
 	pane->size_guide.points = NULL;
@@ -2068,8 +2070,8 @@ gnm_pane_reposition_cursors (GnmPane *pane)
 		item_cursor_reposition (pane->cursor.rangesel);
 	if (NULL != pane->cursor.special)
 		item_cursor_reposition (pane->cursor.special);
-	if (NULL != pane->cursor.expr_range)
-		item_cursor_reposition (ITEM_CURSOR (pane->cursor.expr_range));
+	for (l = pane->cursor.expr_range; l; l = l->next)
+		item_cursor_reposition (ITEM_CURSOR (l->data));
 	for (l = pane->cursor.animated; l; l = l->next)
 		item_cursor_reposition (ITEM_CURSOR (l->data));
 
@@ -2178,28 +2180,36 @@ gnm_pane_mouse_cursor_set (GnmPane *pane, GdkCursor *c)
 
 /****************************************************************************/
 
+
 void
-gnm_pane_expr_cursor_bound_set (GnmPane *pane, GnmRange const *r)
-{
-	if (NULL == pane->cursor.expr_range)
-		pane->cursor.expr_range = (ItemCursor *) goc_item_new (
-			GOC_GROUP (GOC_CANVAS (pane)->root),
-			item_cursor_get_type (),
-			"SheetControlGUI",	pane->simple.scg,
-			"style",		ITEM_CURSOR_EXPR_RANGE,
-			"color",		"blue",
-			NULL);
+gnm_pane_expr_cursor_bound_set (GnmPane *pane, GnmRange const *r, 
+				gboolean main_color)
+{
+	gchar const *colours[5] 
+		= {"green","yellow", "orange", "red", "purple"};
+	gint i;
+	ItemCursor *cursor;
 
-	item_cursor_bound_set (pane->cursor.expr_range, r);
+	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],
+		 NULL);
+
+	item_cursor_bound_set (cursor, r);
+	pane->cursor.expr_range = g_slist_prepend 
+		(pane->cursor.expr_range, cursor);
 }
 
 void
 gnm_pane_expr_cursor_stop (GnmPane *pane)
 {
-	if (NULL != pane->cursor.expr_range) {
-		g_object_unref (G_OBJECT (pane->cursor.expr_range));
-		pane->cursor.expr_range = NULL;
-	}
+	go_slist_free_custom (pane->cursor.expr_range, g_object_unref);
+	pane->cursor.expr_range = NULL;
 }
 
 /****************************************************************************/
diff --git a/src/gnm-pane.h b/src/gnm-pane.h
index 2112393..41ddc4e 100644
--- a/src/gnm-pane.h
+++ b/src/gnm-pane.h
@@ -42,7 +42,8 @@ gboolean gnm_pane_special_cursor_bound_set (GnmPane *pane, GnmRange const *r);
 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);
+void	 gnm_pane_expr_cursor_bound_set    (GnmPane *pane, GnmRange const *r,
+					    gboolean main_color);
 void	 gnm_pane_expr_cursor_stop	   (GnmPane *pane);
 
 /************************************************************************/
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 0b354b0..2e4b88c 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-11  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* gnumeric-expr-entry.c (gee_scan_for_range): create cursors for all
+	  ranges
+
 2010-06-08  Jean Brefort  <jean brefort normalesup org>
 
 	* gnumeric-expr-entry.c (gnm_expr_entry_parse): do not update the wrong
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index cb2096a..2bc7071 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -494,25 +494,62 @@ gee_scan_for_range (GnmExprEntry *gee)
 	GnmRange  range;
 	Sheet *sheet = scg_sheet (gee->scg);
 	Sheet *parse_sheet;
+	gboolean in_editing;
 
 	parse_pos_init_editpos (&gee->pp, scg_view (gee->scg));
+	gee_destroy_feedback_range (gee);
 	if (!gee->feedback_disabled) {
 		gnm_expr_entry_find_range (gee);
+		in_editing = gnm_expr_entry_get_rangesel (gee, &range, &parse_sheet);
+#warning This is only tells us we are editing if we are even in a range.
+
+		if (in_editing) {
+			char const *text = gtk_entry_get_text (gee->entry);
+			GnmParsePos pp;
+			GnmExprTop const *texpr;
+			parse_pos_init_sheet (&pp, sheet);
+			if ((texpr = gnm_expr_parse_str 
+			     ((text[0] == '=') ? text+1 : text, &pp, GNM_EXPR_PARSE_DEFAULT,
+			      sheet_get_conventions (sheet), NULL))!= NULL) {
+				GSList *ptr;
+				GSList *list = gnm_expr_top_get_ranges (texpr);
+#warning FIXME: gnm_expr_top_get_ranges does not delete duplicates!
+				for (ptr = list ; ptr != NULL ; ptr = ptr->next) {
+					GnmValue *v = ptr->data;
+					GnmRange  r;
+					GnmRangeRef const *rr = value_get_rangeref (v);
+					GnmRange const *merge; /* [#127415] */
+					if (rr->a.sheet != NULL && rr->a.sheet != sheet)
+						continue;
+					if (rr->b.sheet != NULL && rr->b.sheet != sheet)
+						continue;
+					range_init_rangeref (&r, rr);
+					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););
+				}
+				
+				go_slist_free_custom (list, (GFreeFunc)value_release);
+				gnm_expr_top_unref (texpr);
+			}
+		}
 		if (gnm_expr_entry_get_rangesel (gee, &range, &parse_sheet) &&
 		    parse_sheet == sheet) {
-
-			GnmRange const *merge; /* [#127415] */
+			GnmRange const *merge; /* [#127415] */			
 			if (range_is_singleton  (&range) &&
-			    NULL != (merge = gnm_sheet_merge_is_corner (parse_sheet, &range.start)))
+			    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););
-			return;
+					  gnm_pane_expr_cursor_bound_set 
+					  (pane, &range, TRUE););
 		}
 	}
-
-	gee_destroy_feedback_range (gee);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]