From: John Darrington Date: Sun, 15 Mar 2009 21:58:34 +0000 (+0900) Subject: Config option to prefer variable labels vs. names X-Git-Tag: v0.7.3~230 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70f8742ab0031e79444d3d3406c12a169a09a543;p=pspp-builds.git Config option to prefer variable labels vs. names Added user config option to select whether dictionary treeviews in dialog boxes should prefer variable labels over names. Default is names. --- diff --git a/src/ui/gui/dict-display.c b/src/ui/gui/dict-display.c index 63d9f3c9..6d167145 100644 --- a/src/ui/gui/dict-display.c +++ b/src/ui/gui/dict-display.c @@ -19,6 +19,7 @@ #include #include +#include "psppire-conf.h" #include "dict-display.h" #include "psppire-dict.h" @@ -124,7 +125,12 @@ var_description_cell_data_func (GtkTreeViewColumn *col, struct variable *var; GtkTreeIter iter; GtkTreeModel *model; + gboolean prefer_labels = FALSE; + PsppireConf *conf = psppire_conf_new (); + + psppire_conf_get_boolean (conf, "dialog-boxes", "prefer-labels", + &prefer_labels); get_base_model (top_model, top_iter, &model, &iter); @@ -134,13 +140,12 @@ var_description_cell_data_func (GtkTreeViewColumn *col, gtk_tree_model_get (model, &iter, DICT_TVM_COL_VAR, &var, -1); - if ( var_has_label (var)) + if ( var_has_label (var) && prefer_labels) { gchar *text = g_strdup_printf ( "%s", var_get_label (var)); - char *utf8 = pspp_locale_to_utf8 (text, -1, NULL); g_free (text); @@ -149,12 +154,13 @@ var_description_cell_data_func (GtkTreeViewColumn *col, } else { - g_object_set (cell, "text", var_get_name (var), NULL); + char *name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL); + g_object_set (cell, "text", name, NULL); + g_free (name); } } -#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, @@ -198,16 +204,26 @@ set_tooltip_for_variable (GtkTreeView *treeview, return FALSE; { - char *name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL); + gchar *tip ; + gboolean prefer_labels = FALSE; + + PsppireConf *conf = psppire_conf_new (); - gtk_tooltip_set_text (tooltip, name); + psppire_conf_get_boolean (conf, "dialog-boxes", "prefer-labels", + &prefer_labels); - g_free (name); + if ( prefer_labels ) + tip = pspp_locale_to_utf8 (var_get_name (var), -1, NULL); + else + tip = pspp_locale_to_utf8 (var_get_label (var), -1, NULL); + + gtk_tooltip_set_text (tooltip, tip); + + g_free (tip); } return TRUE; } -#endif /* Sets up TREEVIEW to display the variables of DICT. MODE is the selection mode for TREEVIEW.