New module psppire-var-view
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 23 Nov 2009 19:03:05 +0000 (20:03 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 23 Nov 2009 19:03:05 +0000 (20:03 +0100)
Added a new object PsppireVarView which is a subclass
of GtkTreeView.   It automatically creates a model for
itself for the storage of variables.

This change breaks some features.  These must be corrected
in subsequenct commits.

44 files changed:
glade/automake.mk
glade/psppire.xml
glade/var-view.c [new file with mode: 0644]
src/ui/gui/automake.mk
src/ui/gui/crosstabs-dialog.c
src/ui/gui/crosstabs.ui
src/ui/gui/descriptives-dialog.c
src/ui/gui/descriptives.ui
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/examine-dialog.c
src/ui/gui/examine.ui
src/ui/gui/find-dialog.c
src/ui/gui/find.ui
src/ui/gui/frequencies-dialog.c
src/ui/gui/frequencies.ui
src/ui/gui/oneway-anova-dialog.c
src/ui/gui/oneway.ui
src/ui/gui/psppire-selector.c
src/ui/gui/psppire-selector.h
src/ui/gui/psppire-var-view.c [new file with mode: 0644]
src/ui/gui/psppire-var-view.h [new file with mode: 0644]
src/ui/gui/psppire.ui
src/ui/gui/rank-dialog.c
src/ui/gui/rank.ui
src/ui/gui/recode-dialog.c
src/ui/gui/recode.ui
src/ui/gui/regression-dialog.c
src/ui/gui/regression.ui
src/ui/gui/reliability-dialog.c
src/ui/gui/reliability.ui
src/ui/gui/select-cases-dialog.c
src/ui/gui/sort-cases-dialog.c
src/ui/gui/sort.ui
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.ui
src/ui/gui/transpose-dialog.c
src/ui/gui/weight-cases-dialog.c
src/ui/gui/widgets.c

index 8e51e1f720244b9e96c4eca5233f5aadf29f11a1..1ef6b32c9d991d7e1974e3f12d15f2b45d0a1e97 100644 (file)
@@ -15,6 +15,9 @@ libglade_psppire_la_SOURCES = \
        glade/selector.c \
        glade/acr.c \
        glade/dictview.c \
+       glade/var-view.c \
+        src/ui/gui/psppire-var-ptr.c \
+       src/ui/gui/dict-display.c \
        src/ui/gui/psppire-conf.c \
        src/ui/gui/psppire-acr.c \
        src/ui/gui/psppire-buttonbox.c \
@@ -23,7 +26,8 @@ libglade_psppire_la_SOURCES = \
        src/ui/gui/psppire-dialog.c \
        src/ui/gui/psppire-keypad.c \
        src/ui/gui/psppire-dictview.c \
-       src/ui/gui/psppire-selector.c
+       src/ui/gui/psppire-selector.c \
+       src/ui/gui/psppire-var-view.c
 
 dist_catalog_DATA = \
        glade/psppire.xml
index 5673d6779bbb3a85029b88f5512e1af0ac8ce24a..db8956b70ac7880d179d1a706911c69c6552938b 100644 (file)
        <property id="source-widget"     ignore="True" />
        <property id="dest-widget"       ignore="True" />
        <property id="visible"           ignore="True" default="True" />
+       <property id="primary"           default="False" />
      </properties>
 
     </glade-widget-class>
       <property id="child"                disabled="True" />
       <property id="homogeneous"          disabled="True" />
       <property id="visible" ignore="True" default="True" />
+      <property id="model"                visible="False"  query="False" />
+    </properties>
+
+    </glade-widget-class>
+
+
+    <glade-widget-class name="PsppireVarView" generic-name="psppire-var-view" title="Variable Treeview">
+
+      <post-create-function>glade_psppire_var_view_post_create</post-create-function>
+      <get-children-function>glade_psppire_var_view_get_children</get-children-function>
+      <get-internal-child-function>glade_psppire_var_view_get_internal_child</get-internal-child-function>
+
+
+    <properties>
+      <property id="child"                disabled="True" />
+      <property id="homogeneous"          disabled="True" />
+      <property id="visible" ignore="True" default="True" />
+      <property id="model"                visible="False"  query="False" disabled="True" />
+      <property id="n-cols"    ignore="True" />
+
     </properties>
 
     </glade-widget-class>
 
 
   </glade-widget-classes>
+
  
 
  <glade-widget-group name="psppire" title="Psppire">
   <glade-widget-class-ref name="PsppireHButtonBox"/>
   <glade-widget-class-ref name="PsppireVButtonBox"/>
   <glade-widget-class-ref name="PsppireDictView"/>
+  <glade-widget-class-ref name="PsppireVarView"/>
   <glade-widget-class-ref name="PsppireSelector"/>
   <glade-widget-class-ref name="PsppireKeypad"/>
   <glade-widget-class-ref name="PsppireAcr"/>
diff --git a/glade/var-view.c b/glade/var-view.c
new file mode 100644 (file)
index 0000000..272f7db
--- /dev/null
@@ -0,0 +1,76 @@
+#include <config.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include "psppire-var-view.h"
+
+#include <gladeui/glade.h>
+
+
+
+
+void
+glade_psppire_var_view_post_create (GladeWidgetAdaptor *adaptor,
+                                   GObject            *object,
+                                   GladeCreateReason   reason)
+{
+  GladeWidget *widget ;
+
+  PsppireVarView *var_view = PSPPIRE_VAR_VIEW (object);
+
+  g_return_if_fail (PSPPIRE_IS_VAR_VIEW (var_view));
+
+  widget = glade_widget_get_from_gobject (GTK_WIDGET (var_view));
+  if (!widget)
+    return;
+
+  if (reason == GLADE_CREATE_USER)
+    {
+      /* HIG complient border-width defaults on var_views */
+      glade_widget_property_set (widget, "border-width", 5);
+    }
+}
+
+
+GtkWidget *
+glade_psppire_var_view_get_internal_child (GladeWidgetAdaptor  *adaptor,
+                                        PsppireVarView       *var_view,
+                                        const gchar         *name)
+{
+#if DEBUGGING
+  g_print ("%s\n", __FUNCTION__);
+#endif
+  return GTK_WIDGET (var_view);
+}
+
+
+
+void
+glade_psppire_var_view_set_property (GladeWidgetAdaptor *adaptor,
+                                    GObject            *object,
+                                    const gchar        *id,
+                                    const GValue       *value)
+{
+#if DEBUGGING
+  g_print ("%s(%p) Type=\"%s\" Id=\"%s\"\n", __FUNCTION__, object,
+          G_OBJECT_TYPE_NAME( object ),
+          id);
+#endif
+
+  GWA_GET_CLASS (GTK_TYPE_WINDOW)->set_property (adaptor, object,
+                                                id, value);
+}
+
+
+GList *
+glade_psppire_var_view_get_children (GladeWidgetAdaptor  *adaptor,
+                                    PsppireVarView  *dv)
+{
+  GList *list = NULL;
+
+  g_return_val_if_fail (PSPPIRE_IS_VAR_VIEW (dv), NULL);
+
+  list = glade_util_container_get_all_children (GTK_CONTAINER (dv));
+
+  return list;
+}
index aaaa05b6d70051545a8725999fcbe53903dd5965..f2f0b813b8c83cf9256f0dfcceb5df47c09a41e5 100644 (file)
@@ -163,6 +163,8 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/psppire-keypad.h \
        src/ui/gui/psppire-output-window.c \
        src/ui/gui/psppire-output-window.h \
+       src/ui/gui/psppire-var-view.c \
+       src/ui/gui/psppire-var-view.h \
        src/ui/gui/psppire-selector.h \
        src/ui/gui/psppire-syntax-window.c \
        src/ui/gui/psppire-syntax-window.h \
index 8198520d6b686222f518dc4664d32d7db007b28d..2b93a77b657afdfd2cdbb78657669c56ae11bb7b 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "checkbox-treeview.h"
 #include "crosstabs-dialog.h"
+#include "psppire-var-view.h"
 
 #include <gtk/gtk.h>
 #include <stdlib.h>
@@ -259,9 +260,9 @@ generate_syntax (const struct crosstabs_dialog *cd)
   GString *string = g_string_new ("CROSSTABS");
 
   g_string_append (string, "\n\t/TABLES=");
-  append_variable_names (string, cd->dict, GTK_TREE_VIEW (cd->row_vars), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (cd->row_vars), 0, string);
   g_string_append (string, "\tBY\t");
-  append_variable_names (string, cd->dict, GTK_TREE_VIEW (cd->col_vars), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (cd->col_vars), 0, string);
 
   g_string_append (string, "\n\t/FORMAT=");
 
@@ -398,8 +399,6 @@ crosstabs_dialog (GObject *o, gpointer data)
   GtkWidget *source = get_widget_assert   (xml, "dict-treeview");
   GtkWidget *dest_rows =   get_widget_assert   (xml, "rows");
   GtkWidget *dest_cols =   get_widget_assert   (xml, "cols");
-  GtkWidget *row_selector = get_widget_assert (xml, "row-selector");
-  GtkWidget *col_selector = get_widget_assert (xml, "col-selector");
   GtkWidget *format_button = get_widget_assert (xml, "format-button");
   GtkWidget *stat_button = get_widget_assert (xml, "stats-button");
   GtkWidget *cell_button = get_widget_assert (xml, "cell-button");
@@ -426,17 +425,6 @@ crosstabs_dialog (GObject *o, gpointer data)
   g_object_get (vs, "dictionary", &dict, NULL);
   g_object_set (source, "model", dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (dest_rows), dict);
-  set_dest_model (GTK_TREE_VIEW (dest_cols), dict);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (row_selector),
-                                   insert_source_row_into_tree_view,
-                                   NULL);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (col_selector),
-                                   insert_source_row_into_tree_view,
-                                   NULL);
-
   cd.row_vars = GTK_TREE_VIEW (dest_rows);
   cd.col_vars = GTK_TREE_VIEW (dest_cols);
   g_object_get (vs, "dictionary", &cd.dict, NULL);
