[gnumeric] Make the formula guru tool tips look more like our standard tooltips
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Make the formula guru tool tips look more like our standard tooltips
- Date: Thu, 17 Jun 2010 06:45:50 +0000 (UTC)
commit 399da324e8e6e8876ffb2393c60fe1d2d6a22f44
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Thu Jun 17 00:41:35 2010 -0600
Make the formula guru tool tips look more like our standard tooltips
2010-06-17 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-formula-guru.c (dialog_formula_guru_adjust_children): drop
the last argument of gnm_func_convert_markup_to_pango
(cb_dialog_formula_guru_destroy): unref tooltip widgets
(cb_dialog_formula_guru_query_tooltip): create our own tooltip
(dialog_formula_guru_init): initialize tooltip widgets
2010-06-17 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/func.h (gnm_func_convert_markup_to_pango): drop highlight arg
* src/func.c (gnm_func_convert_markup_to_pango): ditto
* src/gui-util.h (gnumeric_create_tooltip_rc_style): new
(gnumeric_create_tooltip_widget): new
* src/gui-util.c (gnumeric_create_tooltip_rc_style): new
(gnumeric_create_tooltip_widget): new
(gnumeric_create_tooltip): split off teh above two
2010-06-17 Andreas J. Guelzow <aguelzow pyrshep ca>
* gnumeric-expr-entry.c (gee_check_tooltip): don't create tooltip
in range selectors or cell renderers yet.
(gee_create_tooltip): drop argument from
gnm_func_convert_markup_to_pango
ChangeLog | 11 ++++++
src/dialogs/ChangeLog | 10 +++++-
src/dialogs/dialog-formula-guru.c | 66 +++++++++++++++++++++++++++++++++++--
src/func.c | 10 ++----
src/func.h | 3 +-
src/gui-util.c | 39 +++++++++++++++++-----
src/gui-util.h | 2 +
src/widgets/ChangeLog | 7 ++++
src/widgets/gnumeric-expr-entry.c | 6 ++--
9 files changed, 129 insertions(+), 25 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 50af780..824024b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+<<<<<<< HEAD
+2010-06-17 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/func.h (gnm_func_convert_markup_to_pango): drop highlight arg
+ * src/func.c (gnm_func_convert_markup_to_pango): ditto
+ * src/gui-util.h (gnumeric_create_tooltip_rc_style): new
+ (gnumeric_create_tooltip_widget): new
+ * src/gui-util.c (gnumeric_create_tooltip_rc_style): new
+ (gnumeric_create_tooltip_widget): new
+ (gnumeric_create_tooltip): split off teh above two
+
2010-06-16 Morten Welinder <terra gnome org>
* configure.in: Post-release bump.
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 5e4d719..279e91d 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,7 +1,15 @@
+2010-06-17 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-formula-guru.c (dialog_formula_guru_adjust_children): drop
+ the last argument of gnm_func_convert_markup_to_pango
+ (cb_dialog_formula_guru_destroy): unref tooltip widgets
+ (cb_dialog_formula_guru_query_tooltip): create our own tooltip
+ (dialog_formula_guru_init): initialize tooltip widgets
+
2010-06-16 Morten Welinder <terra gnome org>
* Release 1.10.6
-
+
2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-formula-guru.c (dialog_formula_guru_adjust_children): use
diff --git a/src/dialogs/dialog-formula-guru.c b/src/dialogs/dialog-formula-guru.c
index 71dfc14..e64e007 100644
--- a/src/dialogs/dialog-formula-guru.c
+++ b/src/dialogs/dialog-formula-guru.c
@@ -77,6 +77,8 @@ typedef struct
GtkTreeStore *model;
GtkTreeView *treeview;
+ GtkWidget *tooltip_widget;
+ GtkWidget *tooltip_label;
gint old_height;
gint old_width;
@@ -327,8 +329,7 @@ dialog_formula_guru_adjust_children (GtkTreeIter *parent, GnmFunc const *fd,
arg_name = mod_name;
}
desc = gnm_func_convert_markup_to_pango
- (gnm_func_get_arg_description (fd, i),
- "underline=\"low\"");
+ (gnm_func_get_arg_description (fd, i));
gtk_tree_store_set (state->model, &iter,
ARG_NAME, arg_name,
ARG_TOOLTIP, desc,
@@ -534,6 +535,10 @@ cb_dialog_formula_guru_destroy (FormulaGuruState *state)
if (state->gui != NULL)
g_object_unref (G_OBJECT (state->gui));
gnm_expr_entry_enable_tips (wbcg_get_entry_logical (state->wbcg));
+ if (state->tooltip_widget) {
+ g_object_unref (G_OBJECT (state->tooltip_widget));
+ g_object_unref (G_OBJECT (state->tooltip_label));
+ }
g_free (state);
}
@@ -828,6 +833,55 @@ start_editing_cb (GtkTreeView *tree_view,
/* End of bad bad hack*/
static gboolean
+cb_dialog_formula_guru_query_tooltip (GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ gpointer user_data)
+{
+ FormulaGuruState *state = user_data;
+ gint x_ = x;
+ gint y_ = y;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ if (gtk_tree_view_get_tooltip_context
+ (state->treeview, &x_, &y_, keyboard_mode, NULL, &path, &iter)) {
+ char *markup;
+ GtkRcStyle *rc_style = gnumeric_create_tooltip_rc_style ();
+
+ gtk_tree_model_get (GTK_TREE_MODEL (state->model), &iter,
+ ARG_TOOLTIP, &markup, -1);
+ if (markup == NULL || markup[0]=='\0')
+ return FALSE;
+ if (!state->tooltip_widget) {
+/* For some reason we don't get a reasonable tooltip with the following: */
+/* state->tooltip_label = gnumeric_create_tooltip_widget (); */
+/* state->tooltip_widget */
+/* = gtk_widget_get_toplevel (state->tooltip_label); */
+ state->tooltip_label = state->tooltip_widget
+ = gtk_label_new (NULL);
+
+ gtk_widget_modify_style /* Applying to label */
+ (state->tooltip_label, rc_style);
+ g_object_ref (G_OBJECT (state->tooltip_widget));
+ g_object_ref (G_OBJECT (state->tooltip_label));
+ }
+ gtk_tooltip_set_custom (tooltip, state->tooltip_widget);
+ gtk_widget_modify_style /* Applying to window */
+ (gtk_widget_get_toplevel (state->tooltip_widget), rc_style);
+ gtk_label_set_markup (GTK_LABEL (state->tooltip_label), markup);
+ g_free (markup);
+ gtk_tree_view_set_tooltip_row (state->treeview,
+ tooltip, path);
+ gtk_tree_path_free (path);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
dialog_formula_guru_init (FormulaGuruState *state)
{
GtkWidget *scrolled;
@@ -838,6 +892,8 @@ dialog_formula_guru_init (FormulaGuruState *state)
g_object_set_data (G_OBJECT (state->dialog), FORMULA_GURU_KEY_DIALOG,
state);
+ state->tooltip_widget = NULL;
+
/* Set-up treeview */
scrolled = glade_xml_get_widget (state->gui, "scrolled");
state->model = gtk_tree_store_new (NUM_COLMNS, G_TYPE_STRING, G_TYPE_BOOLEAN,
@@ -878,7 +934,11 @@ dialog_formula_guru_init (FormulaGuruState *state)
state->column = column;
gtk_tree_view_append_column (state->treeview, column);
- gtk_tree_view_set_tooltip_column (state->treeview, ARG_TOOLTIP);
+ gtk_widget_set_has_tooltip (GTK_WIDGET (state->treeview), TRUE);
+ g_signal_connect (G_OBJECT (state->treeview), "query-tooltip",
+ G_CALLBACK (cb_dialog_formula_guru_query_tooltip), state);
+
+/* gtk_tree_view_set_tooltip_column (state->treeview, ARG_TOOLTIP); */
gtk_tree_view_set_headers_visible (state->treeview, TRUE);
gtk_tree_view_set_enable_tree_lines (state->treeview, TRUE);
gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->treeview));
diff --git a/src/func.c b/src/func.c
index f84da0c..c57bafd 100644
--- a/src/func.c
+++ b/src/func.c
@@ -1284,7 +1284,7 @@ gnm_func_get_arg_description (GnmFunc const *fn_def, guint arg_idx)
* pango markup
**/
char *
-gnm_func_convert_markup_to_pango (char const *desc, char const *highlight)
+gnm_func_convert_markup_to_pango (char const *desc)
{
GString *str;
gchar *markup, *at;
@@ -1298,13 +1298,9 @@ gnm_func_convert_markup_to_pango (char const *desc, char const *highlight)
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 ");
+ "<span foreground=\"#0000FF\">");
if ((at = strstr
- (str->str + len + 7 + strlen (highlight), "}"))) {
+ (str->str + len + 26, "}"))) {
len = at - str->str;
g_string_erase (str, len, 1);
g_string_insert (str, len, "</span>");
diff --git a/src/func.h b/src/func.h
index aa23d10..1aecd99 100644
--- a/src/func.h
+++ b/src/func.h
@@ -257,8 +257,7 @@ 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);
+char *gnm_func_convert_markup_to_pango (char const *desc);
/*************************************************************************/
diff --git a/src/gui-util.c b/src/gui-util.c
index 4c92eef..d04e142 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -426,11 +426,9 @@ gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event)
: gtk_get_current_event_time());
}
-
-GtkWidget *
-gnumeric_create_tooltip (GtkWidget *ref_widget)
+GtkRcStyle*
+gnumeric_create_tooltip_rc_style (void)
{
- GtkWidget *tip, *label, *frame;
static GtkRcStyle*rc_style = NULL;
if (rc_style == NULL) {
@@ -438,10 +436,35 @@ gnumeric_create_tooltip (GtkWidget *ref_widget)
rc_style = gtk_rc_style_new ();
for (i = 5; --i >= 0 ; ) {
- rc_style->color_flags[i] = GTK_RC_BG;
+ rc_style->color_flags[i] = (GTK_RC_FG | GTK_RC_BG | GTK_RC_TEXT);
rc_style->bg[i] = gs_yellow;
+ rc_style->fg[i] = gs_black;
+ rc_style->text[i] = gs_black;
}
}
+ return rc_style;
+}
+
+
+GtkWidget *
+gnumeric_create_tooltip_widget (void)
+{
+ GtkWidget *label, *frame;
+
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+ label = gtk_label_new ("");
+
+ gtk_container_add (GTK_CONTAINER (frame), label);
+
+ return label;
+}
+
+GtkWidget *
+gnumeric_create_tooltip (GtkWidget *ref_widget)
+{
+ GtkWidget *tip, *label, *frame;
+ GtkRcStyle*rc_style = gnumeric_create_tooltip_rc_style ();
tip = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_type_hint (GTK_WINDOW (tip),
@@ -452,12 +475,10 @@ gnumeric_create_tooltip (GtkWidget *ref_widget)
if (rc_style != NULL)
gtk_widget_modify_style (tip, rc_style);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
- label = gtk_label_new ("");
+ label = gnumeric_create_tooltip_widget ();
+ frame = gtk_widget_get_toplevel (label);
gtk_container_add (GTK_CONTAINER (tip), frame);
- gtk_container_add (GTK_CONTAINER (frame), label);
return label;
}
diff --git a/src/gui-util.h b/src/gui-util.h
index 1ac8a9c..6abed6d 100644
--- a/src/gui-util.h
+++ b/src/gui-util.h
@@ -41,6 +41,8 @@ void gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event);
*/
void gnumeric_position_tooltip (GtkWidget *tip, int px, int py,
gboolean horizontal);
+GtkRcStyle *gnumeric_create_tooltip_rc_style (void);
+GtkWidget *gnumeric_create_tooltip_widget (void);
GtkWidget *gnumeric_create_tooltip (GtkWidget *ref_widget);
GladeXML *gnm_glade_xml_new (GOCmdContext *cc, char const *gladefile,
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 7690118..5fc83d3 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,10 @@
+2010-06-17 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * gnumeric-expr-entry.c (gee_check_tooltip): don't create tooltip
+ in range selectors or cell renderers yet.
+ (gee_create_tooltip): drop argument from
+ gnm_func_convert_markup_to_pango
+
2010-06-16 Morten Welinder <terra gnome org>
* Release 1.10.6
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index b62a71c..2548da0 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -621,8 +621,7 @@ 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\"");
+ gchar *markup = gnm_func_convert_markup_to_pango (str);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (gee->entry));
gtk_widget_add_events(toplevel, GDK_FOCUS_CHANGE_MASK);
@@ -747,7 +746,8 @@ gee_check_tooltip (GnmExprEntry *gee)
gchar sep = go_locale_get_arg_sep ();
gint para = 0, stuff = 0;
- if (!gee->tooltip.enabled)
+ if (!gee->tooltip.enabled || gee->is_cell_renderer ||
+ (gee->flags & GNM_EE_SINGLE_RANGE))
return;
end = gtk_editable_get_position (editable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]