Merge branch 'master' of ssh://jmd@git.sv.gnu.org/srv/git/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 17 Mar 2009 12:14:12 +0000 (21:14 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 17 Mar 2009 12:14:12 +0000 (21:14 +0900)
52 files changed:
lib/gtk-contrib/psppire-sheet.c
lib/gtk-contrib/psppire-sheet.h
src/ui/gui/automake.mk
src/ui/gui/compute-dialog.c
src/ui/gui/crosstabs-dialog.c
src/ui/gui/crosstabs.glade
src/ui/gui/descriptives-dialog.c
src/ui/gui/descriptives-dialog.glade
src/ui/gui/dict-display.c
src/ui/gui/dict-display.h
src/ui/gui/examine-dialog.c
src/ui/gui/examine.glade
src/ui/gui/find-dialog.c
src/ui/gui/frequencies-dialog.c
src/ui/gui/frequencies.glade
src/ui/gui/oneway-anova-dialog.c
src/ui/gui/oneway.glade
src/ui/gui/psppire-buttonbox.c
src/ui/gui/psppire-buttonbox.h
src/ui/gui/psppire-conf.c
src/ui/gui/psppire-data-editor.c
src/ui/gui/psppire-data-window.c
src/ui/gui/psppire-dialog.c
src/ui/gui/psppire-dialog.h
src/ui/gui/psppire-dict.c
src/ui/gui/psppire-dict.h
src/ui/gui/psppire-dictview.c [new file with mode: 0644]
src/ui/gui/psppire-dictview.h [new file with mode: 0644]
src/ui/gui/psppire-selector.c
src/ui/gui/psppire-selector.h
src/ui/gui/psppire-var-sheet.c
src/ui/gui/psppire-var-store.c
src/ui/gui/psppire-var-store.h
src/ui/gui/psppire.glade
src/ui/gui/rank-dialog.c
src/ui/gui/rank.glade
src/ui/gui/recode-dialog.c
src/ui/gui/recode.glade
src/ui/gui/regression-dialog.c
src/ui/gui/regression.glade
src/ui/gui/select-cases-dialog.c
src/ui/gui/sort-cases-dialog.c
src/ui/gui/split-file-dialog.c
src/ui/gui/t-test-independent-samples-dialog.c
src/ui/gui/t-test-one-sample.c
src/ui/gui/t-test-paired-samples.c
src/ui/gui/t-test.glade
src/ui/gui/transpose-dialog.c
src/ui/gui/variable-info-dialog.c
src/ui/gui/variable-info-dialog.glade [new file with mode: 0644]
src/ui/gui/weight-cases-dialog.c
src/ui/gui/widgets.c

index 8a5375368cd5f19ff075a89df7807729962d2257..ad1cf78a7fd973d1af993e32696e59813b5f69f3 100644 (file)
@@ -2098,6 +2098,13 @@ psppire_sheet_unmap (GtkWidget *widget)
     gtk_widget_unmap (sheet->button);
 }
 
+/* get cell attributes of the given cell */
+/* TRUE means that the cell is currently allocated */
+static gboolean psppire_sheet_get_attributes (const PsppireSheet *sheet,
+                                             gint row, gint col,
+                                             PsppireSheetCellAttr *attributes);
+
+
 
 static void
 psppire_sheet_cell_draw (PsppireSheet *sheet, gint row, gint col)
@@ -5248,7 +5255,7 @@ set_row_height (PsppireSheet *sheet,
     }
 }
 
-gboolean
+static gboolean
 psppire_sheet_get_attributes (const PsppireSheet *sheet, gint row, gint col,
                          PsppireSheetCellAttr *attr)
 {
@@ -5271,8 +5278,6 @@ psppire_sheet_get_attributes (const PsppireSheet *sheet, gint row, gint col,
   attr->border.mask = 0;
   attr->border.color = GTK_WIDGET (sheet)->style->black;
 
-  attr->is_editable = psppire_sheet_model_is_editable (sheet->model, row, col);
-
   colormap = gtk_widget_get_colormap (GTK_WIDGET (sheet));
   fg = psppire_sheet_model_get_foreground (sheet->model, row, col);
   if ( fg )
index 82de87bed5659a21088ab347ce10d799278c2574..8e83765cbcfb63494a429978d64162f10f45870c 100644 (file)
@@ -84,7 +84,6 @@ struct _PsppireSheetCellAttr
   GdkColor foreground;
   GdkColor background;
   PsppireSheetCellBorder border;
-  gboolean is_editable;
 };
 
 struct _PsppireSheetHoverTitle
@@ -300,12 +299,6 @@ void psppire_sheet_get_active_cell (PsppireSheet *sheet,
 gchar *psppire_sheet_cell_get_text (const PsppireSheet *sheet, gint row, gint col);
 
 
-/* get cell attributes of the given cell */
-/* TRUE means that the cell is currently allocated */
-gboolean psppire_sheet_get_attributes       (const PsppireSheet *sheet,
-                                       gint row, gint col,
-                                       PsppireSheetCellAttr *attributes);
-
 void psppire_sheet_set_model (PsppireSheet *sheet,
                                   PsppireSheetModel *model);
 
index 5f14e62c9e7418517268da48e63a1d7203ecf787..1a2b4af13113f08098b3be0a585e6444999dc1a7 100644 (file)
@@ -73,7 +73,8 @@ nodist_src_ui_gui_psppire_DATA = \
        $(top_builddir)/src/ui/gui/syntax-editor.ui \
        $(top_builddir)/src/ui/gui/text-data-import.ui \
        $(top_builddir)/src/ui/gui/t-test.ui \
-       $(top_builddir)/src/ui/gui/var-sheet-dialogs.ui
+       $(top_builddir)/src/ui/gui/var-sheet-dialogs.ui \
+       $(top_builddir)/src/ui/gui/variable-info-dialog.ui
 
 
 dist_src_ui_gui_psppire_DATA = \
@@ -118,8 +119,8 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/descriptives-dialog.h \
        src/ui/gui/dialog-common.c \
        src/ui/gui/dialog-common.h \
-       src/ui/gui/dict-display.c \
        src/ui/gui/dict-display.h \
+       src/ui/gui/dict-display.c \
        src/ui/gui/examine-dialog.c \
        src/ui/gui/examine-dialog.h \
        src/ui/gui/find-dialog.c \
@@ -152,6 +153,8 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/psppire-dialog.h \
        src/ui/gui/psppire-dict.c \
        src/ui/gui/psppire-dict.h \
+       src/ui/gui/psppire-dictview.c \
+       src/ui/gui/psppire-dictview.h \
        src/ui/gui/psppire-hbuttonbox.h \
        src/ui/gui/psppire-keypad.h \
        src/ui/gui/psppire-output-window.c \
@@ -225,7 +228,8 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/syntax-editor.glade \
        src/ui/gui/text-data-import.glade \
        src/ui/gui/t-test.glade \
-       src/ui/gui/var-sheet-dialogs.glade
+       src/ui/gui/var-sheet-dialogs.glade \
+       src/ui/gui/variable-info-dialog.glade
 
 
 nodist_src_ui_gui_psppire_SOURCES = \
index 7269ab79750e76c3ed2cf5c7431045d5506545c3..e3d1c6a1410c645b6998ec89dfb570d0cefe3a3c 100644 (file)
@@ -22,8 +22,8 @@
 #include "psppire-keypad.h"
 #include "psppire-data-window.h"
 #include "psppire-var-store.h"
+#include "psppire-selector.h"
 #include "dialog-common.h"
-#include "dict-display.h"
 
 #include <language/expressions/public.h>
 #include <language/syntax-string-source.h>
@@ -396,11 +396,10 @@ compute_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view),
-                                vs->dict,
-                                GTK_SELECTION_SINGLE, NULL);
-
+  g_object_set (dict_view,
+               "model", vs->dict,
+               "selection-mode", GTK_SELECTION_SINGLE,
+               NULL);
 
   psppire_selector_set_subjects (PSPPIRE_SELECTOR (var_selector),
                                 dict_view, syntax_area,
index 188c4aaa92c66c339c829bef59df4748f6e23516..3d5c5718fc6477172023666d761620760ec173ab 100644 (file)
@@ -422,9 +422,7 @@ crosstabs_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
+  g_object_set (source, "model", vs->dict, NULL);
 
   set_dest_model (GTK_TREE_VIEW (dest_rows), vs->dict);
   set_dest_model (GTK_TREE_VIEW (dest_cols), vs->dict);
index d5907a552946866010a334c13da5175148b0e65a..0409d9e512459125aa878386099f18c1202bafc8 100644 (file)
                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                 <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                 <child>
-                  <widget class="GtkTreeView" id="dict-treeview">
+                  <widget class="PsppireDictView" id="dict-treeview">
                     <property name="visible">True</property>
                     <property name="headers_visible">False</property>
                   </widget>
index e3a6d505115c25ad4b85b7bc259ca7fb88e450e3..77bf95410870fa9deaa00ef98e7cb5c60b53c1b1 100644 (file)
@@ -223,9 +223,8 @@ descriptives_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, var_is_numeric);
+  g_object_set (source, "model", vs->dict,
+       "predicate", var_is_numeric, NULL);
 
   set_dest_model (GTK_TREE_VIEW (dest), vs->dict);
 