index cb90d3cc7bf1759b57838b5f7c1fb9f28ad29f4b..e21ae808e102e1b6917be548718afec3a3408d4d 100644 (file)
@@ -34,7 +34,7 @@
                         <property name="vscrollbar_policy">automatic</property>
                         <property name="shadow_type">etched-in</property>
                         <child>
-                          <object class="GtkTreeView" id="rows">
+                          <object class="PsppireVarView" id="rows">
                             <property name="visible">True</property>
                             <property name="headers_visible">False</property>
                           </object>
@@ -73,7 +73,7 @@
                         <property name="vscrollbar_policy">automatic</property>
                         <property name="shadow_type">etched-in</property>
                         <child>
-                          <object class="GtkTreeView" id="cols">
+                          <object class="PsppireVarView" id="cols">
                             <property name="visible">True</property>
                             <property name="headers_visible">False</property>
                           </object>
index c29e1d8d66c14a8cda6f6b98f8efc3e3ed6e2370..9d8502de058b34b2cfa301338978ccc69267f4e2 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "checkbox-treeview.h"
 #include "descriptives-dialog.h"
+#include "psppire-var-view.h"
 
 #include <gtk/gtk.h>
 #include <stdlib.h>
@@ -117,7 +118,7 @@ generate_syntax (const struct descriptives_dialog *scd)
 
   string = g_string_new ("DESCRIPTIVES");
   g_string_append (string, "\n    /VARIABLES=");
-  append_variable_names (string, scd->dict, GTK_TREE_VIEW (scd->stat_vars), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (scd->stat_vars), 0, string);
 
   listwise = gtk_toggle_button_get_active (scd->exclude_missing_listwise);
   include = gtk_toggle_button_get_active (scd->include_user_missing);
@@ -212,7 +213,6 @@ descriptives_dialog (GObject *o, gpointer data)
 
 
   GtkWidget *source = get_widget_assert   (xml, "all-variables");
-  GtkWidget *selector = get_widget_assert (xml, "stat-var-selector");
   GtkWidget *dest =   get_widget_assert   (xml, "stat-variables");
 
   GtkWidget *stats_treeview = get_widget_assert    (xml, "statistics");
@@ -229,11 +229,6 @@ descriptives_dialog (GObject *o, gpointer data)
   g_object_set (source, "model", dict,
        "predicate", var_is_numeric, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (dest), dict);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                   insert_source_row_into_tree_view, NULL);
-
   put_checkbox_items_in_treeview (GTK_TREE_VIEW (stats_treeview),
                                  B_DS_DEFAULT,
                                  N_DESCRIPTIVE_STATS, stats);
index f43ed49566f566c9baa9c5ff854fdd8f5922122b..62e601f91d617fae16b5bdf768b7c23c4a909a8c 100644 (file)
@@ -99,7 +99,7 @@
                             <property name="vscrollbar_policy">automatic</property>
                             <property name="shadow_type">etched-in</property>
                             <child>
-                              <object class="GtkTreeView" id="stat-variables">
+                              <object class="PsppireVarView" id="stat-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 5d52204ce566ad89cdb1807adda7be338bf846e5..7edbbe504920a594e22bba139dba576f9e45b213 100644 (file)
 
 #include "helper.h"
 
-
-/* Append the names of selected variables to STRING.
-   TREEVIEW is the treeview containing the variables.
-   COLUMN is the column in the treeview containing the variables.
-   DICT is the dictionary for those variables.
+/* A (*GtkTreeCellDataFunc) function.
+   This function expects TREEMODEL to hold G_TYPE_BOXED, which is a pointer to a variable.
+   It renders the name of the variable into CELL.
 */
