[gnumeric] Add preference settings whether to show function name and/or argument tooltips.



commit a42075f67fe60032b3b773b3ca8e7da82f461ffd
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Thu Jul 22 13:21:23 2010 -0600

    Add preference settings whether to show function name and/or argument tooltips.
    
    2010-07-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gnumeric-expr-entry.c (gee_set_tooltip): don't remove the completion
    	(gee_set_tooltip_completion): return whether the tool tip was shown,
    	  check the preference setting.
    	(gee_check_tooltip): check the preference setting and watch the return
    	  value of gee_set_tooltip_completion
    
    2010-07-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* schemas/gnumeric-general.schemas.in: add tooltip preferences
    	* src/gnumeric-gconf.h
    	(gnm_conf_*et_core_gui_editing_function_argument_tooltips*): new
    	* src/gnumeric-gconf.c
    	(gnm_conf_*et_core_gui_editing_function_name_tooltips*): new
    
    2010-07-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* dialog-function-select.c (pref_tool_page_initializer): add checkboxes
    	  for tooltip preferences

 ChangeLog                           |    8 +++++
 NEWS                                |    6 +++-
 schemas/gnumeric-general.schemas.in |   22 +++++++++++++++
 src/dialogs/ChangeLog               |    5 +++
 src/dialogs/dialog-preferences.c    |   10 +++++++
 src/gnumeric-gconf.c                |   52 +++++++++++++++++++++++++++++++++++
 src/gnumeric-gconf.h                |    8 +++++
 src/widgets/ChangeLog               |   10 ++++++-
 src/widgets/gnumeric-expr-entry.c   |   40 +++++++++++++++++++--------
 9 files changed, 146 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c88887e..f4f28c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-07-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* schemas/gnumeric-general.schemas.in: add tooltip preferences
+	* src/gnumeric-gconf.h
+	(gnm_conf_*et_core_gui_editing_function_argument_tooltips*): new
+	* src/gnumeric-gconf.c
+	(gnm_conf_*et_core_gui_editing_function_name_tooltips*): new
+
 2010-07-21  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/func.h (GNM_FUNC_RECALC_ONLOAD): not used
