[gnumeric] Delay function completion tooltip. [#668683]



commit 3c47e7a766fc18f3053218ff0af5d25477aa0d16
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Feb 21 21:14:51 2012 -0700

    Delay function completion tooltip. [#668683]
    
    2012-02-21  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gnumeric-expr-entry.c (gee_delete_tooltip): return info on
    	tooltip visibility, clear appearance timer
    	(cb_show_tooltip): new
    	(gee_create_tooltip): don't show tooltip
    	(gee_set_tooltip): show tooltip
    	(gee_set_tooltip_completion): delay first tooltip

 NEWS                              |    1 +
 src/widgets/ChangeLog             |    9 ++++++++
 src/widgets/gnumeric-expr-entry.c |   39 +++++++++++++++++++++++++++++++-----
 3 files changed, 43 insertions(+), 6 deletions(-)
---
diff --git a/NEWS b/NEWS
index 0f2f581..a4593d7 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Andreas:
 	* Implement ctrl-click cell deselection. [#610696]
 	* Fix LaTeX export of cyrillic. [#666340]
 	* Fix function tool tip. [#668685]
+	* Delay function completion tooltip. [#668683]
 	* Import inline text from xlsx files. [#668936]
 	* Fix rich text import from xlsx. [#669083]
 	* Fix data shuffle. [#669184]
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 5caec1a..aa7c49c 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,12 @@
+2012-02-21  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* gnumeric-expr-entry.c (gee_delete_tooltip): return info on
+	tooltip visibility, clear appearance timer
+	(cb_show_tooltip): new
+	(gee_create_tooltip): don't show tooltip
+	(gee_set_tooltip): show tooltip
+	(gee_set_tooltip_completion): delay first tooltip
+
 2012-01-27  Morten Welinder  <terra gnome org>
 
 	* gnumeric-expr-entry.c (gnm_expr_entry_find_range): Default to
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 2de11e4..27fae80 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -137,6 +137,7 @@ struct _GnmExprEntry {
 		gint             args;
 		gboolean         had_stuff;
 		gulong           handlerid;
+		guint            timerid;
 		gboolean         enabled;
 		gboolean         is_expr;
 		gboolean         completion_se_valid;
@@ -728,9 +729,16 @@ gee_update_env (GnmExprEntry *gee)
 
 }
 
-static void
+static gboolean
 gee_delete_tooltip (GnmExprEntry *gee, gboolean remove_completion)
 {
+	gboolean has_tooltip = (gee->tooltip.tooltip != NULL && 
+				gee->tooltip.timerid == 0);
+
+	if (gee->tooltip.timerid) {
+		g_source_remove (gee->tooltip.timerid);
+		gee->tooltip.timerid = 0;
+	}
 	if (gee->tooltip.tooltip) {
 		gtk_widget_destroy (gee->tooltip.tooltip);
 		gee->tooltip.tooltip = NULL;
@@ -750,6 +758,7 @@ gee_delete_tooltip (GnmExprEntry *gee, gboolean remove_completion)
 		gee->tooltip.completion = NULL;
 		gee->tooltip.completion_se_valid = FALSE;
 	}
+	return has_tooltip;
 }
 
 void
@@ -764,6 +773,16 @@ cb_gee_focus_out_event (GtkWidget         *widget,
 			GdkEventFocus     *event,
 			gpointer           user_data);
 
+static gboolean 
+cb_show_tooltip (gpointer user_data)
+{
+	GnmExprEntry *gee = GNM_EXPR_ENTRY (user_data);
+	gtk_widget_show_all (gee->tooltip.tooltip);
+	gee->tooltip.timerid = 0;
+	return FALSE;
+}
+
+
 static GtkWidget *
 gee_create_tooltip (GnmExprEntry *gee, gchar const *str,
 		    gchar const *marked_str, gboolean set_tabs)
@@ -829,8 +848,6 @@ gee_create_tooltip (GnmExprEntry *gee, gchar const *str,
 			 root_x + allocation.x,
 			 root_y + allocation.y + allocation.height);
 
-	gtk_widget_show_all (tip);
-
 	return tip;
 }
 
@@ -919,6 +936,7 @@ gee_set_tooltip (GnmExprEntry *gee, GnmFunc *fd, gint args, gboolean had_stuff)
 
 	gee->tooltip.tooltip = gee_create_tooltip
 		(gee, str->str, _("\n\n<i>Ctrl-F4 to close tooltip</i>"), FALSE);
+	gtk_widget_show_all (gee->tooltip.tooltip);
 	gee->tooltip.args = args;
 	gee->tooltip.had_stuff = (max == 0 && args == 0 && had_stuff);
 
@@ -934,10 +952,10 @@ gee_set_tooltip_completion (GnmExprEntry *gee, GSList *list, guint start, guint
 	gint max = 10;
 	GSList *list_c = list;
 	gchar const *name = NULL;
-	gboolean show_tool_tip;
+	gboolean show_tool_tip, had_tool_tip;
 	gboolean localized_function_names = gee->sheet->convs->localized_function_names;
 
-	gee_delete_tooltip (gee, TRUE);
+	had_tool_tip = gee_delete_tooltip (gee, TRUE);
 
 	str = g_string_new (NULL);
 	for (; list_c != NULL && ++i < max; list_c = list_c->next) {
@@ -974,9 +992,18 @@ gee_set_tooltip_completion (GnmExprEntry *gee, GSList *list, guint start, guint
 	gee->tooltip.completion_end = end;
 	gee->tooltip.completion_se_valid = TRUE;
 	show_tool_tip = gnm_conf_get_core_gui_editing_function_name_tooltips ();
-	if (show_tool_tip)
+	if (show_tool_tip) {
 		gee->tooltip.tooltip = gee_create_tooltip
 			(gee, str->str, str_marked->str, TRUE);
+		if (had_tool_tip)
+			gtk_widget_show_all (gee->tooltip.tooltip);
+		else
+			gee->tooltip.timerid = g_timeout_add_full 
+				(G_PRIORITY_DEFAULT, 750, 
+				 cb_show_tooltip, 
+				 gee, 
+				 NULL);
+	}
 	g_string_free (str, TRUE);
 	g_string_free (str_marked, TRUE);
 	g_slist_free_full (list, (GDestroyNotify) gnm_func_unref);



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