-gint
-append_variable_names (GString *string,
-                      PsppireDict *dict, GtkTreeView *treeview, gint column)
-{
-  gint n_vars = 0;
-  GtkTreeIter iter;
-
-  GtkTreeModel *list_store =
-    gtk_tree_view_get_model (treeview);
-
-  if ( gtk_tree_model_get_iter_first (list_store, &iter) )
-    {
-      do
-       {
-         GValue value = {0};
-         struct variable *var = NULL;
-         GtkTreePath *path = gtk_tree_model_get_path (list_store, &iter);
-
-         gtk_tree_model_get_value (list_store, &iter, column, &value);
-
-         /* FIXME:  G_TYPE_INT should be deprecated.
-            As well as being simpler, it'd be unecessary to pass dict */
-         if ( G_VALUE_TYPE (&value) == G_TYPE_INT )
-         var = psppire_dict_get_variable (dict, g_value_get_int (&value));
-
-         else if ( G_VALUE_TYPE (&value) == PSPPIRE_VAR_PTR_TYPE)
-           var = g_value_get_boxed (&value);
-
-         else
-           g_critical ("Unsupported type \"%s\", in variable name treeview.",
-                       G_VALUE_TYPE_NAME (&value));
-
-         g_value_unset (&value);
-
-         g_string_append (string, " ");
-         g_string_append (string, var_get_name (var));
-
-         gtk_tree_path_free (path);
-         n_vars++;
-       }
-      while (gtk_tree_model_iter_next (list_store, &iter));
-    }
-
-  return n_vars;
-}
-
-
-
-struct variable *
-get_selected_variable (GtkTreeModel *treemodel,
-                      GtkTreeIter *iter,
-                      PsppireDict *dict)
+void
+XXX_cell_var_name (GtkTreeViewColumn *tree_column,
+                  GtkCellRenderer *cell,
+                  GtkTreeModel *treemodel,
+                  GtkTreeIter *iter,
+                  gpointer data)
 {
-  struct variable *var;
+  const struct variable *var;
   GValue value = {0};
 
   GtkTreePath *path = gtk_tree_model_get_path (treemodel, iter);
@@ -91,67 +43,15 @@ get_selected_variable (GtkTreeModel *treemodel,
 
   gtk_tree_path_free (path);
 
-  var =  psppire_dict_get_variable (dict, g_value_get_int (&value));
+  var = g_value_get_boxed (&value);
 
   g_value_unset (&value);
 
-  return var;
-}
-
-
-
-
-/* A (*GtkTreeCellDataFunc) function.
-   This function expects TREEMODEL to hold G_TYPE_INT.  The ints it holds
-   are the indices of the variables in the dictionary, which DATA points to.
-   It renders the name of the variable into CELL.
-*/
-void
-cell_var_name (GtkTreeViewColumn *tree_column,
-              GtkCellRenderer *cell,
-              GtkTreeModel *tree_model,
-              GtkTreeIter *iter,
-              gpointer data)
-{
-  PsppireDict *dict = data;
-  const struct variable *var = get_selected_variable (tree_model, iter, dict);
-
   g_object_set (cell, "text", var_get_name (var), NULL);
 }
 
 
 
-/* Set a model for DEST, which is an GtkListStore of g_int's
-   whose values are the indices into DICT */
-void
-set_dest_model (GtkTreeView *dest, PsppireDict *dict)
-{
-  GtkTreeViewColumn *col;
-  GtkListStore *dest_list = gtk_list_store_new (1, G_TYPE_INT);
-  GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
-
-  gtk_tree_view_set_model (GTK_TREE_VIEW (dest), GTK_TREE_MODEL (dest_list));
-
-  col = gtk_tree_view_column_new_with_attributes ("Var",
-                                                 renderer,
-                                                 "text",
-                                                 0,
-                                                 NULL);
-
-  gtk_tree_view_column_set_cell_data_func (col, renderer,
-                                          cell_var_name,
-                                          dict, 0);
-
-  /* FIXME: make this a value in terms of character widths */
-  g_object_set (col, "min-width",  100, NULL);
-
-  gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
-
-  gtk_tree_view_append_column (GTK_TREE_VIEW (dest), col);
-}
-
-
-
 /* Returns FALSE if the variables represented by the union of the rows
    currently selected by SOURCE widget, and contents of the DEST
    widget, are of different types.
@@ -224,11 +124,8 @@ homogeneous_types (GtkWidget *source, GtkWidget *dest)
        ok;
        ok = gtk_tree_model_iter_next (model, &iter))
     {
-      gint idx;
       const struct variable *v;
-      gtk_tree_model_get (model, &iter, 0, &idx, -1);
-
-      v = psppire_dict_get_variable (dict, idx);
+      gtk_tree_model_get (model, &iter, 0, &v, -1);
 
       if ( type != -1 )
        {
@@ -242,7 +139,6 @@ homogeneous_types (GtkWidget *source, GtkWidget *dest)
       type = var_get_type (v);
     }
 
-
   return retval;
 }
 
index 9a003f35a20e84941b6ec83cc92870295ac38e0d..328904acfc9643fbf669cf6cd0f2f3451166d9c1 100644 (file)
 #include <gtk/gtk.h>
 #include "psppire-dict.h"
 
-/* Append the names of selected variables to STRING.
-   TREEVIEW is the treeview containing the variables.
-   COLUMN is column in treeview containing the variables.
-   DICT is the dictionary for those variables.
-*/
-gint append_variable_names (GString *string, PsppireDict *dict,
-                           GtkTreeView *treeview, gint column);
-
-
-/* Returns the variable currently selected by the iterator
-   pointing to TREEMODEL */
-struct variable * get_selected_variable (GtkTreeModel *treemodel,
-                                        GtkTreeIter *iter,
-                                        PsppireDict *dict);
-
-
-
 /* A (*GtkTreeCellDataFunc) function.
    This function expects TREEMODEL to hold G_TYPE_INT.  The ints it holds
    are the indices of the variables in the dictionary, which DATA points to.
    It renders the name of the variable into CELL.
 */
-void cell_var_name (GtkTreeViewColumn *tree_column,
+void XXX_cell_var_name (GtkTreeViewColumn *tree_column,
                    GtkCellRenderer *cell,
                    GtkTreeModel *tree_model,
                    GtkTreeIter *iter,
                    gpointer data);
 
 
-/* Set a model for DEST, which is an GtkListStore of g_int's
-   whose values are the indices into DICT */
-void set_dest_model (GtkTreeView *dest, PsppireDict *dict);
-
-
 /* Returns FALSE if the variables represented by the union of the rows
    currently selected by SOURCE widget, and contents of the DEST
    widget, are of different types.
index b06fcb4b53ab793281478560776c3dc5d8293dfc..160cdb2a1b8e635c4ad72a08892ca11edbddef9d 100644 (file)
@@ -54,7 +54,6 @@ get_base_model (GtkTreeModel *top_model, GtkTreeIter *top_iter,
 }
 
 
-
 void
 insert_source_row_into_entry (GtkTreeIter iter,
                              GtkWidget *dest,
@@ -84,7 +83,6 @@ insert_source_row_into_entry (GtkTreeIter iter,
 }
 
 
-
 void
 insert_source_row_into_tree_view (GtkTreeIter iter,
                                  GtkWidget *dest,
@@ -96,24 +94,28 @@ insert_source_row_into_tree_view (GtkTreeIter iter,
   GtkTreeIter dest_iter;
   GtkTreeIter dict_iter;
   gint *row ;
-  GtkTreeModel *destmodel = gtk_tree_view_get_model ( GTK_TREE_VIEW (dest));
+  GtkTreeModel *destmodel = gtk_tree_view_get_model (GTK_TREE_VIEW (dest));
 
+  const struct variable *var;
   GtkTreeModel *dict;
 
-
   get_base_model (model, &iter, &dict, &dict_iter);
 
   path = gtk_tree_model_get_path (dict, &dict_iter);
 
   row = gtk_tree_path_get_indices (path);
 
+  var = psppire_dict_get_variable (PSPPIRE_DICT (dict), *row);
+
   gtk_list_store_append (GTK_LIST_STORE (destmodel),  &dest_iter);
-  gtk_list_store_set (GTK_LIST_STORE (destmodel), &dest_iter, 0, *row, -1);
+
+  gtk_list_store_set (GTK_LIST_STORE (destmodel), &dest_iter, 0, var, -1);
 
   gtk_tree_path_free (path);
 }
 
 
+
 gboolean
 is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter,
                       PsppireSelector *selector)
index 2c8df4407655e7d48cd4aedca7bd880d3130227a..f1a8a0016f9aa2c9920cc9b6424f9b0c34b251ca 100644 (file)
@@ -31,7 +31,6 @@ void insert_source_row_into_tree_view (GtkTreeIter source_iter,
                                       gpointer data
                                       );
 
-
 /* A SelectItemsFunc function for GtkEntry widgets */
 void insert_source_row_into_entry (GtkTreeIter source_iter,
                                   GtkWidget *dest,
index 09b5f8b819182e2ae24450e24ebf8f2e9b89bb3c..67523143fc48ea09eedcae8c5acfe67f8979ce5a 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 2008  Free Software Foundation
+   Copyright (C) 2007, 2008, 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
@@ -17,6 +17,7 @@
 #include <config.h>
 
 #include "examine-dialog.h"
+#include "psppire-var-view.h"
 
 #include <gtk/gtk.h>
 #include <stdlib.h>
@@ -96,13 +97,13 @@ generate_syntax (const struct examine_dialog *ed)
   GString *str = g_string_new ("EXAMINE ");
 
   g_string_append (str, "\n\t/VARIABLES=");
-  append_variable_names (str, ed->dict, GTK_TREE_VIEW (ed->dep_list), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (ed->dep_list), 0, str);
 
   if ( 0  < gtk_tree_model_iter_n_children
        (gtk_tree_view_get_model (GTK_TREE_VIEW (ed->fct_list)), NULL))
     {
       g_string_append (str, "\n\tBY ");
-      append_variable_names (str, ed->dict, GTK_TREE_VIEW (ed->fct_list), 0);
+      psppire_var_view_append_names (PSPPIRE_VAR_VIEW (ed->fct_list), 0, str);
     }
 
   label = gtk_entry_get_text (GTK_ENTRY (ed->id_entry));
@@ -250,8 +251,6 @@ examine_dialog (GObject *o, gpointer data)
 
 
   GtkWidget *dep_selector = get_widget_assert (xml, "psppire-selector1");
-  GtkWidget *fct_selector = get_widget_assert (xml, "psppire-selector2");
-  GtkWidget *id_selector = get_widget_assert (xml, "psppire-selector3");
 
   PsppireVarStore *vs = NULL;
 
@@ -282,28 +281,9 @@ examine_dialog (GObject *o, gpointer data)
   g_object_get (vs, "dictionary", &ex_d.dict, NULL);
   g_object_set (source, "model", ex_d.dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (ex_d.dep_list), ex_d.dict);
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (dep_selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
   psppire_selector_set_allow (PSPPIRE_SELECTOR (dep_selector),
                              numeric_only);
 
-  set_dest_model (GTK_TREE_VIEW (ex_d.fct_list), ex_d.dict);
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (fct_selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (id_selector),
-                                insert_source_row_into_entry,
-                                NULL);
-
   g_signal_connect (dialog, "refresh", G_CALLBACK (refresh),  &ex_d);
 
   psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
index e2acfc3f2379bb1891648d4ffc955eb06b5c5ac3..316f10439b6c2891e729a4a91b5184a1a8c1ce84 100644 (file)
@@ -81,7 +81,7 @@
                             <property name="vscrollbar_policy">automatic</property>
                             <property name="shadow_type">etched-in</property>
                             <child>
-                              <object class="GtkTreeView" id="treeview3">
+                              <object class="PsppireVarView" id="treeview3">
                                 <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">automatic</property>
                             <property name="shadow_type">etched-in</property>
                             <child>
-                              <object class="GtkTreeView" id="treeview2">
+                              <object class="PsppireVarView" 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="receives_default">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="primary">True</property>
                     <property name="source_widget">treeview1</property>
                     <property name="dest_widget">treeview2</property>
                   </object>
index 07b73fe84c93d6cdb9e52f51c60a694f4ba0b0dd..40e91bc0179f1f801a8d22086725735f5810af48 100644 (file)
@@ -246,10 +246,6 @@ find_dialog (GObject *o, gpointer data)
        "selection-mode", GTK_SELECTION_SINGLE,
        NULL);
 
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                   insert_source_row_into_entry,
-                                   NULL
-                                   );
 
   psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector),
                                    is_currently_in_entry);
index 8dae0c99584dcdc2c54896460d3a460cf9abbad8..d1cb203c8020c041640d43885ed5ccd0e6d2a579 100644 (file)
@@ -52,6 +52,8 @@
                     <property name="receives_default">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="source_widget">find-variable-treeview</property>
+                    <property name="dest_widget">find-variable-entry</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
index 1d6a3a2a4b322e8931be6ee8219a90e891957ab8..2d5fcbb48d9f23485ab3b093c0bfe80fa273b80c 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "checkbox-treeview.h"
 #include "frequencies-dialog.h"
+#include "psppire-var-view.h"
 
 #include <gtk/gtk.h>
 #include <stdlib.h>
@@ -147,7 +148,7 @@ generate_syntax (const struct frequencies_dialog *fd)
   GString *string = g_string_new ("FREQUENCIES");
 
   g_string_append (string, "\n\t/VARIABLES=");
-  append_variable_names (string, fd->dict, GTK_TREE_VIEW (fd->stat_vars), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (fd->stat_vars), 0, string);
 
   g_string_append (string, "\n\t/FORMAT=");
 
@@ -316,7 +317,6 @@ frequencies_dialog (GObject *o, gpointer data)
   GtkWidget *dialog = get_widget_assert   (xml, "frequencies-dialog");
   GtkWidget *source = get_widget_assert   (xml, "dict-treeview");
   GtkWidget *dest =   get_widget_assert   (xml, "var-treeview");
-  GtkWidget *selector = get_widget_assert (xml, "selector1");
   GtkWidget *format_button = get_widget_assert (xml, "button1");
   GtkWidget *stats_treeview = get_widget_assert (xml, "stats-treeview");
 
@@ -336,15 +336,6 @@ frequencies_dialog (GObject *o, gpointer data)
   g_object_get (vs, "dictionary", &fd.dict, NULL);
   g_object_set (source, "model", fd.dict, NULL);
 
-
-  set_dest_model (GTK_TREE_VIEW (dest), fd.dict);
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
-
   fd.stat_vars = GTK_TREE_VIEW (dest);
   fd.table_button = get_widget_assert (xml, "checkbutton1");
   fd.format_dialog = get_widget_assert (xml, "format-dialog");
index 1a24657850edd6d76c061d0bd10d81ca8c3c6eab..0ab2f29f3d7140ab4789b66b0c5225dcdf99c7f1 100644 (file)
@@ -87,7 +87,7 @@
                             <property name="vscrollbar_policy">automatic</property>
                             <property name="shadow_type">etched-in</property>
                             <child>
-                              <object class="GtkTreeView" id="var-treeview">
+                              <object class="PsppireVarView" id="var-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 e1e3c5aeca6542b7cdc48b22cdca3d1113fc37a1..57428667a2480a63b5a2956ab7e1a927169594d8 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
 #include <config.h>
 #include <gtk/gtk.h>
 #include "oneway-anova-dialog.h"
 #include "psppire-dict.h"
 #include "psppire-var-store.h"
+#include "psppire-var-view.h"
 #include "helper.h"
 #include "psppire-data-window.h"
 #include "psppire-dialog.h"
