static void
psppire_dict_view_finalize (GObject *object)
{
+ PsppireDictView *dict_view = PSPPIRE_DICT_VIEW (object);
+
+ g_object_unref (dict_view->menu);
}
/* Properties */
static void
-psppire_dict_view_base_finalize(PsppireDictViewClass *class,
- gpointer class_data)
+psppire_dict_view_base_finalize (PsppireDictViewClass *class,
+ gpointer class_data)
{
}
GtkTreeIter *top_iter,
gpointer data)
{
+ PsppireDictView *dv = PSPPIRE_DICT_VIEW (data);
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);
dv_get_base_model (top_model, top_iter, &model, &iter);
g_assert (PSPPIRE_IS_DICT (model));
-
gtk_tree_model_get (model,
&iter, DICT_TVM_COL_VAR, &var, -1);
- if ( var_has_label (var) && prefer_labels)
+ if ( var_has_label (var) && dv->prefer_labels)
{
gchar *text = g_strdup_printf (
"<span stretch=\"condensed\">%s</span>",
gboolean keyboard_mode,
GtkTooltip *tooltip,
gpointer user_data)
-
{
gint bx, by;
GtkTreeIter iter;
{
gchar *tip ;
- gboolean prefer_labels = FALSE;
- PsppireConf *conf = psppire_conf_new ();
-
- psppire_conf_get_boolean (conf, "dialog-boxes", "prefer-labels",
- &prefer_labels);
-
- if ( prefer_labels )
+ if ( PSPPIRE_DICT_VIEW (treeview)->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);
return TRUE;
}
+static gboolean
+show_menu (PsppireDictView *dv, GdkEventButton *event, gpointer data)
+{
+ if (event->button != 3)
+ return FALSE;
+
+ gtk_menu_popup (GTK_MENU (dv->menu), NULL, NULL, NULL, NULL,
+ event->button, event->time);
+
+ return TRUE;
+}
+
+static void
+toggle_label_preference (GtkCheckMenuItem *checkbox, gpointer data)
+{
+ PsppireDictView *dv = PSPPIRE_DICT_VIEW (data);
+
+ dv->prefer_labels = gtk_check_menu_item_get_active (checkbox);
+
+ gtk_widget_queue_draw (GTK_WIDGET (dv));
+}
static void
psppire_dict_view_init (PsppireDictView *dict_view)
{
- GtkTreeViewColumn *col;
+ GtkTreeViewColumn *col = gtk_tree_view_column_new ();
+
+ GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new ();
+
+ dict_view->prefer_labels = TRUE;
- GtkCellRenderer *renderer;
+ psppire_conf_get_boolean (psppire_conf_new (),
+ "dialog-boxes", "prefer-labels",
+ &dict_view->prefer_labels);
- col = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (col, _("Variable"));
- renderer = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (col, renderer, FALSE);
gtk_tree_view_column_set_cell_data_func (col, renderer,
var_icon_cell_data_func,
NULL, NULL);
-
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (col, renderer, TRUE);
gtk_tree_view_column_set_cell_data_func (col, renderer,
var_description_cell_data_func,
- NULL, NULL);
+ dict_view, NULL);
g_object_set (renderer, "ellipsize-set", TRUE, NULL);
g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL);
g_signal_connect (dict_view, "query-tooltip",
G_CALLBACK (set_tooltip_for_variable), NULL);
+
+ dict_view->menu = gtk_menu_new ();
+
+
+ {
+ GtkWidget *checkbox =
+ gtk_check_menu_item_new_with_label (_("Prefer variable labels"));
+
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (checkbox),
+ dict_view->prefer_labels);
+
+ g_signal_connect (checkbox, "toggled",
+ G_CALLBACK (toggle_label_preference), dict_view);
+
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (dict_view->menu), checkbox);
+
+ }
+
+ gtk_widget_show_all (dict_view->menu);
+
+ g_signal_connect (dict_view, "button-press-event",
+ G_CALLBACK (show_menu), NULL);
}
if (! gtk_tree_selection_get_selected (selection,
&top_model, &top_iter))
- {
- return NULL;
- }
+ return NULL;
dv_get_base_model (top_model, &top_iter, &model, &iter);