src/ui/gui/psppire-var-view.c \
src/ui/gui/psppire-var-view.h \
src/ui/gui/psppire-selector.h \
+ src/ui/gui/psppire-select-dest.c \
+ src/ui/gui/psppire-select-dest.h \
src/ui/gui/psppire-syntax-window.c \
src/ui/gui/psppire-syntax-window.h \
src/ui/gui/psppire-var-ptr.c \
--- /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 "psppire-select-dest.h"
+#include <gtk/gtkwidget.h>
+
+GType
+psppire_select_dest_widget_get_type (void)
+{
+ static GType dest_widget_type = 0;
+
+ if (! dest_widget_type)
+ {
+ const GTypeInfo dest_widget_info =
+ {
+ sizeof (PsppireSelectDestWidgetIface), /* class_size */
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ NULL,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ 0,
+ 0, /* n_preallocs */
+ NULL
+ };
+
+ dest_widget_type =
+ g_type_register_static (G_TYPE_INTERFACE, "PsppireSelectDestWidget",
+ &dest_widget_info, 0);
+
+ g_type_interface_add_prerequisite (dest_widget_type, GTK_TYPE_WIDGET);
+ }
+
+ return dest_widget_type;
+}
+
+
+gboolean
+psppire_select_dest_widget_contains_var (PsppireSelectDestWidget *sdm, const GValue *value)
+{
+ return PSPPIRE_SELECT_DEST_GET_IFACE (sdm)->contains_var (sdm, value);
+}
--- /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_SELECT_DEST_H__
+#define __PSPPIRE_SELECT_DEST_H__
+
+#include <glib-object.h>
+
+GType psppire_select_dest_widget_get_type (void) G_GNUC_CONST;
+
+#define PSPPIRE_TYPE_SELECT_DEST_WIDGET (psppire_select_dest_widget_get_type ())
+#define PSPPIRE_SELECT_DEST_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPPIRE_TYPE_SELECT_DEST_WIDGET, PsppireSelectDestWidget))
+#define PSPPIRE_IS_SELECT_DEST_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_SELECT_DEST_WIDGET))
+
+
+#define PSPPIRE_SELECT_DEST_GET_IFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PSPPIRE_TYPE_SELECT_DEST_WIDGET, PsppireSelectDestWidgetIface))
+
+typedef struct _PsppireSelectDestWidgetIface PsppireSelectDestWidgetIface;
+
+
+typedef struct _PsppireSelectDestWidget PsppireSelectDestWidget; /* Dummy typedef */
+
+struct _PsppireSelectDestWidgetIface
+{
+ GTypeInterface g_iface;
+
+ /* Return TRUE iff DEST contains V */
+ gboolean (*contains_var) (PsppireSelectDestWidget *dest, const GValue *v);
+};
+
+
+gboolean psppire_select_dest_widget_contains_var (PsppireSelectDestWidget *m, const GValue *v);
+
+#endif
#include "psppire-dictview.h"
#include "psppire-var-view.h"
-
-
+#include "psppire-dict.h"
+#include "psppire-select-dest.h"
#include <gtk/gtksignal.h>
#include <gtk/gtkbutton.h>
}
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,
- PsppireSelector *selector)
+is_item_in_dest (GtkTreeModel *model, GtkTreeIter *iter, PsppireSelector *selector)
{
- GtkTreeModel *dest_model;
- GtkTreeIter dest_iter;
+ gboolean result = FALSE;
GtkTreeIter source_iter;
- gint index;
- GtkTreePath *path ;
GtkTreeModel *source_model;
+ GValue value = {0};
- if ( GTK_IS_TREE_MODEL_FILTER (model) )
+ if (GTK_IS_TREE_MODEL_FILTER (model))
{
source_model = gtk_tree_model_filter_get_model
(GTK_TREE_MODEL_FILTER (model));
gtk_tree_model_filter_convert_iter_to_child_iter
- ( GTK_TREE_MODEL_FILTER (model), &source_iter, iter );
+ (GTK_TREE_MODEL_FILTER (model), &source_iter, iter);
}
else
{
source_iter = *iter;
}
- dest_model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector->dest));
-
- path = gtk_tree_model_get_path (source_model, &source_iter);
-
- index = *gtk_tree_path_get_indices (path);
-
- gtk_tree_path_free (path);
-
- if ( ! gtk_tree_model_get_iter_first (dest_model, &dest_iter) )
- return FALSE;
-
- do
- {
- int x;
- GValue value = {0};
- GValue int_value = {0};
- gtk_tree_model_get_value (dest_model, &dest_iter, 0, &value);
-
- g_value_init (&int_value, G_TYPE_INT);
+ gtk_tree_model_get_value (source_model, &source_iter, DICT_TVM_COL_VAR, &value);
- g_value_transform (&value, &int_value);
+ result = psppire_select_dest_widget_contains_var (PSPPIRE_SELECT_DEST_WIDGET (selector->dest),
+ &value);
- x = g_value_get_int (&int_value);
+ g_value_unset (&value);
- g_value_unset (&int_value);
- g_value_unset (&value);
+ return result;
+}
- if ( x == index )
- return TRUE;
- }
- while (gtk_tree_model_iter_next (dest_model, &dest_iter));
- return FALSE;
-}
/* Visibility function for items in the SOURCE widget.
Returns TRUE iff *all* the selectors for which SOURCE is associated
set_tree_view_source (PsppireSelector *selector,
GtkTreeView *source)
{
-
GList *list = NULL;
PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
g_hash_table_replace (class->source_hash, source, list);
}
}
-
-
}
static void
-xxx (PsppireSelector *selector)
+on_dest_model_changed (PsppireSelector *selector)
{
GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector->dest));
g_signal_connect (selection, "changed", G_CALLBACK (on_dest_treeview_select),
selector);
-
+ on_dest_model_changed (selector);
g_signal_connect_swapped (dest, "notify::model",
- G_CALLBACK (xxx), selector);
-
+ G_CALLBACK (on_dest_model_changed), selector);
}
+
/* Callback which causes the filter to be refiltered.
Called when the DEST GtkEntry is activated (Enter is pressed), or when it
looses focus.
return FALSE;
}
+
/* Callback for when the DEST GtkEntry is selected (clicked) */
static gboolean
on_entry_dest_select (GtkWidget *widget, GdkEventFocus *event, gpointer data)
}
-
/* Callback for when an item disappears from the source list.
By implication, this means that the item has been inserted into the
destination.
if ( selector->filter == NULL)
{
if (GTK_IS_TREE_VIEW (selector->dest))
- selector->filter = permissive_filter;
+ selector->filter = is_item_in_dest;
}
}
#include <gtk/gtkcellrenderertext.h>
#include "psppire-var-view.h"
#include "psppire-var-ptr.h"
+#include "psppire-select-dest.h"
#include <data/variable.h>
static void psppire_var_view_class_init (PsppireVarViewClass *class);
static void psppire_var_view_init (PsppireVarView *var_view);
+/* Returns TRUE iff VV contains the item V.
+ V must be an initialised value containing a
+ PSPPIRE_VAR_PTR_TYPE.
+*/
+static gboolean
+var_view_contains_var (PsppireSelectDestWidget *sdm, const GValue *v)
+{
+ gboolean ok;
+ GtkTreeIter iter;
+ PsppireVarView *vv = PSPPIRE_VAR_VIEW (sdm);
+ g_return_val_if_fail (G_VALUE_HOLDS (v, PSPPIRE_VAR_PTR_TYPE), FALSE);
+
+ for (ok = psppire_var_view_get_iter_first (vv, &iter);
+ ok;
+ ok = psppire_var_view_get_iter_next (vv, &iter))
+ {
+ const struct variable *var = psppire_var_view_get_variable (vv, 0, &iter);
+ if (var == g_value_get_boxed (v))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+model_init (PsppireSelectDestWidgetIface *iface)
+{
+ iface->contains_var = var_view_contains_var;
+}
GType
psppire_var_view_get_type (void)
(GInstanceInitFunc) psppire_var_view_init,
};
+ static const GInterfaceInfo var_view_model_info = {
+ (GInterfaceInitFunc) model_init, /* Fill this in */
+ NULL,
+ NULL
+ };
+
psppire_var_view_type =
g_type_register_static (GTK_TYPE_TREE_VIEW, "PsppireVarView",
&psppire_var_view_info, 0);
+
+ g_type_add_interface_static (psppire_var_view_type,
+ PSPPIRE_TYPE_SELECT_DEST_WIDGET,
+ &var_view_model_info);
}
return psppire_var_view_type;
return n_vars;
}
-
-/* Returns TRUE iff VV contains the item V.
- V must be an initialised value containing a
- PSPPIRE_VAR_PTR_TYPE.
-*/
-gboolean
-psppire_var_view_contains_var (PsppireVarView *vv, const GValue *v)
-{
- gboolean ok;
- GtkTreeIter iter;
- g_return_val_if_fail (G_VALUE_HOLDS (v, PSPPIRE_VAR_PTR_TYPE), FALSE);
-
- for (ok = psppire_var_view_get_iter_first (vv, &iter);
- ok;
- ok = psppire_var_view_get_iter_next (vv, &iter))
- {
- const struct variable *var = psppire_var_view_get_variable (vv, 0, &iter);
- if (var == g_value_get_boxed (v))
- return TRUE;
- }
-
- return FALSE;
-}
-
GtkListStore *list;
gint *nums;
-
};
struct _PsppireVarViewClass
GType psppire_var_view_get_type (void);
-gboolean psppire_var_view_contains_var (PsppireVarView *vv, const GValue *v);
-
gint psppire_var_view_append_names (PsppireVarView *vv, gint column, GString *string);
gboolean psppire_var_view_get_iter_first (PsppireVarView *vv, GtkTreeIter *iter);