@@ -29,7 +29,6 @@
 #include "psppire-selector.h"
 #include "dict-display.h"
 
-
 #include <language/syntax-string-source.h>
 #include "executor.h"
 
@@ -141,9 +140,6 @@ oneway_anova_dialog (GObject *o, gpointer data)
   GtkWidget *selector2 =
     get_widget_assert (builder, "oneway-anova-selector2");
 
-  GtkWidget *selector1 =
-    get_widget_assert (builder, "oneway-anova-selector1");
-
   GtkWidget *contrasts_button =
     get_widget_assert (builder, "contrasts-button");
 
@@ -173,18 +169,6 @@ oneway_anova_dialog (GObject *o, gpointer data)
 
   g_object_set (dict_view, "model", ow.dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (ow.vars_treeview), ow.dict);
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector1),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector2),
-                                insert_source_row_into_entry,
-                                NULL);
-
 
   psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector2),
                                    is_currently_in_entry);
@@ -264,7 +248,7 @@ static gchar * generate_syntax (const struct oneway_anova_dialog *ow)
 
   GString *str = g_string_new ("ONEWAY /VARIABLES=");
 
-  append_variable_names (str, ow->dict, GTK_TREE_VIEW (ow->vars_treeview), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (ow->vars_treeview), 0, str);
 
   g_string_append (str, " BY ");
 
index a0f7914543eefab02e4c1c694d4e4c4efac28462..7381932b04872682ae2ddb92f09ab6e19ecfaea3 100644 (file)
@@ -84,7 +84,7 @@
                     <property name="vscrollbar_policy">automatic</property>
                     <property name="shadow_type">etched-in</property>
                     <child>
-                      <object class="GtkTreeView" id="oneway-anova-treeview2">
+                      <object class="PsppireVarView" id="oneway-anova-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="receives_default">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="primary">True</property>
                 <property name="source_widget">oneway-anova-treeview1</property>
                 <property name="dest_widget">oneway-anova-treeview2</property>
               </object>
index d871d5d1511a69c894525be369e933ca85d6a2b6..367502b6ea219dca40b1aaeb07bb65a806996de4 100644 (file)
@@ -12,7 +12,8 @@
    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/>. */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
 
 /*
   This module provides a widget, PsppireSelector derived from
 
 #include <config.h>
 
+#include "psppire-dictview.h"
+#include "psppire-var-view.h"
+
+
+
 #include <gtk/gtksignal.h>
 #include <gtk/gtkbutton.h>
 #include <gtk/gtkentry.h>
@@ -146,6 +152,7 @@ enum
 {
   PROP_0,
   PROP_ORIENTATION,
+  PROP_PRIMARY,
   PROP_SOURCE_WIDGET,
   PROP_DEST_WIDGET
 };
@@ -170,6 +177,10 @@ psppire_selector_set_property (GObject         *object,
       selector->orientation = g_value_get_enum (value);
       set_direction (selector, selector->direction);
       break;
+    case PROP_PRIMARY:
+      selector->primary_requested = TRUE;
+      update_subjects (selector);
+      break;
     case PROP_SOURCE_WIDGET:
       selector->source = g_value_dup_object (value);
       update_subjects (selector);
@@ -224,6 +235,15 @@ psppire_selector_class_init (PsppireSelectorClass *class)
                       PSPPIRE_SELECT_SOURCE_BEFORE_DEST /* default value */,
                       G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
 
+
+ /* Meaningfull only if more than one selector shares this selectors source */
+  GParamSpec *primary_spec =
+    g_param_spec_boolean ("primary",
+                         "Primary",
+                         "Whether this selector should be the primary selector for the source",
+                         FALSE,
+                         G_PARAM_READWRITE);
+
   GParamSpec *source_widget_spec = 
     g_param_spec_object ("source-widget",
                         "Source Widget",
@@ -246,6 +266,10 @@ psppire_selector_class_init (PsppireSelectorClass *class)
                                    PROP_ORIENTATION,
                                    orientation_spec);
 
+  g_object_class_install_property (object_class,
+                                   PROP_PRIMARY,
+                                   primary_spec);
+
   g_object_class_install_property (object_class,
                                    PROP_SOURCE_WIDGET,
                                    source_widget_spec);
@@ -298,11 +322,71 @@ psppire_selector_base_finalize(PsppireSelectorClass *class,
   g_hash_table_destroy (class->source_hash);
 }
 
+/* Callback for when the source treeview is activated (double clicked) */
+static void
+on_row_activate (GtkTreeView       *tree_view,
+                GtkTreePath       *path,
+                GtkTreeViewColumn *column,
+                gpointer           data)
+{
+  PsppireSelector *selector  = data;
+
+  gtk_action_activate (selector->action);
+}
+
+/* Callback for when the source selection changes */
+static void
+on_source_select (GtkTreeSelection *treeselection, gpointer data)
+{
+  PsppireSelector *selector = data;
+
+  set_direction (selector, PSPPIRE_SELECTOR_SOURCE_TO_DEST);
+
+  if ( selector->allow_selection )
+    {
+      gtk_action_set_sensitive (selector->action,
+                               selector->allow_selection (selector->source, selector->dest));
+    }
+  else if ( GTK_IS_ENTRY (selector->dest) )
+    {
+      gtk_action_set_sensitive (selector->action,
+                               gtk_tree_selection_count_selected_rows
+                               (treeselection) <= 1 );
+    }
+}
+
+
+static void
+on_realize (PsppireSelector *selector)
+{
+  PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
+  GtkTreeSelection* selection ;
+
+  GList *list = g_hash_table_lookup (class->source_hash, selector->source);
+
+  if ( g_list_first (list)->data == selector)
+    {
+      if ( selector->row_activate_id )
+       g_signal_handler_disconnect (selector->source, selector->row_activate_id);
+
+      selector->row_activate_id =  
+       g_signal_connect (selector->source, "row-activated", G_CALLBACK (on_row_activate), selector);
+    }
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector->source));
+
+  if ( selector->source_select_id )
+    g_signal_handler_disconnect (selection, selector->source_select_id);
+
+  selector->source_select_id = 
+    g_signal_connect (selection, "changed", G_CALLBACK (on_source_select), selector);
+}
 
 
 static void
 psppire_selector_init (PsppireSelector *selector)
 {
+  selector->primary_requested = FALSE;
   selector->select_user_data = NULL;
   selector->select_items = NULL;
   selector->allow_selection = NULL;
@@ -330,6 +414,10 @@ psppire_selector_init (PsppireSelector *selector)
 
   selector->row_activate_id = 0;
   selector->source_select_id  = 0;
+
+  g_signal_connect (selector, "realize",
+                   G_CALLBACK (on_realize), NULL);
+
 }
 
 
@@ -392,27 +480,6 @@ set_direction (PsppireSelector *selector, enum psppire_selector_dir d)
     }
 }
 
-/* Callback for when the source selection changes */
-static void
-on_source_select (GtkTreeSelection *treeselection, gpointer data)
-{
-  PsppireSelector *selector = data;
-
-  set_direction (selector, PSPPIRE_SELECTOR_SOURCE_TO_DEST);
-
-  if ( selector->allow_selection )
-    {
-      gtk_action_set_sensitive (selector->action,
-                               selector->allow_selection (selector->source, selector->dest));
-    }
-  else if ( GTK_IS_ENTRY (selector->dest) )
-    {
-      gtk_action_set_sensitive (selector->action,
-                               gtk_tree_selection_count_selected_rows
-                               (treeselection) <= 1 );
-    }
-}
-
 /* Callback for when the destination treeview selection changes */
 static void
 on_dest_treeview_select (GtkTreeSelection *treeselection, gpointer data)
@@ -559,18 +626,6 @@ select_selection (PsppireSelector *selector)
   selector->selecting = FALSE;
 }
 
-/* Callback for when the source treeview is activated (double clicked) */
-static void
-on_row_activate (GtkTreeView       *tree_view,
-                GtkTreePath       *path,
-                GtkTreeViewColumn *column,
-                gpointer           data)
-{
-  PsppireSelector *selector  = data;
-
-  gtk_action_activate (selector->action);
-}
-
 /* Callback for when the selector button is clicked,
    or other event which causes the selector's action to occur.
  */
@@ -591,6 +646,13 @@ on_activate (PsppireSelector *selector, gpointer data)
     }
 }
 
+static gboolean
+permissive_filter (GtkTreeModel *model, GtkTreeIter *iter,
+                PsppireSelector *selector)
+{
+  return FALSE;
+}
+
 /* Default visibility filter for GtkTreeView DEST widget */
 static gboolean
 is_item_in_dest (GtkTreeModel *model, GtkTreeIter *iter,
@@ -685,7 +747,7 @@ static void
 set_tree_view_source (PsppireSelector *selector,
                      GtkTreeView *source)
 {
-  GtkTreeSelection* selection ;
+
   GList *list = NULL;
 
   PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
@@ -715,23 +777,17 @@ set_tree_view_source (PsppireSelector *selector,
 
       selector->filtered_source = GTK_TREE_MODEL_FILTER (model);
 
-      list = g_list_append (list, selector);
-      g_hash_table_replace (class->source_hash, source, list);
+      if ( NULL == g_list_find (list, selector) )
+       {
+         if ( selector->primary_requested )
+           list = g_list_prepend (list, selector);
+         else
+           list = g_list_append (list, selector);
+         g_hash_table_replace (class->source_hash, source, list);
+       }
     }
 
-  selection = gtk_tree_view_get_selection (source);
-
-  if ( selector->row_activate_id )
-    g_signal_handler_disconnect (source, selector->row_activate_id);
-
-  selector->row_activate_id =  
-    g_signal_connect (source, "row-activated", G_CALLBACK (on_row_activate), selector);
-
-  if ( selector->source_select_id )
-    g_signal_handler_disconnect (selection, selector->source_select_id);
 
-  selector->source_select_id = 
-    g_signal_connect (selection, "changed", G_CALLBACK (on_source_select), selector);
 }
 
 
@@ -868,6 +924,16 @@ set_entry_dest (PsppireSelector *selector,
                    G_CALLBACK (on_row_inserted), selector);
 }
 