index 6ce00df808567786c552a68809a73381a1dad7e3..3fa67a55a8aa4c7baa1e80a0f88574b4caac9e54 100644 (file)
@@ -29,7 +29,7 @@
                     <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                     <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                     <child>
-                      <widget class="GtkTreeView" id="all-variables">
+                      <widget class="PsppireDictView" id="all-variables">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
index 6d1671454740454eb32c0d459815d718469f8eb3..2123c3c5cfe7b300b6c2bcaca241f5ae95d5636d 100644 (file)
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
 
-
-/* A GtkTreeModelFilterVisibleFunc to filter lines in the treeview */
-static gboolean
-filter_variables (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
-{
-  var_predicate_func *predicate = data;
-  struct variable *var;
-  PsppireDict *dict = PSPPIRE_DICT (model);
-
-  GtkTreePath *path = gtk_tree_model_get_path (model, iter);
-
-  gint *idx = gtk_tree_path_get_indices (path);
-
-  var =  psppire_dict_get_variable (dict, *idx);
-
-  gtk_tree_path_free (path);
-
-  return predicate (var);
-}
-
-/* A GtkTreeCellDataFunc which sets the icon appropriate to the type
-   of variable */
 static void
-var_icon_cell_data_func (GtkTreeViewColumn *col,
-                      GtkCellRenderer *cell,
-                      GtkTreeModel *model,
-                      GtkTreeIter *iter,
-                      gpointer data)
-{
-  struct variable *var;
-  gtk_tree_model_get (model, iter, DICT_TVM_COL_VAR, &var, -1);
-
-  if ( var_is_alpha (var))
-    {
-      g_object_set (cell, "stock-id", "var-string", NULL);
-    }
-  else
-    {
-      const struct fmt_spec *fs = var_get_write_format (var);
-      int cat = fmt_get_category (fs->type);
-      switch ( var_get_measure (var))
-       {
-       case MEASURE_NOMINAL:
-         g_object_set (cell, "stock-id", "var-nominal", NULL);
-         break;
-       case MEASURE_ORDINAL:
-         g_object_set (cell, "stock-id", "var-ordinal", NULL);
-         break;
-       case MEASURE_SCALE:
-         if ( ( FMT_CAT_DATE | FMT_CAT_TIME ) & cat )
-           g_object_set (cell, "stock-id", "var-date-scale", NULL);
-         else
-           g_object_set (cell, "stock-id", "var-scale", NULL);
-         break;
-       default:
-         g_assert_not_reached ();
-       };
-    }
-}
-
-
-void
 get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
                GtkTreeModel **model, GtkTreeIter *iter
                )
@@ -113,191 +52,6 @@ get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
   g_assert (PSPPIRE_IS_DICT (*model));
 }
 
-/* A GtkTreeCellDataFunc which renders the name and/or label of the
-   variable */
-static void
-var_description_cell_data_func (GtkTreeViewColumn *col,
-                               GtkCellRenderer *cell,
-                               GtkTreeModel *top_model,
-                               GtkTreeIter *top_iter,
-                               gpointer 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);
-
-  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)
-    {
-      gchar *text = g_strdup_printf (
-                                    "<span stretch=\"condensed\">%s</span>",
-                                    var_get_label (var));
-
-      char *utf8 = pspp_locale_to_utf8 (text, -1, NULL);
-
-      g_free (text);
-      g_object_set (cell, "markup", utf8, NULL);
-      g_free (utf8);
-    }
-  else
-    {
-      char *name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL);
-      g_object_set (cell, "text", name, NULL);
-      g_free (name);
-    }
-}
-
-
-/* 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;
-
-  {
-    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 )
-      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;
-}
-
-   /* 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
-   all are to be visible.
- */
-void
-attach_dictionary_to_treeview (GtkTreeView *treeview, PsppireDict *dict,
-                              GtkSelectionMode mode,
-                              var_predicate_func *predicate
-                              )
-{
-  GtkTreeViewColumn *col;
-
-  GtkTreeSelection *selection =
-    gtk_tree_view_get_selection (treeview);
-
-  GtkCellRenderer *renderer;
-
-  GtkTreeModel *model ;
-
-  if ( predicate )
-    {
-      model = gtk_tree_model_filter_new (GTK_TREE_MODEL (dict),
-                                         NULL);
-
-      gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model),
-                                             filter_variables,
-                                             predicate,
-                                             NULL);
-    }
-  else
-    {
-      model = GTK_TREE_MODEL (dict);
-    }
-
-  gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), model);
-
-
-  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);
-
-  g_object_set (renderer, "ellipsize-set", TRUE, NULL);
-  g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL);
-
-  gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
-
-  /* FIXME: make this a value in terms of character widths */
-  gtk_tree_view_column_set_min_width (col, 150);
-
-  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
@@ -396,3 +150,4 @@ is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter,
 }
 
 
+
index a9481c6d85534439490d672accbf7d1a56f06f46..2c8df4407655e7d48cd4aedca7bd880d3130227a 100644 (file)
 #include <gtk/gtk.h>
 
 #include "psppire-selector.h"
-#include "psppire-dict.h"
-#include <data/variable.h>
-
-/* 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
-   all are to be visible.
- */
-void attach_dictionary_to_treeview (GtkTreeView *treeview, PsppireDict *dict,
-                                   GtkSelectionMode mode,
-                                   var_predicate_func *predicate
-                                   );
 
 
 /* A SelectItemsFunc function for GtkTreeView widgets */
@@ -58,6 +46,3 @@ gboolean is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter,
                                PsppireSelector *selector);
 
 
-void get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
-                    GtkTreeModel **model, GtkTreeIter *iter
-                    );
index 171d88cfc2f9f6def60a12b6fee571f22825bbce..2902685d395f45ac932a88251f0dc3a30ab5d579 100644 (file)
@@ -279,10 +279,7 @@ examine_dialog (GObject *o, gpointer data)
   gtk_window_set_transient_for (GTK_WINDOW (ex_d.stats_dialog), GTK_WINDOW (de));
   gtk_window_set_transient_for (GTK_WINDOW (ex_d.opts_dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
-
+  g_object_set (source, "model", vs->dict, NULL);
 
   set_dest_model (GTK_TREE_VIEW (ex_d.dep_list), vs->dict);
   ex_d.dict = vs->dict;
index 884e00017da775bbd5a1c4c9b969fb8b91d80f75..a6f7ca8a7d57c96156ae7ac97c87d0abcd2c2c76 100644 (file)
                     <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                     <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                     <child>
-                      <widget class="GtkTreeView" id="treeview1">
+                      <widget class="PsppireDictView" id="treeview1">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
index 130b25cfafe54db8f73eca358dada6da80f77b41..60d54e2679cb37d55c67c38f3c3b209fa1d1dedc 100644 (file)
@@ -241,10 +241,9 @@ find_dialog (GObject *o, gpointer data)
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                fd.dict,
-                                GTK_SELECTION_SINGLE,
-                                NULL);
+  g_object_set (source, "model", fd.dict, 
+       "selection-mode", GTK_SELECTION_SINGLE,
+       NULL);
 
   psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector),
                                 source,
index 37e301b88babb099490ed752a075e5e7f44da9f5..a368cabb2a8d622efec471220fb279c59e565890 100644 (file)
@@ -333,9 +333,7 @@ frequencies_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
+  g_object_set (source, "model", vs->dict, NULL);
 
   set_dest_model (GTK_TREE_VIEW (dest), vs->dict);
 
