[gnumeric] don't show @{...} in function tooltips



commit 496b5b7351512c6f3791fe0e15a39ae59689bb39
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Jun 16 16:23:16 2010 -0600

    don't show @{...} in function tooltips
    
    2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/func.h (gnm_func_convert_markup_to_pango): new
    	* src/func.c (gnm_func_convert_markup_to_pango): new
    
    2010-06-16  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gnumeric-expr-entry.c (gee_create_tooltip): use
    	  gnm_func_convert_markup_to_pango
    
    2010-06-16  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* dialog-formula-guru.c (dialog_formula_guru_adjust_children): use
    	  gnm_func_convert_markup_to_pango

 ChangeLog                         |    5 ++++
 src/dialogs/ChangeLog             |    5 ++++
 src/dialogs/dialog-formula-guru.c |   25 ++++++-----------------
 src/func.c                        |   39 +++++++++++++++++++++++++++++++++++++
 src/func.h                        |    2 +
 src/widgets/ChangeLog             |    5 ++++
 src/widgets/gnumeric-expr-entry.c |    6 +++-
 7 files changed, 67 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 24afd98..0201a82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* src/func.h (gnm_func_convert_markup_to_pango): new
+	* src/func.c (gnm_func_convert_markup_to_pango): new	
+
+2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* src/commands.c (cmd_paste_copy): check with user if more than
 	  10000 copies are to be pasted.
 
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index d17018c..47672fe 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-16  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* dialog-formula-guru.c (dialog_formula_guru_adjust_children): use
+	  gnm_func_convert_markup_to_pango
+
 2010-06-15  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* dialog-goto-cell.c (cb_load_names): only load names that are in
diff --git a/src/dialogs/dialog-formula-guru.c b/src/dialogs/dialog-formula-guru.c
index 22cc5a3..71dfc14 100644
--- a/src/dialogs/dialog-formula-guru.c
+++ b/src/dialogs/dialog-formula-guru.c
@@ -307,8 +307,8 @@ dialog_formula_guru_adjust_children (GtkTreeIter *parent, GnmFunc const *fd,
 					       &iter, parent, args))
 		gtk_tree_store_remove (state->model, &iter);
 	for (i = 0; i < args; i++) {
-		GString *desc;
-		gchar *at;
+		gchar *desc;
+
 		if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(state->model),
 						    &iter, parent, i)) {
 			gtk_tree_store_append (state->model, &iter, parent);
@@ -326,26 +326,15 @@ dialog_formula_guru_adjust_children (GtkTreeIter *parent, GnmFunc const *fd,
 			g_free (arg_name);
 			arg_name = mod_name;
 		}
-		desc = g_string_new (g_markup_escape_text 
-				     (gnm_func_get_arg_description (fd, i), -1));
-		while ((at = strstr (desc->str, "@{"))) {
-#warning In gtk+ 2.14+ we should be using g_string_overwrite rather than g_string_erase
-			gint len = at - desc->str;
-			g_string_erase (desc, len, 2);
-			g_string_insert (desc, len, "<b><u>");
-			if ((at = strstr (desc->str + len, "}"))) {
-				len = at - desc->str;
-				g_string_erase (desc, len, 1);
-				g_string_insert (desc, len, "</u></b>");
-			} else
-				g_string_append (desc, "</u></b>");
-		}
+		desc = gnm_func_convert_markup_to_pango 
+			(gnm_func_get_arg_description (fd, i),
+			 "underline=\"low\"");
 		gtk_tree_store_set (state->model, &iter,
 				    ARG_NAME, arg_name,
-				    ARG_TOOLTIP, desc->str,
+				    ARG_TOOLTIP, desc,
 				    ARG_TYPE, function_def_get_arg_type_string (fd, i),
 				    -1);
-		g_string_free (desc, TRUE);
+		g_free (desc);
 		g_free (arg_name);
 	}
 
diff --git a/src/func.c b/src/func.c
index a2532d7..f84da0c 100644
--- a/src/func.c
+++ b/src/func.c
@@ -1276,6 +1276,45 @@ gnm_func_get_arg_description (GnmFunc const *fn_def, guint arg_idx)
 	return "";
 }
 
+/**
+ * gnm_func_convert_markup_to_pango:
+ * @desc: the fn or arg description string
+ *
+ * Return value: the escaped string with @{} markup converted to
+ *               pango markup
+ **/
+char *
+gnm_func_convert_markup_to_pango (char const *desc, char const *highlight)
+{
+	GString *str;
+	gchar *markup, *at;
+
+	markup = g_markup_escape_text (desc, -1);
+	str = g_string_new (markup);
+	g_free (markup);
+
+	while ((at = strstr (str->str, "@{"))) {
+#warning In gtk+ 2.14+ we should be using g_string_overwrite rather than g_string_erase
+		gint len = at - str->str;
+			g_string_erase (str, len, 2);
+			g_string_insert (str, len, 
+					 ">");
+			g_string_insert (str, len, 
+					 highlight);
+			g_string_insert (str, len, 
+					 "<span ");
+			if ((at = strstr 
+			     (str->str + len + 7 + strlen (highlight), "}"))) {
+				len = at - str->str;
+				g_string_erase (str, len, 1);
+				g_string_insert (str, len, "</span>");
+			} else
+				g_string_append (str, "</span>");
+	}
+
+	return g_string_free (str, FALSE);
+}
+
 
 /* ------------------------------------------------------------------------- */
 
diff --git a/src/func.h b/src/func.h
index a2a1c97..aa23d10 100644
--- a/src/func.h
+++ b/src/func.h
@@ -257,6 +257,8 @@ char       *function_def_get_arg_name  (GnmFunc const *fn_def,
                                         guint arg_idx);
 char const *gnm_func_get_arg_description (GnmFunc const *fn_def,
                                         guint arg_idx);
+char       *gnm_func_convert_markup_to_pango (char const *desc, 
+					      char const *highlight);
 
 /*************************************************************************/
 
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 77d96fd..64de6d3 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,5 +1,10 @@
 2010-06-16  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* gnumeric-expr-entry.c (gee_create_tooltip): use
+	  gnm_func_convert_markup_to_pango
+
+2010-06-16  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* gnumeric-expr-entry.c (gee_set_tooltip): add argument indicating
 	  whether non-space characters were observed in current argument.
 	(gee_check_tooltip): record non-space characters in current argument
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 06ad32d..b62a71c 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -621,6 +621,8 @@ gee_create_tooltip (GnmExprEntry *gee, gchar const *str)
 	gint root_x = 0, root_y = 0;
 	GtkAllocation allocation;
 	GdkWindow *gdkw;
+	gchar *markup = gnm_func_convert_markup_to_pango 
+		(str,"foreground=\"#0000FF\"");
 
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (gee->entry));
 	gtk_widget_add_events(toplevel, GDK_FOCUS_CHANGE_MASK);
@@ -632,8 +634,8 @@ gee_create_tooltip (GnmExprEntry *gee, gchar const *str)
 	label = gnumeric_create_tooltip (toplevel);
 	tip = gtk_widget_get_toplevel (label);
 
-	/* We could use markup.  */
-	gtk_label_set_text (GTK_LABEL (label), str);
+	gtk_label_set_markup (GTK_LABEL (label), markup);
+	g_free (markup);
 
 	gdkw = gtk_widget_get_window (GTK_WIDGET (gee->entry));
 	gdk_window_get_origin (gdkw, &root_x, &root_y);



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