+static void
+set_default_filter (PsppireSelector *selector)
+{
+  if ( selector->filter == NULL)
+    {
+      if  (GTK_IS_TREE_VIEW (selector->dest))
+       selector->filter = permissive_filter;
+    }
+}
+
 static void
 update_subjects (PsppireSelector *selector)
 {
@@ -876,11 +942,7 @@ update_subjects (PsppireSelector *selector)
   if ( NULL == selector->dest )
     return;
 
-  if ( selector->filter == NULL)
-    {
-      if  (GTK_IS_TREE_VIEW (selector->dest))
-       selector->filter = is_item_in_dest;
-    }
+  set_default_filter (selector);
 
   if ( NULL == selector->source )
     return;
@@ -916,8 +978,20 @@ update_subjects (PsppireSelector *selector)
   else
     g_error ("Unsupported destination widget: %s", G_OBJECT_TYPE_NAME (selector->dest));
 
-}
+  /* FIXME: Remove this dependency */
+  if ( PSPPIRE_IS_DICT_VIEW (selector->source) )
+    {
+      if ( PSPPIRE_IS_VAR_VIEW (selector->dest))
+       psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
+                                         insert_source_row_into_tree_view,
+                                         NULL);
+      else if (GTK_IS_ENTRY (selector->dest))
+       psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
+                                         insert_source_row_into_entry,
+                                         NULL);
+    }
 
+}
 
 /* Set FILTER_FUNC for this selector */
 void
@@ -925,12 +999,8 @@ psppire_selector_set_filter_func (PsppireSelector *selector,
                                  FilterItemsFunc *filter_func)
 {
   selector->filter = filter_func ;
-
-  if ( selector->filter == NULL)
-    {
-      if  (GTK_IS_TREE_VIEW (selector->dest))
-       selector->filter = is_item_in_dest;
-    }
+  
+  set_default_filter (selector);
 }
 
 
@@ -953,7 +1023,6 @@ psppire_selector_set_allow (PsppireSelector *selector, AllowSelectionFunc *allow
 }
 
 
-
 GType
 psppire_selector_orientation_get_type (void)
 {
index 8e033ae4bd0a67dad28474c21fea41f05d2564cc..c2d18424738c93aa01a47ab8be111fc824b90bb3 100644 (file)
@@ -104,6 +104,8 @@ struct _PsppireSelector
   gulong row_activate_id ;
 
   gulong source_select_id ;
+
+  gboolean primary_requested;
 };
 
 struct _PsppireSelectorClass
diff --git a/src/ui/gui/psppire-var-view.c b/src/ui/gui/psppire-var-view.c
new file mode 100644 (file)
index 0000000..da1cc8c
--- /dev/null
@@ -0,0 +1,280 @@
+/* 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 <gtk/gtkcellrenderertext.h>
+#include "psppire-var-view.h"
+#include "psppire-var-ptr.h"
+
+#include <data/variable.h>
+
+#include <gettext.h>
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+static void psppire_var_view_base_finalize (PsppireVarViewClass *, gpointer);
+static void psppire_var_view_base_init     (PsppireVarViewClass *class);
+static void psppire_var_view_class_init    (PsppireVarViewClass *class);
+static void psppire_var_view_init          (PsppireVarView      *var_view);
+
+
+GType
+psppire_var_view_get_type (void)
+{
+  static GType psppire_var_view_type = 0;
+
+  if (!psppire_var_view_type)
+    {
+      static const GTypeInfo psppire_var_view_info =
+      {
+       sizeof (PsppireVarViewClass),
+       (GBaseInitFunc) psppire_var_view_base_init,
+        (GBaseFinalizeFunc) psppire_var_view_base_finalize,
+       (GClassInitFunc)psppire_var_view_class_init,
+       (GClassFinalizeFunc) NULL,
+       NULL,
+        sizeof (PsppireVarView),
+       0,
+       (GInstanceInitFunc) psppire_var_view_init,
+      };
+
+      psppire_var_view_type =
+       g_type_register_static (GTK_TYPE_TREE_VIEW, "PsppireVarView",
+                               &psppire_var_view_info, 0);
+    }
+
+  return psppire_var_view_type;
+}
+
+
+static void
+psppire_var_view_finalize (GObject *object)
+{
+  PsppireVarView *var_view = PSPPIRE_VAR_VIEW (object);
+  g_free (var_view->nums);
+}
+
+/* Properties */
+enum
+{
+  PROP_0,
+  PROP_N_COLS
+};
+
+/* A (*GtkTreeCellDataFunc) function.
+   This function expects TREEMODEL to hold PSPPIRE_VAR_PTR_TYPE.
+   It renders the name of the variable into CELL.
+*/
+static void
+display_cell_var_name (GtkTreeViewColumn *tree_column,
+                      GtkCellRenderer *cell,
+                      GtkTreeModel *treemodel,
+                      GtkTreeIter *iter,
+                      gpointer data)
+{
+  struct variable *var;
+  GValue value = {0};
+  gint *col = data;
+
+  GtkTreePath *path = gtk_tree_model_get_path (treemodel, iter);
+
+  gtk_tree_model_get_value (treemodel, iter, *col, &value);
+
+  gtk_tree_path_free (path);
+
+  var = g_value_get_boxed (&value);
+
+  g_value_unset (&value);
+
+  g_object_set (cell, "text", var_get_name (var), NULL);
+}
+
+
+static void
+psppire_var_view_get_property (GObject         *object,
+                              guint            prop_id,
+                              GValue          *value,
+                              GParamSpec      *pspec)
+{
+  PsppireVarView *var_view = PSPPIRE_VAR_VIEW (object);
+
+  switch (prop_id)
+    {
+    case PROP_N_COLS:
+      g_value_set_int (value,  gtk_tree_model_iter_n_children (GTK_TREE_MODEL (var_view->list), NULL));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    };
+}
+
+
+static void
+psppire_var_view_set_property (GObject         *object,
+                              guint            prop_id,
+                              const GValue    *value,
+                              GParamSpec      *pspec)
+{
+  PsppireVarView *var_view = PSPPIRE_VAR_VIEW (object);
+
+  switch (prop_id)
+    {
+    case PROP_N_COLS:
+      {
+       gint n_cols = g_value_get_int (value);
+       gint c;
+
+
+       GType *array = g_alloca (sizeof (GType) *  n_cols);
+
+       var_view->nums = g_malloc (sizeof *var_view->nums * n_cols);
+
+       for (c = 0 ; c < n_cols; ++c)
+       {
+         GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
+         GtkTreeViewColumn *col = gtk_tree_view_column_new ();
+
+         gchar *label = g_strdup_printf (_("Var%d"), c + 1);
+
+         gtk_tree_view_column_set_min_width (col, 100);
+         gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_FIXED);
+         gtk_tree_view_column_set_resizable (col, TRUE);
+         gtk_tree_view_column_set_title (col, label);
+
+         g_free (label);
+
+         var_view->nums[c] = c;
+
+         gtk_tree_view_column_pack_start (col, renderer, TRUE);
+         gtk_tree_view_column_set_cell_data_func (col, renderer,
+                                                  display_cell_var_name,
+                                                  &var_view->nums[c], 0);
+
+         gtk_tree_view_append_column (GTK_TREE_VIEW (var_view), col);
+         array[c] = PSPPIRE_VAR_PTR_TYPE;
+       }
+
+       /* Set a model, which is an GtkListStore of gpointers which point to a variable */
+       var_view->list = gtk_list_store_newv  (n_cols, array);
+       gtk_tree_view_set_model (GTK_TREE_VIEW (var_view), GTK_TREE_MODEL (var_view->list));
+      }
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    };
+}
+
+static void
+psppire_var_view_class_init (PsppireVarViewClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  GParamSpec *n_cols_spec =
+    g_param_spec_int ("n-cols",
+                     "Number of columns",
+                     "The Number of Columns in the Variable View",
+                     1, 20,
+                     1,
+                     G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE | G_PARAM_WRITABLE);
+
+
+  object_class->set_property = psppire_var_view_set_property;
+  object_class->get_property = psppire_var_view_get_property;
+
+  g_object_class_install_property (object_class,
+                                   PROP_N_COLS,
+                                   n_cols_spec);
+
+}
+
+
+static void
+psppire_var_view_base_init (PsppireVarViewClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->finalize = psppire_var_view_finalize;
+}
+
+
+
+static void
+psppire_var_view_base_finalize (PsppireVarViewClass *class,
+                                gpointer class_data)
+{
+}
+
+
+
+static void
+psppire_var_view_init (PsppireVarView *var_view)
+{
+}
+
+
+GtkWidget*
+psppire_var_view_new (void)
+{
+  return GTK_WIDGET (g_object_new (psppire_var_view_get_type (), NULL));
+}
+
+
+/*
+  Append the names of selected variables to STRING.
+  Returns the number of variables appended.
+*/
+gint
+psppire_var_view_append_names (PsppireVarView *vv, gint column, GString *string)
+{
+  gint n_vars = 0;
+  GtkTreeIter iter;
+
+  if ( gtk_tree_model_get_iter_first (GTK_TREE_MODEL (vv->list), &iter) )
+    {
+      do
+       {
+         GValue value = {0};
+         struct variable *var = NULL;
+         GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (vv->list), &iter);
+
+         gtk_tree_model_get_value (GTK_TREE_MODEL (vv->list), &iter, column, &value);
+
+         if ( G_VALUE_TYPE (&value) == PSPPIRE_VAR_PTR_TYPE)
+           var = g_value_get_boxed (&value);
+         else
+           g_critical ("Unsupported type \"%s\", in variable name treeview.",
+                       G_VALUE_TYPE_NAME (&value));
+
+         g_value_unset (&value);
+
+         g_string_append (string, " ");
+         g_string_append (string, var_get_name (var));
+
+         gtk_tree_path_free (path);
+         n_vars++;
+       }
+      while (gtk_tree_model_iter_next (GTK_TREE_MODEL (vv->list), &iter));
+    }
+
+  return n_vars;
+}
+
+
+
diff --git a/src/ui/gui/psppire-var-view.h b/src/ui/gui/psppire-var-view.h
new file mode 100644 (file)
index 0000000..9563cce
--- /dev/null
@@ -0,0 +1,66 @@
+/* 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_VAR_VIEW_H__
+#define __PSPPIRE_VAR_VIEW_H__
+
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtktreeview.h>
+
+G_BEGIN_DECLS
+
+#define PSPPIRE_VAR_VIEW_TYPE            (psppire_var_view_get_type ())
+#define PSPPIRE_VAR_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPPIRE_VAR_VIEW_TYPE, PsppireVarView))
+#define PSPPIRE_VAR_VIEW_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), \
+    PSPPIRE_VAR_VIEW_TYPE, PsppireVarViewClass))
+#define PSPPIRE_IS_VAR_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+    PSPPIRE_VAR_VIEW_TYPE))
+#define PSPPIRE_IS_VAR_VIEW_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
+    PSPPIRE_VAR_VIEW_TYPE))
+
+
+typedef struct _PsppireVarView       PsppireVarView;
+typedef struct _PsppireVarViewClass  PsppireVarViewClass;
+
+
+
+struct _PsppireVarView
+{
+  GtkTreeView parent;
+
+  GtkListStore *list;
+  
+  gint *nums;
+
+};
+
+struct _PsppireVarViewClass
+{
+  GtkTreeViewClass parent_class;
+
+};
+
+GType      psppire_var_view_get_type        (void);
+
+gint psppire_var_view_append_names (PsppireVarView *vv, gint column, GString *string);
+
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_VAR_VIEW_H__ */
index 99d9ed06e0db861293070fcf5d6827f2071dce4d..06e72fb18445d2c3eeccb7b1cc6b8b733c1f40ba 100644 (file)
                             <property name="hscrollbar_policy">never</property>
                             <property name="vscrollbar_policy">automatic</property>
                             <child>
