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 \
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
<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"/>
--- /dev/null
+#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;
+}
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 \
#include "checkbox-treeview.h"
#include "crosstabs-dialog.h"
+#include "psppire-var-view.h"
#include <gtk/gtk.h>
#include <stdlib.h>
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=");
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");
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);
<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>
<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>
#include "checkbox-treeview.h"
#include "descriptives-dialog.h"
+#include "psppire-var-view.h"
#include <gtk/gtk.h>
#include <stdlib.h>
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);
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");
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);
<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>
#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);
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.
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 )
{
type = var_get_type (v);
}
-
return retval;
}
#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.
}
-
void
insert_source_row_into_entry (GtkTreeIter iter,
GtkWidget *dest,
}
-
void
insert_source_row_into_tree_view (GtkTreeIter iter,
GtkWidget *dest,
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)
gpointer data
);
-
/* A SelectItemsFunc function for GtkEntry widgets */
void insert_source_row_into_entry (GtkTreeIter source_iter,
GtkWidget *dest,
/* 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
#include <config.h>
#include "examine-dialog.h"
+#include "psppire-var-view.h"
#include <gtk/gtk.h>
#include <stdlib.h>
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));
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;
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),
<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>
"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);
<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>
#include "checkbox-treeview.h"
#include "frequencies-dialog.h"
+#include "psppire-var-view.h"
#include <gtk/gtk.h>
#include <stdlib.h>
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=");
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");
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");
<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>
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"
#include "psppire-selector.h"
#include "dict-display.h"
-
#include <language/syntax-string-source.h>
#include "executor.h"
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");
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);
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 ");
<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>
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>
{
PROP_0,
PROP_ORIENTATION,
+ PROP_PRIMARY,
PROP_SOURCE_WIDGET,
PROP_DEST_WIDGET
};
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);
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",
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);
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;
selector->row_activate_id = 0;
selector->source_select_id = 0;
+
+ g_signal_connect (selector, "realize",
+ G_CALLBACK (on_realize), NULL);
+
}
}
}
-/* 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)
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.
*/
}
}
+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,
set_tree_view_source (PsppireSelector *selector,
GtkTreeView *source)
{
- GtkTreeSelection* selection ;
+
GList *list = NULL;
PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
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);
}
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)
{
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;
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
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);
}
}
-
GType
psppire_selector_orientation_get_type (void)
{
gulong row_activate_id ;
gulong source_select_id ;
+
+ gboolean primary_requested;
};
struct _PsppireSelectorClass
--- /dev/null
+/* 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;
+}
+
+
+
--- /dev/null
+/* 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__ */
<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>
#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"
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)
{
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 = ");
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");
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);
<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>
#include "executor.h"
+#include "psppire-var-view.h"
+
#include <gtk/gtk.h>
#include <xalloc.h>
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;
G_TYPE_STRING);
-
gtk_tree_view_set_model (GTK_TREE_VIEW (rd.variable_treeview),
GTK_TREE_MODEL (rd.var_map));
NULL);
gtk_tree_view_column_set_cell_data_func (col, renderer,
- cell_var_name,
+ XXX_cell_var_name,
rd.dict, 0);
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 */
/* 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));
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);
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");
<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>
#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"
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;
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");
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);
<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>
#include "psppire-dialog.h"
#include "psppire-data-window.h"
+#include "psppire-var-view.h"
#include "executor.h"
#include "helper.h"
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");
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));
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=");
<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>
"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);
-
-
}
#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"
struct sort_cases_dialog
{
- GtkTreeView *tv;
+ PsppireVarView *tv;
PsppireDict *dict;
GtkToggleButton *ascending;
};
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);
{
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, "");
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);
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"));
<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>
#include "helper.h"
#include <data/dictionary.h>
+#include "psppire-var-view.h"
+
#include <gtk/gtk.h>
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 )
{
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));
#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"
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=");
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");
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);
#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"
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);
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);
"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);
#include "psppire-data-window.h"
#include "psppire-selector.h"
+#include "psppire-var-view.h"
#include "psppire-dict.h"
#include "psppire-var-store.h"
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");
}
}
-
+#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)
gtk_tree_view_column_add_attribute (col, renderer, "text", c);
}
+#endif
+
/* Pops up the dialog box */
void
"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,
<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>
#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"
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);
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);
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));
"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);
#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
psppire_keypad_get_type ();
psppire_acr_get_type ();
psppire_dict_view_get_type ();
+ psppire_var_view_get_type ();
}