index 5617d40d2c3e2cce6be7219fef1068046827a713..3e5e921349e937fae732c330a96239affe5f9269 100644 (file)
@@ -29,7 +29,7 @@
                     <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                     <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                     <child>
-                      <widget class="GtkTreeView" id="dict-treeview">
+                      <widget class="PsppireDictView" id="dict-treeview">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
index d41b2760aa97630510ca82315ae96c1b1eb1f87c..3c80f9e3574e226c9509008d0a329bcd39ee9406 100644 (file)
@@ -25,8 +25,9 @@
 #include "psppire-data-window.h"
 #include "psppire-dialog.h"
 #include "dialog-common.h"
-#include "dict-display.h"
 #include "psppire-acr.h"
+#include "psppire-selector.h"
+#include "dict-display.h"
 
 
 #include <language/syntax-string-source.h>
@@ -170,9 +171,7 @@ oneway_anova_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (ow.dialog, GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
+  g_object_set (dict_view, "model", vs->dict, NULL);
 
   set_dest_model (GTK_TREE_VIEW (ow.vars_treeview), vs->dict);
 
index bdca13ddb54e8dec747bf3d4f70c464520518fb2..4b12f68b9b050e31e64591560c8c0843c912452c 100644 (file)
                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                 <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                 <child>
-                  <widget class="GtkTreeView" id="oneway-anova-treeview1">
+                  <widget class="PsppireDictView" id="oneway-anova-treeview1">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
index d121d961b34c3100689b687e4105a0723e0cc5a3..184ebd16df8d8deac3115172710dd451847eb7d4 100644 (file)
@@ -142,7 +142,7 @@ psppire_button_box_class_init (PsppireButtonBoxClass *class)
     g_param_spec_flags ("buttons",
                        _("Buttons"),
                        _("The mask that decides what buttons appear in the button box"),
-                       G_TYPE_PSPPIRE_BUTTON_MASK,
+                       PSPPIRE_TYPE_BUTTON_MASK,
                        PSPPIRE_BUTTON_OK_MASK |
                        PSPPIRE_BUTTON_CANCEL_MASK |
                        PSPPIRE_BUTTON_RESET_MASK |
index 3f865facd040e33cd937112cddf66aca8c7e6ac5..03f9fe34e6a737e5ae12558a704f80042cd81ce7 100644 (file)
@@ -71,7 +71,7 @@ _psppire_button_box_child_requisition (GtkWidget *widget,
                                       int       *width,
 
 
-#define G_TYPE_PSPPIRE_BUTTON_MASK \
+#define PSPPIRE_TYPE_BUTTON_MASK \
   (psppire_button_flags_get_type())
                                       int       *height);
 
index d9f6800ffd0d494278e29b0ca8a3dc2304b4f6e2..4090b74c3ea9dce414e42cb59bb643c6c312a15e 100644 (file)
@@ -181,16 +181,20 @@ psppire_conf_get_boolean (PsppireConf *conf, const gchar *base,
                          const gchar *name, gboolean *value)
 {
   gboolean ok;
+  gboolean b;
   GError *err = NULL;
   conf_read (conf);
-  *value = g_key_file_get_boolean (conf->keyfile,
-                                  base,
-                                  name, &err);
+  b = g_key_file_get_boolean (conf->keyfile,
+                             base,
+                             name, &err);
 
   ok = (err == NULL);
   if ( err != NULL )
     g_error_free (err);
 
+  if (ok)
+    *value = b;
+
   return ok;
 }
 
@@ -270,9 +274,6 @@ psppire_conf_save_window_geometry (PsppireConf *conf,
             GDK_WINDOW_STATE_MAXIMIZED )
          return;
 
-       if ( event->send_event )
-         return;
-
        psppire_conf_set_int (conf, base, "height", event->height);
        psppire_conf_set_int (conf, base, "width", event->width);
 
@@ -292,4 +293,5 @@ psppire_conf_save_window_geometry (PsppireConf *conf,
     default:
       break;
     };
+
 }
index a608e6de29e8745d089b885189e0249dc5b36570..ab3b21284ec55d23968c7c0de5c3a3fa246beb52 100644 (file)
@@ -862,11 +862,10 @@ init_data_sheet (PsppireDataEditor *de)
   de->vaxis[0] = psppire_axis_impl_new ();
   de->vaxis[1] = psppire_axis_impl_new ();
 
-  /* Txoxovhere's only one horizontal axis, since the
+  /* There's only one horizontal axis, since the
      column widths are parameters of the variables */
   de->haxis = psppire_axis_impl_new ();
 
-
   de->split = TRUE;
   de->paned = gtk_xpaned_new ();
 
index c754f73038f69e49238b2c881e004f7f65a0c4ad..5efb02dedb1e1ecade630d4e25af1025cb59d2c1 100644 (file)
@@ -53,7 +53,6 @@
 #include "crosstabs-dialog.h"
 #include "frequencies-dialog.h"
 #include "examine-dialog.h"
-#include "dict-display.h"
 #include "regression-dialog.h"
 #include "oneway-anova-dialog.h"
 #include "t-test-independent-samples-dialog.h"
index 22b4cf4eb339d752f0442fa6231b66696e10c29e..dbe4612f026a160f29592553894be93caff3e3ca 100644 (file)
@@ -73,7 +73,6 @@ psppire_dialog_get_type (void)
       g_type_add_interface_static (dialog_type,
                                   GTK_TYPE_BUILDABLE,
                                   &buildable_info);
-
     }
 
   return dialog_type;
@@ -104,7 +103,8 @@ psppire_dialog_finalize (GObject *object)
 enum
 {
   PROP_0,
-  PROP_ORIENTATION
+  PROP_ORIENTATION,
+  PROP_SLIDING
 };
 
 