-                              <object class="GtkTreeView" id="variables-treeview">
+                              <object class="PsppireVarView" id="variables-treeview">
                                 <property name="visible">True</property>
                                 <property name="headers_visible">False</property>
                               </object>
                     <property name="can_focus">False</property>
                     <property name="receives_default">False</property>
                     <property name="border_width">5</property>
+                    <property name="primary">True</property>
                     <property name="source_widget">source-treeview</property>
                     <property name="dest_widget">variables-treeview</property>
                   </object>
                                     <property name="hscrollbar_policy">never</property>
                                     <property name="vscrollbar_policy">automatic</property>
                                     <child>
-                                      <object class="GtkTreeView" id="split-file-grouping-vars">
+                                      <object class="PsppireVarView" id="split-file-grouping-vars">
                                         <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 157f213609dc3ccc8d4f517a74649c00eba4df1b..aa81e23bbe71fd77fb2e5997f53c3bd93045643a 100644 (file)
@@ -28,6 +28,7 @@
 #include <ui/gui/helper.h>
 #include <ui/gui/psppire-dialog.h>
 #include <ui/gui/psppire-var-store.h>
+#include <ui/gui/psppire-var-view.h>
 #include "executor.h"
 
 #include "gettext.h"
@@ -110,7 +111,7 @@ generate_syntax (const struct rank_dialog *rd)
 
   GString *str = g_string_new ("RANK VARIABLES=");
 
-  append_variable_names (str, rd->dict, GTK_TREE_VIEW (rd->rank_vars), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->rank_vars), 0, str);
 
   g_string_append_printf (str, " (%c)",
                   gtk_toggle_button_get_active (rd->ascending_togglebutton)
@@ -120,7 +121,7 @@ generate_syntax (const struct rank_dialog *rd)
     {
       g_string_append (str, "\n\tBY ");
 
-      append_variable_names (str, rd->dict, GTK_TREE_VIEW (rd->group_vars), 0);
+      psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->group_vars),  0, str);
     }
 
   g_string_append (str, "\n\t/PRINT = ");
@@ -227,9 +228,6 @@ rank_dialog (GObject *o, gpointer data)
   GtkBuilder * builder = builder_new ("rank.ui");
 
   GtkWidget *vars = get_widget_assert   (builder, "dict-treeview");
-  GtkWidget *selector1 = get_widget_assert (builder, "psppire-selector1");
-  GtkWidget *selector2 = get_widget_assert (builder, "psppire-selector2");
-
 
   GtkWidget *types_button = get_widget_assert (builder, "button1");
   GtkWidget *ties_button = get_widget_assert (builder, "button2");
@@ -308,19 +306,6 @@ rank_dialog (GObject *o, gpointer data)
 
   g_object_set (vars, "model", rd.dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (rd.rank_vars), rd.dict);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector1),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
-  set_dest_model (GTK_TREE_VIEW (rd.group_vars), rd.dict);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector2),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
-
   g_signal_connect (types_button, "clicked",
                    G_CALLBACK (run_types_dialog),  &rd);
 
index 1b2a8245d5b5210e9a73cd6a8be14c38cd81c5d4..b05ab4501c7902a0cc84358805a174c4503a2558 100644 (file)
@@ -72,7 +72,7 @@
                         <property name="vscrollbar_policy">automatic</property>
                         <property name="shadow_type">etched-in</property>
                         <child>
-                          <object class="GtkTreeView" id="group-vars-treeview">
+                          <object class="PsppireVarView" id="group-vars-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">automatic</property>
                         <property name="shadow_type">etched-in</property>
                         <child>
-                          <object class="GtkTreeView" id="variables-treeview">
+                          <object class="PsppireVarView" id="variables-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="receives_default">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="primary">True</property>
                     <property name="source_widget">dict-treeview</property>
                     <property name="dest_widget">variables-treeview</property>
                   </object>
index 16a20cb1fd93f92ee3cb285ee85996c9852d88c9..2f0c332dbcea47cbbbbe7bc75b2dcc07b3fc2738 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "executor.h"
 
+#include "psppire-var-view.h"
+
 #include <gtk/gtk.h>
 
 #include <xalloc.h>
@@ -887,14 +889,9 @@ recode_dialog (PsppireDataWindow *de, gboolean diff)
 
   gtk_window_set_transient_for (GTK_WINDOW (rd.dialog), GTK_WINDOW (de));
 
-
   g_object_set (rd.dict_treeview, "model", rd.dict, NULL);
 
-  if ( ! rd.different )
-    {
-      set_dest_model (GTK_TREE_VIEW (rd.variable_treeview), rd.dict);
-    }
-  else
+  if (rd.different)
     {
       GtkTreeSelection *sel;
       GtkTreeViewColumn *col;
@@ -905,7 +902,6 @@ recode_dialog (PsppireDataWindow *de, gboolean diff)
                                                    G_TYPE_STRING);
 
 
-
       gtk_tree_view_set_model (GTK_TREE_VIEW (rd.variable_treeview),
                               GTK_TREE_MODEL (rd.var_map));
 
@@ -915,7 +911,7 @@ recode_dialog (PsppireDataWindow *de, gboolean diff)
                                                  NULL);
 
       gtk_tree_view_column_set_cell_data_func (col, renderer,
-                                              cell_var_name,
+                                              XXX_cell_var_name,
                                               rd.dict, 0);
 
 
@@ -949,12 +945,6 @@ recode_dialog (PsppireDataWindow *de, gboolean diff)
                        G_CALLBACK (select_something), &rd);
     }
 
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
   psppire_selector_set_allow (PSPPIRE_SELECTOR (selector), homogeneous_types);
 
   /* Set up the Old & New Values subdialog */
@@ -1273,7 +1263,6 @@ run_old_and_new_dialog (struct recode_dialog *rd)
     /* Find the type of the first variable (it's invariant that
        all variables are of the same type) */
     const struct variable *v;
-    gint idx;
     GtkTreeIter iter;
     GtkTreeModel *model =
       gtk_tree_view_get_model (GTK_TREE_VIEW (rd->variable_treeview));
@@ -1282,9 +1271,7 @@ run_old_and_new_dialog (struct recode_dialog *rd)
 
     g_return_if_fail (not_empty);
 
-    gtk_tree_model_get (model, &iter, 0, &idx, -1);
-
-    v = psppire_dict_get_variable (rd->dict, idx);
+    gtk_tree_model_get (model, &iter, 0, &v, -1);
 
     rd->input_var_is_string = var_is_alpha (v);
 
@@ -1439,7 +1426,7 @@ generate_syntax (const struct recode_dialog *rd)
 
   g_string_append (str, "\nRECODE ");
 
-  append_variable_names (str, rd->dict, GTK_TREE_VIEW (rd->variable_treeview), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->variable_treeview), 0, str);
 
   g_string_append (str, "\n\t");
 
index 711a4eafb631e337c55c35b42db03b420e2e1521..c573dba0607f7f85c45394330ede2946e0e7b283 100644 (file)
                         <property name="vscrollbar_policy">automatic</property>
                         <property name="shadow_type">etched-in</property>
                         <child>