diff --git a/NEWS b/NEWS
index cbb7bc5..692ab0a 100644
--- a/NEWS
+++ b/NEWS
@@ -41,8 +41,10 @@ Andreas:
 	* Make the font style buttons override the character attributes. 
 	  [#163410]
 	* Provide name completion (F4) when entering functions. [#587084]
-	* Implement access to the function selector to paste function names
-	  while editing cells (Shift-F4).
+	* Implement access to the function selector to paste function
+	  names while editing cells (Shift-F4).
+	* Add preference settings whether to show function name and/or
+	  argument tooltips.
 
 Jean:
 	* Fix strong/weak cursor display. [#623241]
diff --git a/schemas/gnumeric-general.schemas.in b/schemas/gnumeric-general.schemas.in
index ae11782..2b5a034 100644
--- a/schemas/gnumeric-general.schemas.in
+++ b/schemas/gnumeric-general.schemas.in
@@ -267,6 +267,28 @@
         </locale>
       </schema>
       <schema>
+        <key>/schemas/apps/gnumeric/core/gui/editing/function-name-tooltips</key>
+        <applyto>/apps/gnumeric/core/gui/editing/function-name-tooltips</applyto>
+        <owner>Gnumeric</owner>
+        <type>bool</type>
+	<default>TRUE</default>
+        <locale name="C">
+        <short>Show Function Name Tooltips</short>
+        <long>This variable determines whether to show function name tooltips.</long>
+        </locale>
+      </schema>
+      <schema>
+        <key>/schemas/apps/gnumeric/core/gui/editing/function-argument-tooltips</key>
+        <applyto>/apps/gnumeric/core/gui/editing/function-argument-tooltips</applyto>
+        <owner>Gnumeric</owner>
+        <type>bool</type>
+	<default>TRUE</default>
+        <locale name="C">
+        <short>Show Function Argument Tooltips</short>
+        <long>This variable determines whether to show function argument tooltips.</long>
+        </locale>
+      </schema>
+      <schema>
         <key>/schemas/apps/gnumeric/core/gui/editing/enter_moves_dir</key>
         <applyto>/apps/gnumeric/core/gui/editing/enter_moves_dir</applyto>
         <owner>Gnumeric</owner>
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index f83f177..f2d2bf5 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2010-07-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* dialog-function-select.c (pref_tool_page_initializer): add checkboxes
+	  for tooltip preferences
+
 2010-07-21  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* dialog-function-select.c (dialog_function_select_load_tree): dont load
diff --git a/src/dialogs/dialog-preferences.c b/src/dialogs/dialog-preferences.c
index a5b177d..9d7c67d 100644
--- a/src/dialogs/dialog-preferences.c
+++ b/src/dialogs/dialog-preferences.c
@@ -1027,6 +1027,16 @@ pref_tool_page_initializer (PrefState *state,
 				 gnm_conf_set_core_gui_editing_autocomplete,
 				 gnm_conf_get_core_gui_editing_autocomplete,
 				_("Autocomplete"));
+	bool_pref_create_widget (gnm_conf_get_core_gui_editing_function_name_tooltips_node (),
+				 page, row++,
+				 gnm_conf_set_core_gui_editing_function_name_tooltips,
+				 gnm_conf_get_core_gui_editing_function_name_tooltips,
+				_("Show Function Name Tooltips"));
+	bool_pref_create_widget (gnm_conf_get_core_gui_editing_function_argument_tooltips_node (),
+				 page, row++,
+				 gnm_conf_set_core_gui_editing_function_argument_tooltips,
+				 gnm_conf_get_core_gui_editing_function_argument_tooltips,
+				_("Show Function Argument Tooltips"));
 	bool_pref_create_widget (gnm_conf_get_dialogs_rs_unfocused_node (),
 				 page, row++,
 				 gnm_conf_set_dialogs_rs_unfocused,
diff --git a/src/gnumeric-gconf.c b/src/gnumeric-gconf.c
index 320d3c3..65b1521 100644
--- a/src/gnumeric-gconf.c
+++ b/src/gnumeric-gconf.c
@@ -1128,6 +1128,58 @@ gnm_conf_get_core_gui_editing_enter_moves_dir_node (void)
 	return get_node (watch_core_gui_editing_enter_moves_dir.key);
 }
 
+static struct cb_watch_bool watch_core_gui_editing_function_argument_tooltips = {
+	0, "core/gui/editing/function-argument-tooltips", TRUE,
+};
+
+gboolean
+gnm_conf_get_core_gui_editing_function_argument_tooltips (void)
+{
+	if (!watch_core_gui_editing_function_argument_tooltips.handler)
+		watch_bool (&watch_core_gui_editing_function_argument_tooltips);
+	return watch_core_gui_editing_function_argument_tooltips.var;
+}
+
+void
+gnm_conf_set_core_gui_editing_function_argument_tooltips (gboolean x)
+{
+	if (!watch_core_gui_editing_function_argument_tooltips.handler)
+		watch_bool (&watch_core_gui_editing_function_argument_tooltips);
+	set_bool (&watch_core_gui_editing_function_argument_tooltips, x);
+}
+
+GOConfNode *
+gnm_conf_get_core_gui_editing_function_argument_tooltips_node (void)
+{
+	return get_node (watch_core_gui_editing_function_argument_tooltips.key);
+}
+
+static struct cb_watch_bool watch_core_gui_editing_function_name_tooltips = {
+	0, "core/gui/editing/function-name-tooltips", TRUE,
+};
+
+gboolean
+gnm_conf_get_core_gui_editing_function_name_tooltips (void)
+{
+	if (!watch_core_gui_editing_function_name_tooltips.handler)
+		watch_bool (&watch_core_gui_editing_function_name_tooltips);
+	return watch_core_gui_editing_function_name_tooltips.var;
+}
+
+void
+gnm_conf_set_core_gui_editing_function_name_tooltips (gboolean x)
+{
+	if (!watch_core_gui_editing_function_name_tooltips.handler)
+		watch_bool (&watch_core_gui_editing_function_name_tooltips);
+	set_bool (&watch_core_gui_editing_function_name_tooltips, x);
+}
+
+GOConfNode *
+gnm_conf_get_core_gui_editing_function_name_tooltips_node (void)
+{
+	return get_node (watch_core_gui_editing_function_name_tooltips.key);
+}
+
 static struct cb_watch_bool watch_core_gui_editing_livescrolling = {
 	0, "core/gui/editing/livescrolling", TRUE,
 };
diff --git a/src/gnumeric-gconf.h b/src/gnumeric-gconf.h
index 41cbfe7..0ad20c6 100644
--- a/src/gnumeric-gconf.h
+++ b/src/gnumeric-gconf.h
@@ -105,6 +105,14 @@ GOConfNode *gnm_conf_get_core_gui_editing_enter_moves_dir_node (void);
 GODirection gnm_conf_get_core_gui_editing_enter_moves_dir (void);
 void gnm_conf_set_core_gui_editing_enter_moves_dir (GODirection);
 
+GOConfNode *gnm_conf_get_core_gui_editing_function_argument_tooltips_node (void);
+gboolean gnm_conf_get_core_gui_editing_function_argument_tooltips (void);
+void gnm_conf_set_core_gui_editing_function_argument_tooltips (gboolean);
+
+GOConfNode *gnm_conf_get_core_gui_editing_function_name_tooltips_node (void);
+gboolean gnm_conf_get_core_gui_editing_function_name_tooltips (void);
+void gnm_conf_set_core_gui_editing_function_name_tooltips (gboolean);
+
 GOConfNode *gnm_conf_get_core_gui_editing_livescrolling_node (void);
 gboolean gnm_conf_get_core_gui_editing_livescrolling (void);
 void gnm_conf_set_core_gui_editing_livescrolling (gboolean);
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index f2d7f6e..260dab5 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,6 +1,14 @@
+2010-07-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* gnumeric-expr-entry.c (gee_set_tooltip): don't remove the completion
+	(gee_set_tooltip_completion): return whether the tool tip was shown, 
+	  check the preference setting.
+	(gee_check_tooltip): check the preference setting and watch the return
+	  value of gee_set_tooltip_completion
+
 2010-07-21  Andreas J. Guelzow <aguelzow pyrshep ca>
 
-	* gnumeric-expr-entry.c (gee_check_tooltip): zero teh correct token
+	* gnumeric-expr-entry.c (gee_check_tooltip): zero the correct token
 
 2010-07-21  Andreas J. Guelzow <aguelzow pyrshep ca>
 
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index ff56db2..ddef67a 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -722,7 +722,7 @@ gee_set_tooltip (GnmExprEntry *gee, GnmFunc *fd, gint args, gboolean had_stuff)
 	    && (gee->tooltip.fd == fd && gee->tooltip.args == args
 		&& gee->tooltip.had_stuff == (max == 0 && args == 0 && had_stuff)))
 			return;
-	gee_delete_tooltip (gee, TRUE);
+	gee_delete_tooltip (gee, FALSE);
 
 	gee->tooltip.fd = fd;
 	gnm_func_ref (gee->tooltip.fd);
@@ -782,7 +782,7 @@ gee_set_tooltip (GnmExprEntry *gee, GnmFunc *fd, gint args, gboolean had_stuff)
 	g_string_free (str, TRUE);
 }
 
-static void
+static gboolean
 gee_set_tooltip_completion (GnmExprEntry *gee, GSList *list, guint start, guint end)
 {
 	GString *str;
@@ -791,6 +791,7 @@ gee_set_tooltip_completion (GnmExprEntry *gee, GSList *list, guint start, guint
 	gint max = 10;
 	GSList *list_c = list;
 	gchar const *name;
+	gboolean show_tool_tip;
 
 	gee_delete_tooltip (gee, TRUE);
 
@@ -816,7 +817,6 @@ gee_set_tooltip_completion (GnmExprEntry *gee, GSList *list, guint start, guint
 	if (i == max)
 		g_string_append (str_marked, UNICODE_ELLIPSIS_VERT "\n");
 	if (i == 1) {
-		g_free (gee->tooltip.completion);
 		gee->tooltip.completion 
 			= g_strdup (name);
 		/*xgettext: short form for: "type F4-key to complete the name"*/
@@ -829,11 +829,14 @@ gee_set_tooltip_completion (GnmExprEntry *gee, GSList *list, guint start, guint
 	gee->tooltip.completion_start = start;
 	gee->tooltip.completion_end = end;
 	gee->tooltip.completion_se_valid = TRUE;
-	gee->tooltip.tooltip = gee_create_tooltip 
-		(gee, str->str, str_marked->str, TRUE);
+	show_tool_tip = gnm_conf_get_core_gui_editing_function_name_tooltips ();
+	if (show_tool_tip)
+		gee->tooltip.tooltip = gee_create_tooltip 
+			(gee, str->str, str_marked->str, TRUE);
 	g_string_free (str, TRUE);
 	g_string_free (str_marked, TRUE);
-	go_slist_free_custom (list, (GFreeFunc) gnm_func_unref);	
+	go_slist_free_custom (list, (GFreeFunc) gnm_func_unref);
+	return show_tool_tip;
 }
 
 static void
@@ -861,7 +864,7 @@ gee_check_tooltip (GnmExprEntry *gee)
 	gint  end, args = 0;
 	guint end_t;
 	char *str;
-	gboolean stuff = FALSE;
+	gboolean stuff = FALSE, completion_se_set = FALSE;
 	GnmLexerItem *gli, *gli_c;
 
 	if (!gee->tooltip.enabled || gee->is_cell_renderer ||
@@ -923,16 +926,29 @@ gee_check_tooltip (GnmExprEntry *gee)
 			list = g_slist_sort 
 				(list, 
 				 (GCompareFunc)func_def_cmp);
-			gee_set_tooltip_completion (gee, list, start_t, end_t);
-			g_free (str);
-			g_free (gli_c);
-			return;
+			if (gee_set_tooltip_completion 
+			    (gee, list, start_t, end_t)) {
+				g_free (str);
+				g_free (gli_c);
+				return;
+			}
 		} else {
+			g_free (gee->tooltip.completion);
+			gee->tooltip.completion = NULL;
 			gee->tooltip.completion_start = start_t;
 			gee->tooltip.completion_end = end_t;
 			gee->tooltip.completion_se_valid = TRUE;
 		}
+		completion_se_set = TRUE; 
+	} else {
+		g_free (gee->tooltip.completion);
+		gee->tooltip.completion = NULL;
+		gee->tooltip.completion_se_valid = FALSE;		
 	}
+		
+
+	if (!gnm_conf_get_core_gui_editing_function_argument_tooltips ())
+		goto not_found;
 
 	if (gnm_debug_flag ("functooltip"))
 		g_print ("last token consider is %d from %d to %d\n", 
@@ -1017,7 +1033,7 @@ gee_check_tooltip (GnmExprEntry *gee)
  not_found:
 	g_free (str);
 	g_free (gli_c);
-	gee_delete_tooltip (gee, TRUE);
+	gee_delete_tooltip (gee, !completion_se_set);
 	return;
 }
 



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