@@ -120,14 +120,17 @@ psppire_dialog_get_property (GObject         *object,
     {
     case PROP_ORIENTATION:
       {
-       if ( GTK_IS_VBOX (dialog->box) )
+       if ( GTK_IS_VBOX (dialog->box) || GTK_VPANED (dialog->box))
          g_value_set_enum (value, PSPPIRE_VERTICAL);
-       else if ( GTK_IS_HBOX (dialog->box))
+       else if ( GTK_IS_HBOX (dialog->box) || GTK_HPANED (dialog->box))
          g_value_set_enum (value, PSPPIRE_HORIZONTAL);
        else if ( GTK_IS_TABLE (dialog->box))
          g_value_set_enum (value, PSPPIRE_TABULAR);
       }
       break;
+    case PROP_SLIDING:
+      g_value_set_boolean (value, dialog->slidable);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -136,22 +139,26 @@ psppire_dialog_get_property (GObject         *object,
 
 
 static void
-dialog_set_orientation (PsppireDialog *dialog, const GValue *orval)
+dialog_set_container (PsppireDialog *dialog)
 {
-  PsppireOrientation orientation = g_value_get_enum (orval);
-
   if ( dialog->box != NULL)
     {
       gtk_container_remove (GTK_CONTAINER (dialog), dialog->box);
     }
 
-  switch ( orientation )
+  switch (dialog->orientation)
     {
     case PSPPIRE_HORIZONTAL:
-      dialog->box = gtk_hbox_new (FALSE, 5);
+      if ( dialog->slidable)
+       dialog->box = gtk_hpaned_new();
+      else
+       dialog->box = gtk_hbox_new (FALSE, 5);
       break;
     case PSPPIRE_VERTICAL:
-      dialog->box = gtk_vbox_new (FALSE, 5);
+      if ( dialog->slidable)
+       dialog->box = gtk_vpaned_new();
+      else
+       dialog->box = gtk_vbox_new (FALSE, 5);
       break;
     case PSPPIRE_TABULAR:
       dialog->box = gtk_table_new (2, 3, FALSE);
@@ -162,6 +169,7 @@ dialog_set_orientation (PsppireDialog *dialog, const GValue *orval)
       break;
     }
 
+  gtk_widget_show_all (dialog->box);
   gtk_container_add (GTK_CONTAINER (dialog), dialog->box);
 }
 
@@ -177,13 +185,18 @@ psppire_dialog_set_property (GObject         *object,
 
   switch (prop_id)
     {
+    case PROP_SLIDING:
+      dialog->slidable = g_value_get_boolean (value);
+      break;
     case PROP_ORIENTATION:
-      dialog_set_orientation (dialog, value);
+      dialog->orientation = g_value_get_enum (value);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
     };
+
+  dialog_set_container (dialog);
 }
 
 
@@ -194,15 +207,24 @@ psppire_dialog_class_init (PsppireDialogClass *class)
 {
   GObjectClass *object_class = (GObjectClass *) class;
 
+  GParamSpec *sliding_spec ;
 
   orientation_spec =
     g_param_spec_enum ("orientation",
                       "Orientation",
                       "Which way widgets are packed",
-                      G_TYPE_PSPPIRE_ORIENTATION,
+                      PSPPIRE_TYPE_ORIENTATION,
                       PSPPIRE_HORIZONTAL /* default value */,
                       G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
 
+  sliding_spec =
+    g_param_spec_boolean ("slidable",
+                         "Slidable",
+                         "Can the container be sized by the user",
+                         FALSE,
+                         G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
+
+
 
   object_class->set_property = psppire_dialog_set_property;
   object_class->get_property = psppire_dialog_get_property;
@@ -212,6 +234,11 @@ psppire_dialog_class_init (PsppireDialogClass *class)
                                    orientation_spec);
 
 
+  g_object_class_install_property (object_class,
+                                   PROP_SLIDING,
+                                   sliding_spec);
+
+
 
   signals [DIALOG_REFRESH] =
     g_signal_new ("refresh",
@@ -305,6 +332,7 @@ psppire_dialog_init (PsppireDialog *dialog)
   dialog->box = NULL;
   dialog->contents_are_valid = NULL;
   dialog->validity_data = NULL;
+  dialog->slidable = FALSE;
 
   g_value_init (&value, orientation_spec->value_type);
   g_param_value_set_default (orientation_spec, &value);
@@ -312,8 +340,6 @@ psppire_dialog_init (PsppireDialog *dialog)
   gtk_window_set_type_hint (GTK_WINDOW (dialog),
        GDK_WINDOW_TYPE_HINT_DIALOG);
 
-  dialog_set_orientation (dialog, &value);
-
   g_value_unset (&value);
 
   g_signal_connect (dialog, "delete-event",
@@ -333,8 +359,6 @@ psppire_dialog_init (PsppireDialog *dialog)
        GDK_WINDOW_TYPE_HINT_DIALOG);
 
   g_object_set (dialog, "icon-name", "psppicon", NULL);
-
-  gtk_widget_show_all (dialog->box);
 }
 
 
index 05215ce984e2b14bd332aad5bb02f86ffd25d2ef..6c175cfb8a690d0de4632f5daabacfc12bf754e5 100644 (file)
@@ -42,6 +42,14 @@ typedef struct _PsppireDialogClass  PsppireDialogClass;
 
 typedef gboolean (*ContentsAreValid) (gpointer);
 
+typedef enum
+  {
+    PSPPIRE_HORIZONTAL,
+    PSPPIRE_VERTICAL,
+    PSPPIRE_TABULAR
+  } PsppireOrientation;
+
+
 
 struct _PsppireDialog
 {
@@ -54,6 +62,8 @@ struct _PsppireDialog
 
   ContentsAreValid contents_are_valid;
   gpointer validity_data;
+  gboolean slidable;
+  PsppireOrientation orientation;
 };
 
 struct _PsppireDialogClass
@@ -77,14 +87,7 @@ void           psppire_dialog_notify_change (PsppireDialog *);
 GType psppire_orientation_get_type (void);
 
 
-typedef enum
-  {
-    PSPPIRE_HORIZONTAL,
-    PSPPIRE_VERTICAL,
-    PSPPIRE_TABULAR
-  } PsppireOrientation;
-
-#define G_TYPE_PSPPIRE_ORIENTATION (psppire_orientation_get_type ())
+#define PSPPIRE_TYPE_ORIENTATION (psppire_orientation_get_type ())
 
 
 G_END_DECLS
index 91293956b9e8e2ab613b83b719674c1b54e7bc97..564257f46c8cdb74c6adef8ce6d4547f0bd70764 100644 (file)
@@ -315,7 +315,7 @@ psppire_dict_init (PsppireDict *psppire_dict)
 PsppireDict*
 psppire_dict_new_from_dict (struct dictionary *d)
 {
-  PsppireDict *new_dict = g_object_new (G_TYPE_PSPPIRE_DICT, NULL);
+  PsppireDict *new_dict = g_object_new (PSPPIRE_TYPE_DICT, NULL);
   new_dict->dict = d;
 
   dict_set_callbacks (new_dict->dict, &gui_callbacks, new_dict);
index 534f0707ea22df8bc6084a1d8193c917d4ae0e0a..6d731f212a98203225028bbb9f6de79a4253682a 100644 (file)
@@ -30,12 +30,12 @@ G_BEGIN_DECLS
 
 
 /* --- type macros --- */
-#define G_TYPE_PSPPIRE_DICT              (psppire_dict_get_type ())
-#define PSPPIRE_DICT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_PSPPIRE_DICT, PsppireDict))
-#define PSPPIRE_DICT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
-#define PSPPIRE_IS_DICT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_PSPPIRE_DICT))
-#define PSPPIRE_IS_DICT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_PSPPIRE_DICT))
-#define PSPPIRE_DICT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_PSPPIRE_DICT, PsppireDictClass))
+#define PSPPIRE_TYPE_DICT              (psppire_dict_get_type ())
+#define PSPPIRE_DICT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PSPPIRE_TYPE_DICT, PsppireDict))
+#define PSPPIRE_DICT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PSPPIRE_TYPE_DICT, PsppireDictClass))
+#define PSPPIRE_IS_DICT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PSPPIRE_TYPE_DICT))
+#define PSPPIRE_IS_DICT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DICT))
+#define PSPPIRE_DICT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PSPPIRE_TYPE_DICT, PsppireDictClass))
 
 
 /* --- typedefs & structures --- */
diff --git a/src/ui/gui/psppire-dictview.c b/src/ui/gui/psppire-dictview.c
new file mode 100644 (file)
index 0000000..336092f
--- /dev/null
@@ -0,0 +1,545 @@
+/* PSPPIRE - a graphical user interface for PSPP.
+   Copyright (C) 2009  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
+   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,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <gtk/gtktreeview.h>
+#include "psppire-dictview.h"
+#include "psppire-dict.h"
+#include "psppire-conf.h"
+#include <data/format.h>
+#include "helper.h"
+
+#include <gettext.h>
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+static void psppire_dict_view_base_finalize (PsppireDictViewClass *, gpointer);
+static void psppire_dict_view_base_init     (PsppireDictViewClass *class);
+static void psppire_dict_view_class_init    (PsppireDictViewClass *class);
+static void psppire_dict_view_init          (PsppireDictView      *dict_view);
+
+
+GType
+psppire_dict_view_get_type (void)
+{
+  static GType psppire_dict_view_type = 0;
+
+  if (!psppire_dict_view_type)
+    {
+      static const GTypeInfo psppire_dict_view_info =
+      {
+       sizeof (PsppireDictViewClass),
+       (GBaseInitFunc) psppire_dict_view_base_init,
+        (GBaseFinalizeFunc) psppire_dict_view_base_finalize,
+       (GClassInitFunc)psppire_dict_view_class_init,
+       (GClassFinalizeFunc) NULL,
+       NULL,
+        sizeof (PsppireDictView),
+       0,
+       (GInstanceInitFunc) psppire_dict_view_init,
+      };
+
+      psppire_dict_view_type =
+       g_type_register_static (GTK_TYPE_TREE_VIEW, "PsppireDictView",
+                               &psppire_dict_view_info, 0);
+    }
+
+  return psppire_dict_view_type;
+}
+
+
+static void
+psppire_dict_view_finalize (GObject *object)
+{
+  PsppireDictView *dict_view = PSPPIRE_DICT_VIEW (object);
+
+  g_object_unref (dict_view->menu);
+}
+
+/* Properties */
+enum
+{
+  PROP_0,
+  PROP_MODEL,
+  PROP_PREDICATE,
+  PROP_SELECTION_MODE
+};
+
+
+/* A GtkTreeModelFilterVisibleFunc to filter lines in the treeview */
+static gboolean
+filter_variables (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+{
+  var_predicate_func *predicate = data;
+  struct variable *var;
+  PsppireDict *dict = PSPPIRE_DICT (model);
+
+  GtkTreePath *path = gtk_tree_model_get_path (model, iter);
+
+  gint *idx = gtk_tree_path_get_indices (path);
+
+  var =  psppire_dict_get_variable (dict, *idx);
+
+  gtk_tree_path_free (path);
+
+  return predicate (var);
+}
+
+static void
+set_model (PsppireDictView *dict_view)
+{
+  GtkTreeModel *model ;
+
+  if ( dict_view->predicate )
+    {
+      model = gtk_tree_model_filter_new (GTK_TREE_MODEL (dict_view->dict),
+                                        NULL);
+
+      gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model),
+                                             filter_variables,
+                                             dict_view->predicate,
+                                             NULL);
+    }
+  else
+    {
+      model = GTK_TREE_MODEL (dict_view->dict);
+    }
+
+  gtk_tree_view_set_model (GTK_TREE_VIEW (dict_view), model);
+}
+
+static void
+psppire_dict_view_set_property (GObject         *object,
+                              guint            prop_id,
+                              const GValue    *value,
+                              GParamSpec      *pspec)
+{
+  PsppireDictView *dict_view = PSPPIRE_DICT_VIEW (object);
+
+  switch (prop_id)
+    {
+    case PROP_MODEL:
+      dict_view->dict = g_value_get_object (value);
+      break;
+    case PROP_PREDICATE:
+      dict_view->predicate = g_value_get_pointer (value);
+      break;
+    case PROP_SELECTION_MODE:
+      {
+       GtkTreeSelection *selection =
+         gtk_tree_view_get_selection (GTK_TREE_VIEW (dict_view));
+
+       GtkSelectionMode mode = g_value_get_enum (value);
+
+       gtk_tree_selection_set_mode (selection, mode);
+      }
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    };
+
+
+  set_model (dict_view);
+}
+
+
+static void
+psppire_dict_view_get_property (GObject         *object,
+                              guint            prop_id,
+                              GValue          *value,
+                              GParamSpec      *pspec)
+{
+  PsppireDictView *dict_view = PSPPIRE_DICT_VIEW (object);
+
+  switch (prop_id)
+    {
+    case PROP_MODEL:
+      g_value_set_object (value, dict_view->dict);
+      break;
+    case PROP_PREDICATE:
+      g_value_set_pointer (value, dict_view->predicate);
+      break;
+    case PROP_SELECTION_MODE:
+      {
+       GtkTreeSelection *selection =
+         gtk_tree_view_get_selection (GTK_TREE_VIEW (dict_view));
+
+       g_value_set_enum (value, gtk_tree_selection_get_mode (selection));
+      }
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    };
+}
+
+
+
+static void
+psppire_dict_view_class_init (PsppireDictViewClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  GParamSpec *model_spec =
+    g_param_spec_object ("model",
+                        "Model",
+                        _("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",
+                         _("A predicate function"),
+                         G_PARAM_READABLE | G_PARAM_WRITABLE);
+
+
+  GParamSpec *selection_mode_spec =
+    g_param_spec_enum ("selection-mode",
+                      "Selection Mode",
+                      _("How many things can be selected"),
+                      GTK_TYPE_SELECTION_MODE,
+                      GTK_SELECTION_MULTIPLE,
+                      G_PARAM_CONSTRUCT | G_PARAM_READABLE | G_PARAM_WRITABLE);
+
+
+  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,
+                                   model_spec);
+
+  g_object_class_install_property (object_class,
+                                   PROP_PREDICATE,
+                                   predicate_spec);
+
+  g_object_class_install_property (object_class,
+                                   PROP_SELECTION_MODE,
+                                   selection_mode_spec);
+}
+
+
+static void
+psppire_dict_view_base_init (PsppireDictViewClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->finalize = psppire_dict_view_finalize;
+}
+
+
+
+static void
+psppire_dict_view_base_finalize (PsppireDictViewClass *class,
+                                gpointer class_data)
+{
+
+}
+
+
+static void
+dv_get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
+               GtkTreeModel **model, GtkTreeIter *iter
+               )
+{
+  *model = top_model;
+  *iter = *top_iter;
+  while (GTK_IS_TREE_MODEL_FILTER (*model))
+    {
+      GtkTreeIter parent_iter = *iter;
+      GtkTreeModelFilter *parent_model = GTK_TREE_MODEL_FILTER (*model);
+
+      *model = gtk_tree_model_filter_get_model (parent_model);
+
+      gtk_tree_model_filter_convert_iter_to_child_iter (parent_model,
+                                                       iter,
+                                                       &parent_iter);
+    }
+
+  g_assert (PSPPIRE_IS_DICT (*model));
+}
+
+
+
+/* A GtkTreeCellDataFunc which renders the name and/or label of the
+   variable */
+static void
+var_description_cell_data_func (GtkTreeViewColumn *col,
+                               GtkCellRenderer *cell,
+                               GtkTreeModel *top_model,
+                               GtkTreeIter *top_iter,
+                               gpointer data)
+{
+  PsppireDictView *dv = PSPPIRE_DICT_VIEW (data);
+  struct variable *var;
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+
+
+  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) && dv->prefer_labels)
+    {
+      gchar *text = g_strdup_printf (
+                                    "<span stretch=\"condensed\">%s</span>",
+                                    var_get_label (var));
+
+      char *utf8 = pspp_locale_to_utf8 (text, -1, NULL);
+
+      g_free (text);
+      g_object_set (cell, "markup", utf8, NULL);
+      g_free (utf8);
+    }
+  else
+    {
+      char *name = pspp_locale_to_utf8 (var_get_name (var), -1, NULL);
+      g_object_set (cell, "text", name, NULL);
+      g_free (name);
+    }
+}
+
+
+
+/* A GtkTreeCellDataFunc which sets the icon appropriate to the type
+   of variable */
+static void
+var_icon_cell_data_func (GtkTreeViewColumn *col,
+                      GtkCellRenderer *cell,
+                      GtkTreeModel *model,
+                      GtkTreeIter *iter,
+                      gpointer data)
+{
+  struct variable *var;
+  gtk_tree_model_get (model, iter, DICT_TVM_COL_VAR, &var, -1);
+
+  if ( var_is_alpha (var))
+    {
+      g_object_set (cell, "stock-id", "var-string", NULL);
+    }
+  else
+    {
+      const struct fmt_spec *fs = var_get_write_format (var);
+      int cat = fmt_get_category (fs->type);
+      switch ( var_get_measure (var))
+       {
+       case MEASURE_NOMINAL:
+         g_object_set (cell, "stock-id", "var-nominal", NULL);
+         break;
+       case MEASURE_ORDINAL:
+         g_object_set (cell, "stock-id", "var-ordinal", NULL);
+         break;
+       case MEASURE_SCALE:
+         if ( ( FMT_CAT_DATE | FMT_CAT_TIME ) & cat )
+           g_object_set (cell, "stock-id", "var-date-scale", NULL);
+         else
+           g_object_set (cell, "stock-id", "var-scale", NULL);
+         break;
+       default:
+         g_assert_not_reached ();
+       };
+    }
+}
+
+
+/* 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;
+
+  {
+    gchar *tip ;
+
+    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);
+
+    gtk_tooltip_set_text (tooltip, tip);
+
+    g_free (tip);
+  }
+
+  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 = gtk_tree_view_column_new ();
+
+  GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new ();
+
+  dict_view->prefer_labels = TRUE;
+
+  psppire_conf_get_boolean (psppire_conf_new (),
+                           "dialog-boxes", "prefer-labels",
+                           &dict_view->prefer_labels);
+
+  gtk_tree_view_column_set_title (col, _("Variable"));
+
+  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,
+                                          dict_view, NULL);
+
+  g_object_set (renderer, "ellipsize-set", TRUE, NULL);
+  g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL);
+
+  gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
+
+  /* FIXME: make this a value in terms of character widths */
+  gtk_tree_view_column_set_min_width (col, 150);
+
+  gtk_tree_view_append_column (GTK_TREE_VIEW (dict_view), col);
+
+  g_object_set (dict_view, "has-tooltip", TRUE, 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);
+}
+
+
+GtkWidget*
+psppire_dict_view_new (void)
+{
+  return GTK_WIDGET (g_object_new (psppire_dict_view_get_type (), NULL));
+}
+
+
+
+struct variable *
+psppire_dict_view_get_selected_variable (PsppireDictView *treeview)
+{
+  struct variable *var;
+  GtkTreeModel *top_model;
+  GtkTreeIter top_iter;
+
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+
+  GtkTreeSelection *selection =
+    gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+
+  if (! gtk_tree_selection_get_selected (selection,
+                                        &top_model, &top_iter))
+    return NULL;
+
+  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);
+
+  return var;
+}
+
+
diff --git a/src/ui/gui/psppire-dictview.h b/src/ui/gui/psppire-dictview.h
new file mode 100644 (file)
index 0000000..dd08d78
--- /dev/null
@@ -0,0 +1,68 @@
+/* PSPPIRE - a graphical user interface for PSPP.
+   Copyright (C) 2009  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
+   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,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>. */
+
+
+#ifndef __PSPPIRE_DICT_VIEW_H__
+#define __PSPPIRE_DICT_VIEW_H__
+
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtktreeview.h>
+
+#include "psppire-dict.h"
+#include "dict-display.h"
+
+G_BEGIN_DECLS
+
+#define PSPPIRE_DICT_VIEW_TYPE            (psppire_dict_view_get_type ())
+#define PSPPIRE_DICT_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPPIRE_DICT_VIEW_TYPE, PsppireDictView))
+#define PSPPIRE_DICT_VIEW_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), \
+    PSPPIRE_DICT_VIEW_TYPE, PsppireDictViewClass))
+#define PSPPIRE_IS_DICT_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+    PSPPIRE_DICT_VIEW_TYPE))
+#define PSPPIRE_IS_DICT_VIEW_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
+    PSPPIRE_DICT_VIEW_TYPE))
+
+
+typedef struct _PsppireDictView       PsppireDictView;
+typedef struct _PsppireDictViewClass  PsppireDictViewClass;
+
+
+
+struct _PsppireDictView
+{
+  GtkTreeView parent;
+
+  PsppireDict *dict;
+  var_predicate_func *predicate;
+  GtkWidget *menu;
+  gboolean prefer_labels;
+};
+
+struct _PsppireDictViewClass
+{
+  GtkTreeViewClass parent_class;
+
+};
+
+GType      psppire_dict_view_get_type        (void);
+struct variable * psppire_dict_view_get_selected_variable (PsppireDictView *);
+
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DICT_VIEW_H__ */
index 2f9dbe06a890cbe5903ed74891b2574c1b702cea..d6ea3375257186d0566aa8a7706da717030db17c 100644 (file)
@@ -179,7 +179,7 @@ psppire_selector_class_init (PsppireSelectorClass *class)
     g_param_spec_enum ("orientation",
                       "Orientation",
                       "Where the selector is relative to its subjects",
-                      G_TYPE_PSPPIRE_SELECTOR_ORIENTATION,
+                      PSPPIRE_TYPE_SELECTOR_ORIENTATION,
                       PSPPIRE_SELECT_SOURCE_BEFORE_DEST /* default value */,
                       G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
 
index bdd358ebab30ebdb1dba610a9f58b0767dca1c1f..6fff5d4269da20286062e0f8c36def77374f1fa5 100644 (file)
@@ -130,7 +130,7 @@ typedef enum {
   PSPPIRE_SELECT_SOURCE_BELOW_DEST
 } PsppireSelectorOrientation;
 
-#define G_TYPE_PSPPIRE_SELECTOR_ORIENTATION \
+#define PSPPIRE_TYPE_SELECTOR_ORIENTATION \
   (psppire_selector_orientation_get_type())
 
 
index bffcfd1dd922bedf016d2e36c2b2d8d865a63a86..517a61e04b71924064ba4463aa695da111ff9e6b 100644 (file)
@@ -286,7 +286,6 @@ traverse_cell_callback (PsppireSheet *sheet,
 
 
 
-
 /*
    Callback whenever the active cell changes on the var sheet.
 */
@@ -296,7 +295,6 @@ var_sheet_change_active_cell (PsppireVarSheet *vs,
                              gint oldrow, gint oldcolumn,
                              gpointer data)
 {
-  PsppireSheetCellAttr attributes;
   PsppireVarStore *var_store;
   PsppireVarSheetClass *vs_class =
     PSPPIRE_VAR_SHEET_CLASS(G_OBJECT_GET_CLASS (vs));
@@ -313,8 +311,6 @@ var_sheet_change_active_cell (PsppireVarSheet *vs,
   g_return_if_fail (oldcolumn == PSPPIRE_VAR_STORE_COL_NAME ||
                    row < psppire_var_store_get_var_cnt (var_store));
 
-  psppire_sheet_get_attributes (sheet, row, column, &attributes);
-
   var = psppire_var_store_get_var (var_store, row);
 
   switch (column)
@@ -430,7 +426,8 @@ var_sheet_change_active_cell (PsppireVarSheet *vs,
     case PSPPIRE_VAR_STORE_COL_DECIMALS:
     case PSPPIRE_VAR_STORE_COL_COLUMNS:
       {
-       if ( attributes.is_editable)
+       if ( psppire_sheet_model_is_editable (PSPPIRE_SHEET_MODEL(var_store),
+                                             row, column))
          {
            gint r_min, r_max;
 
index b092de30939f6a76cb7d31eddf11faccd266ba13..8e78e2ec62218d3a339f346acbabee03fb25bb52 100644 (file)
@@ -191,7 +191,7 @@ psppire_var_store_class_init (PsppireVarStoreClass *class)
                              "Variable format type",
                              ("Whether variables have input or output "
                               "formats"),
-                             G_TYPE_PSPPIRE_VAR_STORE_FORMAT_TYPE,
+                             PSPPIRE_TYPE_VAR_STORE_FORMAT_TYPE,
                              PSPPIRE_VAR_STORE_OUTPUT_FORMATS,
                              G_PARAM_READWRITE);
 
index cf4375898f737fd782196c51cf7143cc8334b4d4..4cda0159bf0e776f4601f1e1b126b3ed211d11f2 100644 (file)
@@ -34,7 +34,7 @@ typedef enum
   }
 PsppireVarStoreFormatType;
 
-#define G_TYPE_PSPPIRE_VAR_STORE_FORMAT_TYPE \
+#define PSPPIRE_TYPE_VAR_STORE_FORMAT_TYPE \
         (psppire_var_store_format_type_get_type ())
 
 /* PSPPIRE variable store. */
index 473d530473894da5915f747c82e838707630b2bc..ad08cb2b13a3e30543582e02eb9ebe1349816791 100644 (file)
@@ -47,7 +47,7 @@
                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                 <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                 <child>
-                  <widget class="GtkTreeView" id="weight-cases-treeview">
+                  <widget class="PsppireDictView" id="weight-cases-treeview">
                     <property name="visible">True</property>
                     <property name="headers_visible">False</property>
                     <property name="fixed_height_mode">True</property>
                     <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
                     <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                     <child>
-                      <widget class="GtkTreeView" id="source-treeview">
+                      <widget class="PsppireDictView" id="source-treeview">
                         <property name="visible">True</property>
                         <property name="headers_visible">False</property>
                       </widget>
                         <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
                         <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                         <child>
-                          <widget class="GtkTreeView" id="split-file-dict-treeview">
+                          <widget class="PsppireDictView" id="split-file-dict-treeview">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                 <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                 <child>
-                  <widget class="GtkTreeView" id="sort-cases-treeview1">
+                  <widget class="PsppireDictView" id="sort-cases-treeview1">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                         <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                         <property name="shadow_type">GTK_SHADOW_IN</property>
                         <child>
-                          <widget class="GtkTreeView" id="compute-treeview1">
+                          <widget class="PsppireDictView" id="compute-treeview1">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                     <property name="shadow_type">GTK_SHADOW_IN</property>
                     <child>
-                      <widget class="GtkTreeView" id="select-cases-treeview">
+                      <widget class="PsppireDictView" id="select-cases-treeview">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
       </widget>
     </child>
   </widget>
-  <widget class="PsppireDialog" id="variable-info-dialog">
-    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-    <property name="title">Variables</property>
-    <property name="modal">True</property>
-    <child internal-child="hbox">
-      <widget class="GtkHBox" id="dialog-hbox6">
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="spacing">5</property>
-        <child>
-          <widget class="GtkScrolledWindow" id="scrolledwindow11">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
-            <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-            <property name="shadow_type">GTK_SHADOW_IN</property>
-            <child>
-              <widget class="GtkTreeView" id="treeview2">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="headers_visible">False</property>
-                <property name="reorderable">True</property>
-                <property name="fixed_height_mode">True</property>
-              </widget>
-            </child>
-          </widget>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">5</property>
-          </packing>
-        </child>
-        <child>
-          <widget class="GtkVBox" id="vbox23">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="spacing">5</property>
-            <child>
-              <widget class="GtkLabel" id="label24">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Variable Information:</property>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="padding">5</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkScrolledWindow" id="scrolledwindow12">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
-                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                <property name="shadow_type">GTK_SHADOW_IN</property>
-                <child>
-                  <widget class="GtkTextView" id="textview1">
-                    <property name="height_request">200</property>
-                    <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="editable">False</property>
-                    <property name="wrap_mode">GTK_WRAP_WORD_CHAR</property>
-                    <property name="left_margin">3</property>
-                    <property name="cursor_visible">False</property>
-                    <property name="accepts_tab">False</property>
-                  </widget>
-                </child>
-              </widget>
-              <packing>
-                <property name="padding">5</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="PsppireHButtonBox" id="psppire-hbuttonbox3">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="border_width">5</property>
-                <property name="homogeneous">True</property>
-                <property name="buttons">PSPPIRE_BUTTON_GOTO_MASK | PSPPIRE_BUTTON_CANCEL_MASK | PSPPIRE_BUTTON_HELP_MASK | PSPPIRE_BUTTON_PASTE_MASK</property>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="pack_type">GTK_PACK_END</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="padding">5</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </widget>
-    </child>
-  </widget>
   <widget class="PsppireDialog" id="select-cases-range-dialog">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     <property name="title">Select Cases: Range</property>
index 8ea25a1d9e8e5f9f93f39619ad39f37409bdce84..606475bac5d12bfdbe5701f878b4c0a1bb5f68f6 100644 (file)
@@ -306,10 +306,7 @@ rank_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (rd.dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (vars),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
-
+  g_object_set (vars, "model", vs->dict, NULL);
 
   set_dest_model (GTK_TREE_VIEW (rd.rank_vars), vs->dict);
 
index 6f65542f404d3388ce482f8dd3ceb30a46a03fc1..fd412dfeb5fcdad9a559f003bb8cbfc02b3b5c1a 100644 (file)
@@ -32,7 +32,7 @@
                     <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                     <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                     <child>
-                      <widget class="GtkTreeView" id="dict-treeview">
+                      <widget class="PsppireDictView" id="dict-treeview">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
index 859737f63e7d4d7895c1347f2a585c60d28cb5ab..e5de4597cb011b0dc67999d9342eef487850938b 100644 (file)
@@ -885,10 +885,7 @@ recode_dialog (PsppireDataWindow *de, gboolean diff)
   gtk_window_set_transient_for (GTK_WINDOW (rd.dialog), GTK_WINDOW (de));
 
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (rd.dict_treeview),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
-
+  g_object_set (rd.dict_treeview, "model", vs->dict, NULL);
 
   if ( ! rd.different )
     {
index a3b795e6960842c92ed8d5c126669332ad4eed70..6edcc0ab719f22c9ac753d72f89de85f3c3cc924 100644 (file)
             <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
             <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
             <child>
-              <widget class="GtkTreeView" id="treeview1">
+              <widget class="PsppireDictView" id="treeview1">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
index 2d8aca3ebc6a5d074e3a329211d25c530df83f2e..a860501805b391af6a5fbd35f684dfa55fc5aa10 100644 (file)
@@ -252,9 +252,7 @@ regression_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
+  g_object_set (source, "model", vs->dict, NULL);
 
   set_dest_model (GTK_TREE_VIEW (dest_dep), vs->dict);
   set_dest_model (GTK_TREE_VIEW (dest_indep), vs->dict);
index 3ee4973b32418352015bac1c68a801931d44c8f5..e6bac4d8e8979e4157743ec538c18d37e2334161 100644 (file)
@@ -95,7 +95,7 @@
                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                 <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                 <child>
-                  <widget class="GtkTreeView" id="dict-view">
+                  <widget class="PsppireDictView" id="dict-view">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
index e4d599edc8124480e2b51afb45ef1a25e44e7ca4..ca1b31bc0b2a4305acf5e30243b95db27162c49b 100644 (file)
@@ -21,8 +21,9 @@
 #include "helper.h"
 #include "psppire-dialog.h"
 #include "psppire-data-window.h"
-#include "dialog-common.h"
+#include "psppire-selector.h"
 #include "dict-display.h"
+#include "dialog-common.h"
 #include "widget-io.h"
 #include <language/syntax-string-source.h>
 #include "helper.h"
@@ -324,9 +325,10 @@ select_cases_dialog (GObject *o, gpointer data)
   {
     GtkWidget *source = get_widget_assert   (scd.xml, "select-cases-treeview");
 
-    attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                  scd.data_store->dict,
-                                  GTK_SELECTION_SINGLE, NULL);
+    g_object_set (source, "model",
+                 scd.data_store->dict,
+                 "selection-mode",
+                 GTK_SELECTION_SINGLE, NULL);
 
     psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector),
                                   source,
index d9c665e69a8db988df983919d7ea6d651cc9c9ea..9d4ea50bc95fcd8ff51c9f8acbf940b1918dd230 100644 (file)
@@ -22,6 +22,7 @@
 #include "psppire-data-window.h"
 #include "psppire-var-store.h"
 #include "dialog-common.h"
+#include "psppire-selector.h"
 #include "dict-display.h"
 
 #include <language/syntax-string-source.h>
@@ -110,9 +111,7 @@ sort_cases_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
+  g_object_set (source, "model", vs->dict, NULL);
 
   set_dest_model (GTK_TREE_VIEW (dest), vs->dict);
 
index 8708b33f05df2d5613cc0b514d4cf0150e055156..1641b50c2df701a08dbc9a0bb477e8634ad0eef3 100644 (file)
@@ -191,9 +191,8 @@ split_file_dialog (GObject *o, gpointer data)
   sfd.selector  = PSPPIRE_SELECTOR (
                                    get_widget_assert   (sfd.xml, "split-file-selector"));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
+  g_object_set (source, "model",
+                                vs->dict, NULL);
 
 
   g_signal_connect (on_off, "toggled", G_CALLBACK(on_off_toggled),  sfd.xml);
index 392867adbb606acd5c62abad6ce6a58286807f13..53b2c20c430291bf3792d65d30468bbaa89871d1 100644 (file)
@@ -426,9 +426,9 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (tt_d.dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view),
+  g_object_set (dict_view, "model", 
                                 vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
+                                NULL);
 
   set_dest_model (GTK_TREE_VIEW (test_variables_treeview), vs->dict);
 
index 3cdc91c32721f4780684f2966c5b896ecaae6ef3..64232d85754429e4117e8eb02228d54f83836407 100644 (file)
@@ -147,10 +147,10 @@ t_test_one_sample_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view),
+  g_object_set (dict_view, "model",
                                 vs->dict,
-                                GTK_SELECTION_MULTIPLE,
-                                var_is_numeric);
+       "predicate",
+                                var_is_numeric, NULL);
 
   set_dest_model (GTK_TREE_VIEW (tt_d.vars_treeview), vs->dict);
 
index ca1d776a7294f6bed0b91060e4be8f7878ef4b2c..5ac5d8aaa41f851ae9c8faef022dcb5624448cd6 100644 (file)
 #include <language/syntax-string-source.h>
 
 #include "psppire-data-window.h"
+#include "psppire-selector.h"
 
 #include "psppire-dict.h"
 #include "psppire-var-store.h"
 #include "t-test-paired-samples.h"
 #include "t-test-options.h"
 
-#include "dict-display.h"
 #include "dialog-common.h"
 #include "psppire-dialog.h"
 
@@ -205,10 +205,10 @@ t_test_paired_samples_dialog (GObject *o, gpointer data)
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view),
+  g_object_set (dict_view, "model",
                                 vs->dict,
-                                GTK_SELECTION_MULTIPLE,
-                                var_is_numeric);
+                                "predicate",
+                                var_is_numeric, NULL);
 
   {
     tt_d.list_store =
index e355daf442b655be6422835c2022ff7bcacb2070..040a99ea432721dd17e7e43354536b5adb3994c5 100644 (file)
@@ -26,7 +26,7 @@
                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                 <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                 <child>
-                  <widget class="GtkTreeView" id="indep-samples-t-test-treeview1">
+                  <widget class="PsppireDictView" id="indep-samples-t-test-treeview1">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
             <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
             <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
             <child>
-              <widget class="GtkTreeView" id="one-sample-t-test-treeview2">
+              <widget class="PsppireDictView" id="one-sample-t-test-treeview2">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                 <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
                 <child>
-                  <widget class="GtkTreeView" id="paired-samples-t-test-treeview1">
+                  <widget class="PsppireDictView" id="paired-samples-t-test-treeview1">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
index 09756d3738919bc40f2f314b3d4d924a7a287499..0e8a6259ddb365cfe13c53d35c068aa0fd69ebb6 100644 (file)
@@ -94,9 +94,7 @@ transpose_dialog (GObject *o, gpointer data)
 
   g_object_get (de->data_editor, "var-store", &vs, NULL);
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_MULTIPLE, NULL);
+  g_object_set (source, "model", vs->dict, NULL);
 
   set_dest_model (GTK_TREE_VIEW (dest), vs->dict);
 
index 2f5495f137dd5a41f0e889cc847a210f7bf4b3e7..9cafd9b80e5613b74d4b675881502fbea05cd414 100644 (file)
@@ -17,7 +17,6 @@
 #include <config.h>
 #include <gtk/gtk.h>
 
-#include "dict-display.h"
 #include "var-display.h"
 #include <data/variable.h>
 #include <data/format.h>
@@ -25,6 +24,7 @@
 #include "psppire-data-window.h"
 #include "psppire-dialog.h"
 #include "psppire-var-store.h"
+#include "psppire-dictview.h"
 #include "helper.h"
 
 #include <language/syntax-string-source.h>
 #define N_(msgid) msgid
 
 
-static struct variable *
-get_selected_variable (GtkTreeView *treeview)
-{
-  struct variable *var;
-  GtkTreeModel *top_model;
-  GtkTreeIter top_iter;
-
-  GtkTreeModel *model;
-  GtkTreeIter iter;
-
-  GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
-
-  if (! gtk_tree_selection_get_selected (selection,
-                                        &top_model, &top_iter))
-    {
-      return NULL;
-    }
-
-  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);
-
-  return var;
-}
-
-
 
 static void
-populate_text (GtkTreeView *treeview, gpointer data)
+populate_text (PsppireDictView *treeview, gpointer data)
 {
   gchar *text = 0;
   GString *gstring;
 
   GtkTextBuffer *textbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(data));
-  const struct variable *var = get_selected_variable (treeview);
+  const struct variable *var =
+    psppire_dict_view_get_selected_variable (treeview);
+
   if ( var == NULL)
     return;
 
@@ -157,7 +130,7 @@ treeview_item_selected (gpointer data)
 }
 
 
