X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fdict-display.c;h=356758beeea4100c4f4f1fd3feeaae71ebeb2fb4;hb=c94183521bb50d92ae05153f6013af0bc347299e;hp=1c2858d65cc8c0a8904e4ccd72938c5f4805b4d8;hpb=0bd0098aec2ee31d9460c8d4c1263d0b5ccc4324;p=pspp-builds.git diff --git a/src/ui/gui/dict-display.c b/src/ui/gui/dict-display.c index 1c2858d6..356758be 100644 --- a/src/ui/gui/dict-display.c +++ b/src/ui/gui/dict-display.c @@ -24,6 +24,7 @@ #include "psppire-dict.h" #include "helper.h" #include +#include #define _(msgid) gettext (msgid) #define N_(msgid) msgid @@ -136,10 +137,9 @@ var_description_cell_data_func (GtkTreeViewColumn *col, if ( var_has_label (var)) { gchar *text = g_strdup_printf ( - "%s" - " (%s)", - var_get_label (var), - var_get_name (var)); + "%s", + var_get_label (var)); + char *utf8 = pspp_locale_to_utf8 (text, -1, NULL); @@ -153,6 +153,56 @@ var_description_cell_data_func (GtkTreeViewColumn *col, } } + +#if GTK_CHECK_VERSION (2, 12, 0) +/* Sets the tooltip to be the name of the variable under the cursor */ +static gboolean +set_tooltip_for_variable (GtkTreeView *treeview, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip *tooltip, + gpointer user_data) + +{ + gint bx, by; + GtkTreeIter iter; + GtkTreePath *path; + GtkTreeModel *tree_model; + struct variable *var = NULL; + gboolean ok; + + + gtk_tree_view_convert_widget_to_bin_window_coords (treeview, + x, y, &bx, &by); + + if (!gtk_tree_view_get_path_at_pos (treeview, bx, by, + &path, NULL, NULL, NULL)) + return FALSE; + + tree_model = gtk_tree_view_get_model (treeview); + + + gtk_tree_view_set_tooltip_row (treeview, tooltip, path); + + ok = gtk_tree_model_get_iter (tree_model, &iter, path); + + gtk_tree_path_free (path); + if (!ok) + return FALSE; + + + gtk_tree_model_get (tree_model, &iter, DICT_TVM_COL_VAR, &var, -1); + + if ( ! var_has_label (var)) + return FALSE; + + gtk_tooltip_set_text (tooltip, var_get_name (var)); + + return TRUE; +} +#endif + /* Sets up TREEVIEW to display the variables of DICT. MODE is the selection mode for TREEVIEW. PREDICATE determines which variables should be visible, or NULL if @@ -219,6 +269,12 @@ attach_dictionary_to_treeview (GtkTreeView *treeview, PsppireDict *dict, gtk_tree_view_append_column (treeview, col); gtk_tree_selection_set_mode (selection, mode); + + g_object_set (treeview, "has-tooltip", TRUE, NULL); + +#if GTK_CHECK_VERSION (2, 12, 0) + g_signal_connect (treeview, "query-tooltip", G_CALLBACK (set_tooltip_for_variable), NULL); +#endif }