projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gui: Fix temporary filtering by a variable's value.
[pspp]
/
src
/
ui
/
gui
/
psppire-dictview.c
diff --git
a/src/ui/gui/psppire-dictview.c
b/src/ui/gui/psppire-dictview.c
index f2648298dc25459a9e53e4f4c39829bc17fd5346..cab7436cb226f3f287f5e84a69a68589a0c75ffd 100644
(file)
--- a/
src/ui/gui/psppire-dictview.c
+++ b/
src/ui/gui/psppire-dictview.c
@@
-1,5
+1,5
@@
/* PSPPIRE - a graphical user interface for PSPP.
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2009 Free Software Foundation
+ Copyright (C) 2009
, 2010
Free Software Foundation
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
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
@@
-16,11
+16,12
@@
#include <config.h>
#include <config.h>
-#include <gtk/gtk
treeview
.h>
+#include <gtk/gtk.h>
#include "psppire-dictview.h"
#include "psppire-dict.h"
#include "psppire-conf.h"
#include <data/format.h>
#include "psppire-dictview.h"
#include "psppire-dict.h"
#include "psppire-conf.h"
#include <data/format.h>
+#include <libpspp/i18n.h>
#include "helper.h"
#include <gettext.h>
#include "helper.h"
#include <gettext.h>
@@
-74,7
+75,6
@@
psppire_dict_view_finalize (GObject *object)
enum
{
PROP_0,
enum
{
PROP_0,
- PROP_MODEL,
PROP_DICTIONARY,
PROP_PREDICATE,
PROP_SELECTION_MODE
PROP_DICTIONARY,
PROP_PREDICATE,
PROP_SELECTION_MODE
@@
-136,11
+136,6
@@
psppire_dict_view_set_property (GObject *object,
case PROP_DICTIONARY:
dict_view->dict = g_value_get_object (value);
break;
case PROP_DICTIONARY:
dict_view->dict = g_value_get_object (value);
break;
- case PROP_MODEL:
- g_critical ("Don't set the \"model\" property on %s. "
- "Use the \"dictionary\" property instead.",
- G_OBJECT_TYPE_NAME (dict_view));
- break;
case PROP_PREDICATE:
dict_view->predicate = g_value_get_pointer (value);
break;
case PROP_PREDICATE:
dict_view->predicate = g_value_get_pointer (value);
break;
@@
-200,45
+195,27
@@
psppire_dict_view_class_init (PsppireDictViewClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- GParamSpec *dictionary_spec =
- g_param_spec_object ("dictionary",
- "Dictionary",
- _("The dictionary to be displayed by this widget"),
- PSPPIRE_TYPE_DICT,
- G_PARAM_READABLE | G_PARAM_WRITABLE);
-
GParamSpec *predicate_spec =
g_param_spec_pointer ("predicate",
"Predicate",
GParamSpec *predicate_spec =
g_param_spec_pointer ("predicate",
"Predicate",
-
_("A predicate function")
,
+
"A predicate function"
,
G_PARAM_READABLE | G_PARAM_WRITABLE);
GParamSpec *selection_mode_spec =
g_param_spec_enum ("selection-mode",
"Selection Mode",
G_PARAM_READABLE | G_PARAM_WRITABLE);
GParamSpec *selection_mode_spec =
g_param_spec_enum ("selection-mode",
"Selection Mode",
-
_("How many things can be selected")
,
+
"How many things can be selected"
,
GTK_TYPE_SELECTION_MODE,
GTK_SELECTION_MULTIPLE,
G_PARAM_CONSTRUCT | G_PARAM_READABLE | G_PARAM_WRITABLE);
GTK_TYPE_SELECTION_MODE,
GTK_SELECTION_MULTIPLE,
G_PARAM_CONSTRUCT | G_PARAM_READABLE | G_PARAM_WRITABLE);
-
- GParamSpec *dummy_spec =
- g_param_spec_pointer ("model",
- "Model",
- "Don't set the property",
- G_PARAM_WRITABLE);
-
object_class->set_property = psppire_dict_view_set_property;
object_class->get_property = psppire_dict_view_get_property;
object_class->set_property = psppire_dict_view_set_property;
object_class->get_property = psppire_dict_view_get_property;
- g_object_class_install_property (object_class,
- PROP_MODEL,
- dummy_spec);
-
- g_object_class_install_property (object_class,
- PROP_DICTIONARY,
- dictionary_spec);
+ g_object_class_override_property (object_class,
+ PROP_DICTIONARY,
+ "model");
g_object_class_install_property (object_class,
PROP_PREDICATE,
g_object_class_install_property (object_class,
PROP_PREDICATE,
@@
-270,15
+247,18
@@
psppire_dict_view_base_finalize (PsppireDictViewClass *class,
static void
dv_get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
static void
dv_get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
- GtkTreeModel **model, GtkTreeIter *iter
- )
+ GtkTreeModel **model, GtkTreeIter *iter)
{
*model = top_model;
{
*model = top_model;
- *iter = *top_iter;
+
+ if ( iter)
+ *iter = *top_iter;
while ( ! PSPPIRE_IS_DICT (*model))
{
while ( ! PSPPIRE_IS_DICT (*model))
{
- GtkTreeIter parent_iter = *iter;
+ GtkTreeIter parent_iter;
+ if (iter)
+ parent_iter = *iter;
if ( GTK_IS_TREE_MODEL_FILTER (*model))
{
if ( GTK_IS_TREE_MODEL_FILTER (*model))
{
@@
-286,9
+266,10
@@
dv_get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
*model = gtk_tree_model_filter_get_model (parent_model);
*model = gtk_tree_model_filter_get_model (parent_model);
- gtk_tree_model_filter_convert_iter_to_child_iter (parent_model,
- iter,
- &parent_iter);
+ if (iter)
+ gtk_tree_model_filter_convert_iter_to_child_iter (parent_model,
+ iter,
+ &parent_iter);
}
else if (GTK_IS_TREE_MODEL_SORT (*model))
{
}
else if (GTK_IS_TREE_MODEL_SORT (*model))
{
@@
-296,9
+277,10
@@
dv_get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
*model = gtk_tree_model_sort_get_model (parent_model);
*model = gtk_tree_model_sort_get_model (parent_model);
- gtk_tree_model_sort_convert_iter_to_child_iter (parent_model,
- iter,
- &parent_iter);
+ if (iter)
+ gtk_tree_model_sort_convert_iter_to_child_iter (parent_model,
+ iter,
+ &parent_iter);
}
}
}
}
}
}
@@
-318,32
+300,27
@@
var_description_cell_data_func (GtkTreeViewColumn *col,
struct variable *var;
GtkTreeIter iter;
GtkTreeModel *model;
struct variable *var;
GtkTreeIter iter;
GtkTreeModel *model;
-
+ PsppireDict *dict;
dv_get_base_model (top_model, top_iter, &model, &iter);
dv_get_base_model (top_model, top_iter, &model, &iter);
-
g_assert (PSPPIRE_IS_DICT (model)
);
+
dict = PSPPIRE_DICT (model
);
gtk_tree_model_get (model,
&iter, DICT_TVM_COL_VAR, &var, -1);
if ( var_has_label (var) && dv->prefer_labels)
{
gtk_tree_model_get (model,
&iter, DICT_TVM_COL_VAR, &var, -1);
if ( var_has_label (var) && dv->prefer_labels)
{
- gchar *text = g_
strdup_printf
(
+ gchar *text = g_
markup_printf_escaped
(
"<span stretch=\"condensed\">%s</span>",
var_get_label (var));
"<span stretch=\"condensed\">%s</span>",
var_get_label (var));
- char *utf8 = pspp_locale_to_utf8 (text, -1, NULL);
-
+ g_object_set (cell, "markup", text, NULL);
g_free (text);
g_free (text);
- g_object_set (cell, "markup", utf8, NULL);
- g_free (utf8);
}
else
{
}
else
{
- char *name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL);
- g_object_set (cell, "text", name, NULL);
- g_free (name);
+ g_object_set (cell, "text", var_get_name (var), NULL);
}
}
}
}
@@
-406,7
+383,6
@@
set_tooltip_for_variable (GtkTreeView *treeview,
struct variable *var = NULL;
gboolean ok;
struct variable *var = NULL;
gboolean ok;
-
gtk_tree_view_convert_widget_to_bin_window_coords (treeview,
x, y, &bx, &by);
gtk_tree_view_convert_widget_to_bin_window_coords (treeview,
x, y, &bx, &by);
@@
-416,7
+392,6
@@
set_tooltip_for_variable (GtkTreeView *treeview,
tree_model = gtk_tree_view_get_model (treeview);
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_view_set_tooltip_row (treeview, tooltip, path);
ok = gtk_tree_model_get_iter (tree_model, &iter, path);
@@
-432,16
+407,19
@@
set_tooltip_for_variable (GtkTreeView *treeview,
return FALSE;
{
return FALSE;
{
- gchar *tip ;
+ const gchar *tip ;
+ GtkTreeModel *m;
+ PsppireDict *dict;
+
+ dv_get_base_model (tree_model, NULL, &m, NULL);
+ dict = PSPPIRE_DICT (m);
if ( PSPPIRE_DICT_VIEW (treeview)->prefer_labels )
if ( PSPPIRE_DICT_VIEW (treeview)->prefer_labels )
- tip =
pspp_locale_to_utf8 (var_get_name (var), -1, NULL
);
+ tip =
var_get_name (var
);
else
else
- tip =
pspp_locale_to_utf8 (var_get_label (var), -1, NULL
);
+ tip =
var_get_label (var
);
gtk_tooltip_set_text (tooltip, tip);
gtk_tooltip_set_text (tooltip, tip);
-
- g_free (tip);
}
return TRUE;
}
return TRUE;
@@
-481,7
+459,8
@@
psppire_dict_view_init (PsppireDictView *dict_view)
dict_view->prefer_labels = TRUE;
psppire_conf_get_boolean (psppire_conf_new (),
dict_view->prefer_labels = TRUE;
psppire_conf_get_boolean (psppire_conf_new (),
- "dialog-boxes", "prefer-labels",
+ G_OBJECT_TYPE_NAME (dict_view),
+ "prefer-labels",
&dict_view->prefer_labels);
gtk_tree_view_column_set_title (col, _("Variable"));
&dict_view->prefer_labels);
gtk_tree_view_column_set_title (col, _("Variable"));
@@
-508,7
+487,10
@@
psppire_dict_view_init (PsppireDictView *dict_view)
gtk_tree_view_append_column (GTK_TREE_VIEW (dict_view), col);
gtk_tree_view_append_column (GTK_TREE_VIEW (dict_view), col);
- g_object_set (dict_view, "has-tooltip", TRUE, NULL);
+ g_object_set (dict_view,
+ "has-tooltip", TRUE,
+ "headers-visible", FALSE,
+ NULL);
g_signal_connect (dict_view, "query-tooltip",
G_CALLBACK (set_tooltip_for_variable), NULL);
g_signal_connect (dict_view, "query-tooltip",
G_CALLBACK (set_tooltip_for_variable), NULL);