-static gchar * generate_syntax (GtkTreeView *treeview);
+static gchar * generate_syntax (PsppireDictView *treeview);
 
 
 void
@@ -167,7 +140,7 @@ variable_info_dialog (GObject *o, gpointer data)
 
   gint response ;
 
-  GtkBuilder *xml = builder_new ("psppire.ui");
+  GtkBuilder *xml = builder_new ("variable-info-dialog.ui");
 
   GtkWidget *dialog = get_widget_assert (xml, "variable-info-dialog");
   GtkWidget *treeview = get_widget_assert (xml, "treeview2");
@@ -179,11 +152,10 @@ variable_info_dialog (GObject *o, gpointer data)
 
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (treeview),
-                                vs->dict,
-                                GTK_SELECTION_SINGLE,
-                                NULL );
-
+  g_object_set (treeview,
+               "model", vs->dict,
+               "selection-mode", GTK_SELECTION_SINGLE,
+               NULL);
 
   g_signal_connect (treeview, "cursor-changed", G_CALLBACK (populate_text),
                    textview);
@@ -201,18 +173,20 @@ variable_info_dialog (GObject *o, gpointer data)
     case PSPPIRE_RESPONSE_GOTO:
       {
        const struct variable *var =
-         get_selected_variable (GTK_TREE_VIEW (treeview));
+         psppire_dict_view_get_selected_variable (PSPPIRE_DICT_VIEW (treeview));
 
        if ( NULL == var)
          goto done;
 
-       g_object_set (de->data_editor, "current-variable",  var_get_dict_index (var), NULL);
+       g_object_set (de->data_editor,
+                     "current-variable", var_get_dict_index (var),
+                     NULL);
       }
 
       break;
     case PSPPIRE_RESPONSE_PASTE:
       {
-       gchar *syntax = generate_syntax (GTK_TREE_VIEW (treeview));
+       gchar *syntax = generate_syntax (PSPPIRE_DICT_VIEW (treeview));
         paste_syntax_in_new_window (syntax);
 
        g_free (syntax);
@@ -227,9 +201,10 @@ variable_info_dialog (GObject *o, gpointer data)
 }
 
 static gchar *
