[gnumeric] Show the tooltips also for editing on teh sheet, and make sure they close when editing is finished.



commit d1255492b8842bcfefb21771bbf1e1751737eb92
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Mon Jun 14 17:42:28 2010 -0600

    Show the tooltips also for editing on teh sheet, and make sure they close when editing is finished.
    
    2010-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/wbc-gtk-edit.c (wbcg_edit_finish): close the tooltips of
    	  the entry
    
    2010-06-14  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gnumeric-expr-entry.h (gnm_expr_entry_close_tips): new
    	* gnumeric-expr-entry.c (gnm_expr_entry_close_tips): new
    	(gee_check_tooltip): new
    	(cb_entry_changed): connect with gee_check_tooltip
    	(cb_gee_key_press_event): move handling of () into gee_check_tooltip
    	(cb_gee_button_press_event): keep the tool tips

 ChangeLog                         |    5 ++
 src/wbc-gtk-edit.c                |    2 +
 src/widgets/ChangeLog             |    9 ++++
 src/widgets/gnumeric-expr-entry.c |   87 ++++++++++++++++++++++++-------------
 src/widgets/gnumeric-expr-entry.h |    2 +
 5 files changed, 74 insertions(+), 31 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 27c1b7f..f1f9aa9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* src/wbc-gtk-edit.c (wbcg_edit_finish): close the tooltips of
+	  the entry
+
+2010-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* src/func-builtin.c (help_if): fix argument description
 	* src/func.c (gnm_func_sanity_check1): add checks
 
diff --git a/src/wbc-gtk-edit.c b/src/wbc-gtk-edit.c
index e6af0d0..5698770 100644
--- a/src/wbc-gtk-edit.c
+++ b/src/wbc-gtk-edit.c
@@ -100,6 +100,8 @@ wbcg_edit_finish (WBCGtk *wbcg, WBCEditResult result,
 
 	wbcg_focus_cur_scg (wbcg);
 
+	gnm_expr_entry_close_tips (wbcg_get_entry_logical (wbcg));
+
 	if (showed_dialog != NULL)
 		*showed_dialog = FALSE;
 
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 31aa59c..1b47b48 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,5 +1,14 @@
 2010-06-14  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* gnumeric-expr-entry.h (gnm_expr_entry_close_tips): new
+	* gnumeric-expr-entry.c (gnm_expr_entry_close_tips): new
+	(gee_check_tooltip): new
+	(cb_entry_changed): connect with gee_check_tooltip
+	(cb_gee_key_press_event): move handling of () into gee_check_tooltip
+	(cb_gee_button_press_event): keep the tool tips
+
+2010-06-14  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* gnumeric-expr-entry.c (gee_delete_tooltip): watch 
 	  for disappearing entries 
 	(cb_gee_key_press_event): gee_set_tooltip will ref the fd
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index b423489..d45e5d0 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -599,6 +599,15 @@ gee_delete_tooltip (GnmExprEntry *gee)
 	}
 }
 
+void    
+gnm_expr_entry_close_tips  (GnmExprEntry *gee)
+{
+	if (gee != NULL)
+		gee_delete_tooltip (gee);
+}
+
+
+
 static gboolean
 cb_gee_configure_event (GtkWidget         *widget,
 			GdkEventConfigure *event,
@@ -704,10 +713,57 @@ gee_set_tooltip (GnmExprEntry *gee, GnmFunc *fd)
 }
 
 static void
+gee_check_tooltip (GnmExprEntry *gee)
+{
+	GtkEditable *editable = GTK_EDITABLE (gee->entry);
+	gint end;
+	char *str;
+	char *prefix;
+	char *str_end;
+	char last;
+	
+	end = gtk_editable_get_position (editable);
+
+	if (end == 0) {
+		gee_delete_tooltip (gee);
+		return;
+	}
+	
+	str = gtk_editable_get_chars (editable, end, end+1);
+	last = *str;
+	g_free (str);
+
+	if (last == ')') {
+		gee_delete_tooltip (gee);
+		return;		
+	}
+	
+	if (last != '(')
+		return;
+
+	str = gtk_editable_get_chars (editable, 0, end);
+
+	prefix = str_end = str + strlen (str);
+	do {prefix--;} while (prefix >= str && (('a' <= *prefix && *prefix <= 'z') ||
+						('a' <= *prefix && *prefix <= 'z')));
+	prefix++;
+	
+	if (prefix < str_end) {
+		GnmFunc	   *fd = gnm_func_lookup (prefix, NULL);
+		if (fd != NULL)
+			gee_set_tooltip (gee, fd);
+	}
+	
+	g_free (str);
+
+}
+
+static void
 cb_entry_changed (GnmExprEntry *gee)
 {
 	gee_update_env (gee);
 	gee_update_calendar (gee);
+	gee_check_tooltip (gee);
 	g_signal_emit (G_OBJECT (gee), signals[CHANGED], 0);
 }
 
@@ -896,36 +952,6 @@ cb_gee_key_press_event (GtkEntry	*entry,
 		return TRUE;
 	}
 
-	case GDK_parenright: {
-		gee_delete_tooltip (gee);
-		return FALSE;
-	}
-
-	case GDK_parenleft: {
-		/* Create tooltip with the syntax of the current function */
-		GtkEditable *editable = GTK_EDITABLE (entry);
-		gint end;
-		char *str;
-		char *prefix;
-		char *str_end;
-
-		end = gtk_editable_get_position (editable);
-		str = gtk_editable_get_chars (editable, 0, end);
-		prefix = str_end = str + strlen (str);
-		do {prefix--;} while (prefix >= str && (('a' <= *prefix && *prefix <= 'z') ||
-						       ('a' <= *prefix && *prefix <= 'z')));
-		prefix++;
-		
-		if (prefix < str_end) {
-			GnmFunc	   *fd = gnm_func_lookup (prefix, NULL);
-			if (fd != NULL)
-				gee_set_tooltip (gee, fd);
-		}
-
-		g_free (str);
-		return FALSE;
-	}
-
 	default:
 		break;
 	}
@@ -944,7 +970,6 @@ cb_gee_button_press_event (G_GNUC_UNUSED GtkEntry *entry,
 		scg_rangesel_stop (gee->scg, FALSE);
 		gnm_expr_entry_find_range (gee);
 		g_signal_emit (G_OBJECT (gee), signals[CHANGED], 0);
-		gee_delete_tooltip (gee);
 	}
 
 	return FALSE;
diff --git a/src/widgets/gnumeric-expr-entry.h b/src/widgets/gnumeric-expr-entry.h
index 3edcdb1..68884a6 100644
--- a/src/widgets/gnumeric-expr-entry.h
+++ b/src/widgets/gnumeric-expr-entry.h
@@ -76,6 +76,8 @@ void gnm_expr_entry_grab_focus (GnmExprEntry *gee, gboolean select_all);
 void    gnm_expr_entry_disable_highlight (GnmExprEntry *gee);
 void    gnm_expr_entry_enable_highlight  (GnmExprEntry *gee);
 
+void    gnm_expr_entry_close_tips  (GnmExprEntry *gee);
+
 /* Cell Renderer Specific Method */
 
 gboolean gnm_expr_entry_editing_canceled (GnmExprEntry *gee);



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