-                          <object class="GtkTreeView" id="treeview2">
+                          <object class="PsppireVarView" 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>
index b52f0f7cd8e2dbc79334d767953ac395c24842d6..070d30a6e74bbfe59749eba9c86903e79f502827 100644 (file)
@@ -30,6 +30,7 @@
 #include <ui/gui/helper.h>
 #include <ui/gui/psppire-dialog.h>
 #include <ui/gui/psppire-var-store.h>
+#include <ui/gui/psppire-var-view.h>
 
 
 #include "gettext.h"
@@ -157,9 +158,9 @@ generate_syntax (const struct regression_dialog *rd)
   GString *string = g_string_new ("REGRESSION");
 
   g_string_append (string, "\n\t/VARIABLES=");
-  append_variable_names (string, rd->dict, GTK_TREE_VIEW (rd->indep_vars), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->indep_vars), 0, string);
   g_string_append (string, "\n\t/DEPENDENT=\t");
-  append_variable_names (string, rd->dict, GTK_TREE_VIEW (rd->dep_vars), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->dep_vars), 0, string);
 
   selected = 0;
   for (i = 0, ok = gtk_tree_model_get_iter_first (rd->stat, &iter); ok; 
@@ -234,8 +235,6 @@ regression_dialog (GObject *o, gpointer data)
   GtkWidget *source = get_widget_assert   (xml, "dict-view");
   GtkWidget *dest_dep =   get_widget_assert   (xml, "dep-view");
   GtkWidget *dest_indep =   get_widget_assert   (xml, "indep-view");
-  GtkWidget *dep_selector = get_widget_assert (xml, "dep-selector");
-  GtkWidget *indep_selector = get_widget_assert (xml, "indep-selector");
   GtkWidget *stat_button = get_widget_assert (xml, "stat-button");
   GtkWidget *save_button = get_widget_assert (xml, "save-button");
 
@@ -256,17 +255,6 @@ regression_dialog (GObject *o, gpointer data)
   g_object_get (vs, "dictionary", &rd.dict, NULL);
   g_object_set (source, "model", rd.dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (dest_dep), rd.dict);
-  set_dest_model (GTK_TREE_VIEW (dest_indep), rd.dict);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (dep_selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (indep_selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
   rd.dep_vars = GTK_TREE_VIEW (dest_dep);
   rd.indep_vars = GTK_TREE_VIEW (dest_indep);
 
index 437a1f6b088a7ad6bd6901e82f441417b69c920f..61561f354a19d28de3c306c0299323d39d742a73 100644 (file)
                         <property name="vscrollbar_policy">automatic</property>
                         <property name="shadow_type">etched-in</property>
                         <child>
-                          <object class="GtkTreeView" id="dep-view">
+                          <object class="PsppireVarView" id="dep-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>
                         <property name="vscrollbar_policy">automatic</property>
                         <property name="shadow_type">etched-in</property>
                         <child>
-                          <object class="GtkTreeView" id="indep-view">
+                          <object class="PsppireVarView" id="indep-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 3d661a5c50695a76929ba2191b809256e5cf80a6..9831ab7f66ce7ae20c974cdcdc1593b31a459763 100644 (file)
@@ -24,6 +24,7 @@
 #include "psppire-dialog.h"
 
 #include "psppire-data-window.h"
+#include "psppire-var-view.h"
 
 #include "executor.h"
 #include "helper.h"
@@ -121,8 +122,6 @@ reliability_dialog (GObject *o, gpointer data)
   GtkWidget *dialog = get_widget_assert   (xml, "reliability-dialog");
   GtkWidget *source = get_widget_assert   (xml, "dict-view");
 
-  GtkWidget *selector = get_widget_assert (xml, "psppire-selector1");
-
   rd.split_point_hbox = get_widget_assert (xml, "split-point-hbox");
 
   rd.variables = get_widget_assert   (xml, "treeview2");
@@ -140,12 +139,6 @@ reliability_dialog (GObject *o, gpointer data)
   g_object_get (vs, "dictionary", &rd.dict, NULL);
   g_object_set (source, "model", rd.dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (rd.variables), rd.dict);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
   {
     GtkTreeModel *tm =
       gtk_tree_view_get_model (GTK_TREE_VIEW (rd.variables));
@@ -203,7 +196,7 @@ generate_syntax (const struct reliability *rd)
   GString *string = g_string_new ("RELIABILITY");
 
   g_string_append (string, "\n\t/VARIABLES=");
-  append_variable_names (string, rd->dict, GTK_TREE_VIEW (rd->variables), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->variables), 0, string);
 
 
   g_string_append (string, "\n\t/MODEL=");
index 364ea89387c3694594923eb1750d209255066506..25af6ca1d63595111890f6461ad1da0b2b073a82 100644 (file)
@@ -98,7 +98,7 @@
                             <property name="vscrollbar_policy">automatic</property>
                             <property name="shadow_type">etched-in</property>
                             <child>
-                              <object class="GtkTreeView" id="treeview2">
+                              <object class="PsppireVarView" id="treeview2">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="headers_visible">False</property>
index 63061b1fa3a4b98cd1a2ab1ae92827c53d373497..5b027825bc6e62ccec66116837e7f085015a9dc7 100644 (file)
@@ -331,14 +331,8 @@ select_cases_dialog (GObject *o, gpointer data)
                  "selection-mode",
                  GTK_SELECTION_SINGLE, NULL);
 
-    psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                  insert_source_row_into_entry,
-                                  NULL);
-
     psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector),
                                   is_currently_in_entry);
-
-
   }
 
 
index 337aaf053ffba5620de4f6436b09a0f0b602d0a0..22c537812311eb232837062c384b5a91dc22db70 100644 (file)
@@ -24,6 +24,7 @@
 #include "dialog-common.h"
 #include "psppire-selector.h"
 #include "dict-display.h"
+#include "psppire-var-view.h"
 
 #include <language/syntax-string-source.h>
 #include "helper.h"
@@ -40,7 +41,7 @@ refresh (PsppireDialog *dialog, GtkTreeView *dest)
 
 struct sort_cases_dialog
 {
-  GtkTreeView *tv;
+  PsppireVarView *tv;
   PsppireDict *dict;
   GtkToggleButton *ascending;
 };
@@ -50,7 +51,7 @@ static gboolean
 dialog_state_valid (gpointer data)
 {
   struct sort_cases_dialog *scd = data;
-  GtkTreeModel *model = gtk_tree_view_get_model (scd->tv);
+  GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (scd->tv));
 
   gint n_rows = gtk_tree_model_iter_n_children  (model, NULL);
 
@@ -65,8 +66,8 @@ generate_syntax (const struct sort_cases_dialog *scd)
 {
   gchar *text;
   GString *string = g_string_new ("SORT CASES BY ");
-  gint n_vars = append_variable_names (string,
-                                      scd->dict, GTK_TREE_VIEW (scd->tv), 0);
+
+  gint n_vars = psppire_var_view_append_names (scd->tv, 0, string);
 
   if ( n_vars == 0 )
     g_string_assign (string, "");
@@ -102,9 +103,7 @@ sort_cases_dialog (GObject *o, gpointer data)
 
 
   GtkWidget *source = get_widget_assert   (xml, "sort-cases-treeview1");
-  GtkWidget *selector = get_widget_assert (xml, "sort-cases-selector");
   GtkWidget *dest =   get_widget_assert   (xml, "sort-cases-treeview2");
-
   PsppireVarStore *vs = NULL;
 
   g_object_get (de->data_editor, "var-store", &vs, NULL);
@@ -114,15 +113,9 @@ sort_cases_dialog (GObject *o, gpointer data)
   g_object_get (vs, "dictionary", &scd.dict, NULL);
   g_object_set (source, "model", scd.dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (dest), scd.dict);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
   g_signal_connect (dialog, "refresh", G_CALLBACK (refresh),  dest);
 
-  scd.tv = GTK_TREE_VIEW (dest);
+  scd.tv = PSPPIRE_VAR_VIEW (dest);
   scd.ascending =
     GTK_TOGGLE_BUTTON (get_widget_assert (xml, "sort-cases-radiobutton0"));
 
index b80affaf099bc1e9b76cc429f5d22fb18ad3b232..19f8b719fabd0361edc49b49a6a733f0b0489952 100644 (file)
@@ -92,7 +92,7 @@
                         <property name="vscrollbar_policy">automatic</property>
                         <property name="shadow_type">etched-in</property>
                         <child>
-                          <object class="GtkTreeView" id="sort-cases-treeview2">
+                          <object class="PsppireVarView" id="sort-cases-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>
index 3546f84450b7f0188fb19f9180d5950b90245047..cb226d9fffc095a1f23e7bf668efdca6015ac1bb 100644 (file)
@@ -26,6 +26,8 @@
 #include "helper.h"
 #include <data/dictionary.h>
 
+#include "psppire-var-view.h"
+
 #include <gtk/gtk.h>
 
 
@@ -68,8 +70,7 @@ generate_syntax (const struct split_file_dialog *sfd)
       GString * varlist = g_string_sized_new (80);
       GtkWidget *sort = get_widget_assert (sfd->xml, "split-radiobutton3");
       GtkWidget *layered = get_widget_assert (sfd->xml, "split-radiobutton1");
-      gint n_vars = append_variable_names (varlist,
-                                          sfd->dict, GTK_TREE_VIEW (vars), 0);
+      gint n_vars = psppire_var_view_append_names (PSPPIRE_VAR_VIEW (vars), 0, varlist);
 
       if ( n_vars > 0 )
        {
@@ -195,12 +196,6 @@ split_file_dialog (GObject *o, gpointer data)
 
   g_signal_connect (on_off, "toggled", G_CALLBACK(on_off_toggled),  sfd.xml);
 
-  set_dest_model (GTK_TREE_VIEW (dest), sfd.dict);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
   g_signal_connect (dialog, "refresh", G_CALLBACK (refresh),  &sfd);
 
   gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
index 473e04e02b2f86d09dd150862cff4baadb4e78dd..90c5ab54870b9439548d61ff0fc5efed2d4cedc9 100644 (file)
@@ -21,6 +21,7 @@
 #include "t-test-independent-samples-dialog.h"
 #include "psppire-dict.h"
 #include "psppire-var-store.h"
+#include "psppire-var-view.h"
 #include "executor.h"
 #include "psppire-data-window.h"
 #include "psppire-dialog.h"
@@ -160,7 +161,7 @@ generate_syntax (const struct tt_indep_samples_dialog *d)
 
   GString *str = g_string_new ("T-TEST /VARIABLES=");
 
-  append_variable_names (str, d->dict, GTK_TREE_VIEW (tv), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (tv), 0, str);
 
   g_string_append (str, "\n\t/GROUPS=");
 
@@ -400,9 +401,6 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
   GtkWidget *dict_view =
     get_widget_assert (xml, "indep-samples-t-test-treeview1");
 
-  GtkWidget *test_variables_treeview =
-    get_widget_assert (xml, "indep-samples-t-test-treeview2");
-
   GtkWidget *selector2 =
     get_widget_assert (xml, "indep-samples-t-test-selector2");
 
@@ -428,21 +426,10 @@ t_test_independent_samples_dialog (GObject *o, gpointer data)
 
   g_object_set (dict_view, "model", tt_d.dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (test_variables_treeview), tt_d.dict);
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector1),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
   psppire_selector_set_allow (PSPPIRE_SELECTOR (selector1),
                              numeric_only);
 
 
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector2),
-                                insert_source_row_into_entry,
-                                NULL);
-
   psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector2),
                                 is_currently_in_entry);
 