-generate_syntax (GtkTreeView *treeview)
+generate_syntax (PsppireDictView *treeview)
 {
-  const struct variable *var = get_selected_variable (treeview);
+  const struct variable *var =
+    psppire_dict_view_get_selected_variable (treeview);
 
   if ( NULL == var)
     return g_strdup ("");
diff --git a/src/ui/gui/variable-info-dialog.glade b/src/ui/gui/variable-info-dialog.glade
new file mode 100644 (file)
index 0000000..1acb84e
--- /dev/null
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+  <requires lib="psppire"/>
+  <widget class="PsppireDialog" id="variable-info-dialog">
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="title">Variables</property>
+    <property name="modal">True</property>
+    <property name="slidable">True</property>
+    <child internal-child="hbox">
+      <widget class="GtkHPaned" id="dialog-hbox2">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <child>
+          <widget class="GtkScrolledWindow" id="scrolledwindow13">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+            <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+            <property name="shadow_type">GTK_SHADOW_IN</property>
+            <child>
+              <widget class="PsppireDictView" id="treeview2">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="headers_visible">False</property>
+                <property name="reorderable">True</property>
+                <property name="fixed_height_mode">True</property>
+              </widget>
+            </child>
+          </widget>
+          <packing>
+            <property name="resize">False</property>
+            <property name="shrink">True</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkVBox" id="vbox23">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="spacing">5</property>
+            <child>
+              <widget class="GtkLabel" id="label24">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Variable Information:</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">5</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkScrolledWindow" id="scrolledwindow14">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                <property name="shadow_type">GTK_SHADOW_IN</property>
+                <child>
+                  <widget class="GtkTextView" id="textview1">
+                    <property name="height_request">200</property>
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="editable">False</property>
+                    <property name="wrap_mode">GTK_WRAP_WORD_CHAR</property>
+                    <property name="left_margin">3</property>
+                    <property name="cursor_visible">False</property>
+                    <property name="accepts_tab">False</property>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="padding">5</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="PsppireHButtonBox" id="psppire-hbuttonbox4">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="border_width">5</property>
+                <property name="homogeneous">True</property>
+                <property name="buttons">PSPPIRE_BUTTON_GOTO_MASK | PSPPIRE_BUTTON_CANCEL_MASK | PSPPIRE_BUTTON_HELP_MASK | PSPPIRE_BUTTON_PASTE_MASK</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="pack_type">GTK_PACK_END</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="resize">True</property>
+            <property name="shrink">True</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>
index a464646fe7742eeacf0c0ece78467710c0ad5de8..8cfae24b74bded8b517a85784c3214bab3852d36 100644 (file)
@@ -130,11 +130,10 @@ weight_cases_dialog (GObject *o, gpointer data)
   g_signal_connect (selector, "de-selected", G_CALLBACK (on_deselect),
                    radiobutton1);
 
-  attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
-                                vs->dict,
-                                GTK_SELECTION_SINGLE,
-                                var_is_numeric
-                                );
+  g_object_set (source, "model", vs->dict,
+                                "selection-mode", GTK_SELECTION_SINGLE,
+                                "predicate", var_is_numeric,
+                                NULL);
 
   psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector),
                                 source,
index 843f1f3c414023eb4096f0e2e603e2661e84d9ff..979224fe4152331227d6597cf3259e08fb996cb5 100644 (file)
@@ -1,11 +1,15 @@
+#include <config.h>
+
 #include "widgets.h"
 
+
 #include "psppire-dialog.h"
 #include "psppire-selector.h"
 #include "psppire-vbuttonbox.h"
 #include "psppire-hbuttonbox.h"
 #include "psppire-keypad.h"
 #include "psppire-acr.h"
+#include "psppire-dictview.h"
 
 
 /* Any custom widgets which are to be used in GtkBuilder ui files
@@ -20,4 +24,5 @@ preregister_widgets (void)
   psppire_hbutton_box_get_type ();
   psppire_keypad_get_type ();
   psppire_acr_get_type ();
+  psppire_dict_view_get_type ();
 }