X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fdict-display.c;h=a8e9237a7edbb38c065e5d2c0f52dc6064fef862;hb=f463d854c12bda4f9f12f798ba12d3ea88c3a9ed;hp=5129f13988c433b3d3171bf939c5773956273611;hpb=b06c888cf2e8c126b04d4678120439533a5086e5;p=pspp-builds.git diff --git a/src/ui/gui/dict-display.c b/src/ui/gui/dict-display.c index 5129f139..a8e9237a 100644 --- a/src/ui/gui/dict-display.c +++ b/src/ui/gui/dict-display.c @@ -1,10 +1,9 @@ -/* - PSPPIRE --- A Graphical User Interface for PSPP +/* PSPPIRE - a graphical user interface for PSPP. Copyright (C) 2007 Free Software Foundation - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -13,9 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program. If not, see . */ #include @@ -27,6 +24,7 @@ #include "psppire-dict.h" #include "helper.h" #include +#include #define _(msgid) gettext (msgid) #define N_(msgid) msgid @@ -138,11 +136,10 @@ 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)); + gchar *text = g_markup_printf_escaped ( + "%s", + var_get_label (var)); + char *utf8 = pspp_locale_to_utf8 (text, -1, NULL); @@ -156,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 @@ -222,13 +269,20 @@ 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 } void insert_source_row_into_entry (GtkTreeIter iter, GtkWidget *dest, - GtkTreeModel *model + GtkTreeModel *model, + gpointer data ) { GtkTreePath *path; @@ -260,7 +314,8 @@ insert_source_row_into_entry (GtkTreeIter iter, void insert_source_row_into_tree_view (GtkTreeIter iter, GtkWidget *dest, - GtkTreeModel *model + GtkTreeModel *model, + gpointer data ) { GtkTreePath *path;