index 1161db5b8d28edc1fc08f672a605ed32894f336f..9301b2c316893566b5f891bf1f081d5e3de613e1 100644 (file)
@@ -21,6 +21,7 @@
 #include "t-test-one-sample.h"
 #include "psppire-dict.h"
 #include "psppire-var-store.h"
+#include "psppire-var-view.h"
 #include "helper.h"
 #include "psppire-data-window.h"
 #include "psppire-dialog.h"
@@ -58,7 +59,7 @@ generate_syntax (const struct tt_one_sample_dialog *d)
 
   g_string_append (str, "\n\t/VARIABLES=");
 
-  append_variable_names (str, d->dict, GTK_TREE_VIEW (d->vars_treeview), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (d->vars_treeview), 0, str);
 
   tt_options_dialog_append_syntax (d->opt, str);
 
@@ -135,8 +136,6 @@ t_test_one_sample_dialog (GObject *o, gpointer data)
   GtkWidget *options_button =
     get_widget_assert (xml, "button1");
 
-  GtkWidget *selector = get_widget_assert (xml, "psppire-selector1");
-
   GtkWidget *dialog = get_widget_assert (xml, "t-test-one-sample-dialog");
 
   g_object_get (de->data_editor, "var-store", &vs, NULL);
@@ -153,14 +152,6 @@ t_test_one_sample_dialog (GObject *o, gpointer data)
                "predicate",
                var_is_numeric, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (tt_d.vars_treeview), tt_d.dict);
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
-
   g_signal_connect_swapped (dialog, "refresh",
                            G_CALLBACK (refresh),  &tt_d);
 
index a021ce2c3897e19368a3b87468d3f4ce80c4479b..68b45fcb5a6a934378305a5bc30cbddd19b03c17 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "psppire-data-window.h"
 #include "psppire-selector.h"
+#include "psppire-var-view.h"
 
 #include "psppire-dict.h"
 #include "psppire-var-store.h"
@@ -56,11 +57,11 @@ generate_syntax (const struct tt_paired_samples_dialog *d)
   gchar *text = NULL;
   GString *str =   g_string_new ("T-TEST \n\tPAIRS = ");
 
-  append_variable_names (str, d->dict, GTK_TREE_VIEW (d->pairs_treeview), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (d->pairs_treeview), 0, str);
 
   g_string_append (str, " WITH ");
 
-  append_variable_names (str, d->dict, GTK_TREE_VIEW (d->pairs_treeview), 1);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (d->pairs_treeview), 1, str);
 
   g_string_append (str, " (PAIRED)");
   g_string_append (str, "\n");
@@ -151,7 +152,7 @@ select_as_pair_member (GtkTreeIter source_iter,
     }
 }
 
-
+#if 0
 /* Append a new column to TV at position C, and heading TITLE */
 static void
 add_new_column (GtkTreeView *tv, const gchar *title, gint c)
@@ -175,6 +176,8 @@ add_new_column (GtkTreeView *tv, const gchar *title, gint c)
   gtk_tree_view_column_add_attribute  (col, renderer, "text", c);
 }
 
+#endif
+
 
 /* Pops up the dialog box */
 void
@@ -211,22 +214,8 @@ t_test_paired_samples_dialog (GObject *o, gpointer data)
                "predicate",
                var_is_numeric, NULL);
 
-  {
-    tt_d.list_store =
-      GTK_TREE_MODEL (
-                     gtk_list_store_new (2,
-                                         PSPPIRE_VAR_PTR_TYPE,
-                                         PSPPIRE_VAR_PTR_TYPE));
-
-
-    gtk_tree_view_set_model (GTK_TREE_VIEW (tt_d.pairs_treeview),
-                            GTK_TREE_MODEL (tt_d.list_store));
-
-
-    add_new_column (GTK_TREE_VIEW (tt_d.pairs_treeview), _("Var 1"), 0);
-    add_new_column (GTK_TREE_VIEW (tt_d.pairs_treeview), _("Var 2"), 1);
-  }
-
+  
+  tt_d.list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (tt_d.pairs_treeview));
 
   psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
                                    select_as_pair_member,
index 48ac09401a714a992afc6470ef85d6b1b1051183..d8c2511315f2b265c33a97b30beba01681c61dfe 100644 (file)
                         <property name="vscrollbar_policy">automatic</property>
                         <property name="shadow_type">etched-in</property>
                         <child>
-                          <object class="GtkTreeView" id="indep-samples-t-test-treeview2">
+                          <object class="PsppireVarView" id="indep-samples-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">automatic</property>
                     <property name="shadow_type">etched-in</property>
                     <child>
-                      <object class="GtkTreeView" id="one-sample-t-test-treeview1">
+                      <object class="PsppireVarView" id="one-sample-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="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">never</property>
+                            <property name="hscrollbar_policy">always</property>
                             <property name="vscrollbar_policy">automatic</property>
                             <property name="shadow_type">etched-in</property>
                             <child>
-                              <object class="GtkTreeView" id="paired-samples-t-test-treeview2">
+                              <object class="PsppireVarView" id="paired-samples-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="enable_search">False</property>
+                                <property name="n-cols">2</property>
                               </object>
                             </child>
                           </object>
index 2bc7e7b38073d145b75c6b05c9a0f288a24b59b4..0061193e16b1b86f1d9dfa6c7c26d336e04cfb6b 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "transpose-dialog.h"
 #include "psppire-selector.h"
+#include "psppire-var-view.h"
 #include "psppire-dialog.h"
 #include "executor.h"
 #include "psppire-data-window.h"
@@ -88,8 +89,6 @@ transpose_dialog (GObject *o, gpointer data)
 
   GtkWidget *dialog = get_widget_assert (xml, "transpose-dialog");
   GtkWidget *source = get_widget_assert (xml, "source-treeview");
-  GtkWidget *dest = get_widget_assert (xml, "variables-treeview");
-  GtkWidget *selector1 = get_widget_assert (xml, "psppire-selector2");
   GtkWidget *selector2 = get_widget_assert (xml, "psppire-selector3");
 
   g_object_get (de->data_editor, "var-store", &vs, NULL);
@@ -97,17 +96,6 @@ transpose_dialog (GObject *o, gpointer data)
   g_object_get (vs, "dictionary", &dict, NULL);
   g_object_set (source, "model", dict, NULL);
 
-  set_dest_model (GTK_TREE_VIEW (dest), dict);
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector1),
-                                insert_source_row_into_tree_view,
-                                NULL);
-
-
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector2),
-                                insert_source_row_into_entry,
-                                NULL);
-
   psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector2),
                                 is_currently_in_entry);
 
@@ -164,7 +152,7 @@ generate_syntax (PsppireDict *dict, GtkBuilder *xml)
 
   g_string_append (string, " /VARIABLES = ");
 
-  append_variable_names (string, dict, GTK_TREE_VIEW (dest), 0);
+  psppire_var_view_append_names (PSPPIRE_VAR_VIEW (dest), 0, string);
 
   text = gtk_entry_get_text (GTK_ENTRY (entry));
 
index 1871f7aa9c40a417054c69e12bd4665440e7236b..40951360d70186658642ec2a99c701ed8e9e042c 100644 (file)
@@ -137,10 +137,6 @@ weight_cases_dialog (GObject *o, gpointer data)
                                 "predicate", var_is_numeric,
                                 NULL);
 
-  psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
-                                insert_source_row_into_entry,
-                                NULL);
-
   psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector),
                                    is_currently_in_entry);
 
index 979224fe4152331227d6597cf3259e08fb996cb5..a1a55d1453a3816bd1a3bdf68c7b0b833bf3bccc 100644 (file)
@@ -10,6 +10,7 @@
 #include "psppire-keypad.h"
 #include "psppire-acr.h"
 #include "psppire-dictview.h"
+#include "psppire-var-view.h"
 
 
 /* Any custom widgets which are to be used in GtkBuilder ui files
@@ -25,4 +26,5 @@ preregister_widgets (void)
   psppire_keypad_get_type ();
   psppire_acr_get_type ();
   psppire_dict_view_get_type ();
+  psppire_var_view_get_type ();
 }