1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2007, 2009 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 This module provides a widget, PsppireSelector derived from
22 It contains a GtkArrow, and is used for selecting objects from a
23 GtkTreeView and putting them into a destination widget (often
24 another GtkTreeView). Typically this is used in psppire for
25 selecting variables, thus:
28 +----------------------------------------------------------+
30 | Source Widget Dest Widget |
31 | +----------------+ +----------------+ |
32 | | Variable0 | | Variable2 | |
47 | +----------------+ +----------------+ |
49 +----------------------------------------------------------+
51 The Source Widget is always a GtkTreeView. The Dest Widget may be a
52 GtkTreeView or a GtkEntry (other destination widgets may be
53 supported in the future).
55 Widgets may be source to more than one PsppireSelector.
61 #include "psppire-dictview.h"
62 #include "psppire-var-view.h"
66 #include <gtk/gtksignal.h>
67 #include <gtk/gtkbutton.h>
68 #include <gtk/gtkentry.h>
70 #include "psppire-selector.h"
72 #include <gtk/gtktreeview.h>
73 #include <gtk/gtktreeselection.h>
74 #include <gtk/gtktextview.h>
75 #include <gtk/gtkwidget.h>
77 static void psppire_selector_base_finalize (PsppireSelectorClass *, gpointer);
78 static void psppire_selector_base_init (PsppireSelectorClass *class);
79 static void psppire_selector_class_init (PsppireSelectorClass *class);
80 static void psppire_selector_init (PsppireSelector *selector);
83 static void set_direction (PsppireSelector *, enum psppire_selector_dir);
86 enum {SELECTED, /* Emitted when an item is inserted into dest */
87 DE_SELECTED, /* Emitted when an item is removed from dest */
90 static guint signals [n_SIGNALS];
94 psppire_selector_get_type (void)
96 static GType psppire_selector_type = 0;
98 if (!psppire_selector_type)
100 static const GTypeInfo psppire_selector_info =
102 sizeof (PsppireSelectorClass),
103 (GBaseInitFunc) psppire_selector_base_init,
104 (GBaseFinalizeFunc) psppire_selector_base_finalize,
105 (GClassInitFunc)psppire_selector_class_init,
106 (GClassFinalizeFunc) NULL,
108 sizeof (PsppireSelector),
110 (GInstanceInitFunc) psppire_selector_init,
113 psppire_selector_type =
114 g_type_register_static (GTK_TYPE_BUTTON, "PsppireSelector",
115 &psppire_selector_info, 0);
118 return psppire_selector_type;
121 static GObjectClass * parent_class = NULL;
124 psppire_selector_finalize (GObject *obj)
126 /* Chain up to the parent class */
127 G_OBJECT_CLASS (parent_class)->finalize (obj);
132 psppire_selector_dispose (GObject *obj)
134 PsppireSelector *sel = PSPPIRE_SELECTOR (obj);
136 if (sel->dispose_has_run)
139 /* Make sure dispose does not run twice. */
140 sel->dispose_has_run = TRUE;
142 g_object_unref (sel->dest);
143 g_object_unref (sel->source);
145 /* Chain up to the parent class */
146 G_OBJECT_CLASS (parent_class)->dispose (obj);
161 static void on_activate (PsppireSelector *selector, gpointer data);
163 static void update_subjects (PsppireSelector *selector);
167 psppire_selector_set_property (GObject *object,
172 PsppireSelector *selector = PSPPIRE_SELECTOR (object);
176 case PROP_ORIENTATION:
177 selector->orientation = g_value_get_enum (value);
178 set_direction (selector, selector->direction);
181 selector->primary_requested = TRUE;
182 update_subjects (selector);
184 case PROP_SOURCE_WIDGET:
185 selector->source = g_value_dup_object (value);
186 update_subjects (selector);
188 case PROP_DEST_WIDGET:
189 selector->dest = g_value_dup_object (value);
190 update_subjects (selector);
193 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
200 psppire_selector_get_property (GObject *object,
205 PsppireSelector *selector = PSPPIRE_SELECTOR (object);
209 case PROP_ORIENTATION:
210 g_value_set_enum (value, selector->orientation);
212 case PROP_SOURCE_WIDGET:
213 g_value_take_object (value, selector->source);
215 case PROP_DEST_WIDGET:
216 g_value_take_object (value, selector->dest);
219 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
225 psppire_selector_class_init (PsppireSelectorClass *class)
227 GObjectClass *object_class = G_OBJECT_CLASS (class);
228 GParamSpec *orientation_spec =
229 g_param_spec_enum ("orientation",
231 "Where the selector is relative to its subjects",
232 PSPPIRE_TYPE_SELECTOR_ORIENTATION,
233 PSPPIRE_SELECT_SOURCE_BEFORE_DEST /* default value */,
234 G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
237 /* Meaningfull only if more than one selector shares this selectors source */
238 GParamSpec *primary_spec =
239 g_param_spec_boolean ("primary",
241 "Whether this selector should be the primary selector for the source",
245 GParamSpec *source_widget_spec =
246 g_param_spec_object ("source-widget",
248 "The widget to be used as the source for this selector",
252 GParamSpec *dest_widget_spec =
253 g_param_spec_object ("dest-widget",
254 "Destination Widget",
255 "The widget to be used as the destination for this selector",
260 object_class->set_property = psppire_selector_set_property;
261 object_class->get_property = psppire_selector_get_property;
263 g_object_class_install_property (object_class,
267 g_object_class_install_property (object_class,
271 g_object_class_install_property (object_class,
275 g_object_class_install_property (object_class,
279 parent_class = g_type_class_peek_parent (class);
282 g_signal_new ("selected",
283 G_TYPE_FROM_CLASS (class),
287 g_cclosure_marshal_VOID__VOID,
291 signals [DE_SELECTED] =
292 g_signal_new ("de-selected",
293 G_TYPE_FROM_CLASS (class),
297 g_cclosure_marshal_VOID__VOID,
301 class->default_selection_funcs = g_hash_table_new (g_direct_hash, g_direct_equal);
306 psppire_selector_base_init (PsppireSelectorClass *class)
308 GObjectClass *object_class = G_OBJECT_CLASS (class);
310 object_class->finalize = psppire_selector_finalize;
311 object_class->dispose = psppire_selector_dispose;
313 class->source_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
319 psppire_selector_base_finalize(PsppireSelectorClass *class,
322 g_hash_table_destroy (class->source_hash);
323 g_hash_table_destroy (class->default_selection_funcs);
326 /* Callback for when the source treeview is activated (double clicked) */
328 on_row_activate (GtkTreeView *tree_view,
330 GtkTreeViewColumn *column,
333 PsppireSelector *selector = data;
335 gtk_action_activate (selector->action);
338 /* Callback for when the source selection changes */
340 on_source_select (GtkTreeSelection *treeselection, gpointer data)
342 PsppireSelector *selector = data;
344 set_direction (selector, PSPPIRE_SELECTOR_SOURCE_TO_DEST);
346 if ( selector->allow_selection )
348 gtk_action_set_sensitive (selector->action,
349 selector->allow_selection (selector->source, selector->dest));
351 else if ( GTK_IS_ENTRY (selector->dest) )
353 gtk_action_set_sensitive (selector->action,
354 gtk_tree_selection_count_selected_rows
355 (treeselection) <= 1 );
361 on_realize (PsppireSelector *selector)
363 PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
364 GtkTreeSelection* selection ;
366 GList *list = g_hash_table_lookup (class->source_hash, selector->source);
371 if ( g_list_first (list)->data == selector)
373 if ( selector->row_activate_id )
374 g_signal_handler_disconnect (selector->source, selector->row_activate_id);
376 selector->row_activate_id =
377 g_signal_connect (selector->source, "row-activated", G_CALLBACK (on_row_activate), selector);
380 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector->source));
382 if ( selector->source_select_id )
383 g_signal_handler_disconnect (selection, selector->source_select_id);
385 selector->source_select_id =
386 g_signal_connect (selection, "changed", G_CALLBACK (on_source_select), selector);
391 psppire_selector_init (PsppireSelector *selector)
393 selector->primary_requested = FALSE;
394 selector->select_user_data = NULL;
395 selector->select_items = NULL;
396 selector->allow_selection = NULL;
397 selector->filter = NULL;
399 selector->arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
400 selector->filtered_source = NULL;
402 selector->action = gtk_action_new ("select", NULL, NULL, "pspp-stock-select");
404 gtk_action_connect_proxy (selector->action, GTK_WIDGET (selector));
406 gtk_container_add (GTK_CONTAINER (selector), selector->arrow);
408 gtk_widget_show (selector->arrow);
410 g_signal_connect_swapped (selector->action, "activate", G_CALLBACK (on_activate), selector);
412 selector->selecting = FALSE;
414 selector->source = NULL;
415 selector->dest = NULL;
416 selector->dispose_has_run = FALSE;
419 selector->row_activate_id = 0;
420 selector->source_select_id = 0;
422 g_signal_connect (selector, "realize",
423 G_CALLBACK (on_realize), NULL);
429 psppire_selector_new (void)
431 return GTK_WIDGET (g_object_new (psppire_selector_get_type (), NULL));
436 set_direction (PsppireSelector *selector, enum psppire_selector_dir d)
438 selector->direction = d;
440 /* FIXME: Need to reverse the arrow direction if an RTL locale is in
442 if ( d == PSPPIRE_SELECTOR_SOURCE_TO_DEST )
444 switch (selector->orientation)
446 case PSPPIRE_SELECT_SOURCE_BEFORE_DEST:
447 g_object_set (selector->arrow, "arrow-type", GTK_ARROW_RIGHT, NULL);
449 case PSPPIRE_SELECT_SOURCE_AFTER_DEST:
450 g_object_set (selector->arrow, "arrow-type", GTK_ARROW_LEFT, NULL);
452 case PSPPIRE_SELECT_SOURCE_ABOVE_DEST:
453 g_object_set (selector->arrow, "arrow-type", GTK_ARROW_DOWN, NULL);
455 case PSPPIRE_SELECT_SOURCE_BELOW_DEST:
456 g_object_set (selector->arrow, "arrow-type", GTK_ARROW_UP, NULL);
459 g_assert_not_reached ();
465 switch (selector->orientation)
467 case PSPPIRE_SELECT_SOURCE_BEFORE_DEST:
468 g_object_set (selector->arrow, "arrow-type", GTK_ARROW_LEFT, NULL);
470 case PSPPIRE_SELECT_SOURCE_AFTER_DEST:
471 g_object_set (selector->arrow, "arrow-type", GTK_ARROW_RIGHT, NULL);
473 case PSPPIRE_SELECT_SOURCE_ABOVE_DEST:
474 g_object_set (selector->arrow, "arrow-type", GTK_ARROW_UP, NULL);
476 case PSPPIRE_SELECT_SOURCE_BELOW_DEST:
477 g_object_set (selector->arrow, "arrow-type", GTK_ARROW_DOWN, NULL);
480 g_assert_not_reached ();
487 /* Callback for when the destination treeview selection changes */
489 on_dest_treeview_select (GtkTreeSelection *treeselection, gpointer data)
491 PsppireSelector *selector = data;
493 gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (selector->source)));
495 set_direction (selector, PSPPIRE_SELECTOR_DEST_TO_SOURCE);
498 /* Callback for source deselection, when the dest is GtkEntry */
500 de_select_selection_entry (PsppireSelector *selector)
502 gtk_entry_set_text (GTK_ENTRY (selector->dest), "");
505 /* Callback for source deselection, when the dest is GtkTreeView */
507 de_select_selection_tree_view (PsppireSelector *selector)
511 GtkTreeSelection* selection =
512 gtk_tree_view_get_selection ( GTK_TREE_VIEW (selector->dest));
514 GtkTreeModel *model =
515 gtk_tree_view_get_model (GTK_TREE_VIEW (selector->dest));
517 GList *selected_rows =
518 gtk_tree_selection_get_selected_rows (selection, NULL);
520 g_return_if_fail (selector->select_items);
522 /* Convert paths to RowRefs */
523 for (item = g_list_first (selected_rows);
525 item = g_list_next (item))
527 GtkTreeRowReference* rowref;
528 GtkTreePath *path = item->data;
530 rowref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), path);
532 item->data = rowref ;
533 gtk_tree_path_free (path);
536 /* Remove each selected row from the dest widget */
537 for (item = g_list_first (selected_rows);
539 item = g_list_next (item))
542 GtkTreeRowReference *rr = item->data;
544 GtkTreePath *path = gtk_tree_row_reference_get_path (rr);
546 gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
548 gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
550 gtk_tree_path_free (path);
553 /* Delete list of RowRefs and its contents */
554 g_list_foreach (selected_rows, (GFunc) gtk_tree_row_reference_free, NULL);
555 g_list_free (selected_rows);
559 /* Removes something from the DEST widget */
561 de_select_selection (PsppireSelector *selector)
563 selector->selecting = TRUE;
565 if ( GTK_IS_TREE_VIEW (selector->dest ) )
566 de_select_selection_tree_view (selector);
568 else if ( GTK_IS_ENTRY (selector->dest))
569 de_select_selection_entry (selector);
572 g_assert_not_reached ();
574 selector->selecting = FALSE;
576 gtk_tree_model_filter_refilter (selector->filtered_source);
578 g_signal_emit (selector, signals [DE_SELECTED], 0);
582 /* Puts something into the DEST widget */
584 select_selection (PsppireSelector *selector)
587 GtkTreeSelection* selection =
588 gtk_tree_view_get_selection ( GTK_TREE_VIEW (selector->source));
590 GList *selected_rows =
591 gtk_tree_selection_get_selected_rows (selection, NULL);
593 GtkTreeModel *childmodel = gtk_tree_model_filter_get_model
594 (selector->filtered_source);
596 g_return_if_fail (selector->select_items);
598 selector->selecting = TRUE;
600 for (item = g_list_first (selected_rows);
602 item = g_list_next (item))
604 GtkTreeIter child_iter;
606 GtkTreePath *path = item->data;
608 gtk_tree_model_get_iter (GTK_TREE_MODEL (selector->filtered_source),
611 gtk_tree_model_filter_convert_iter_to_child_iter
612 (selector->filtered_source,
616 selector->select_items (child_iter,
619 selector->select_user_data
623 g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
624 g_list_free (selected_rows);
626 gtk_tree_model_filter_refilter (selector->filtered_source);
628 g_signal_emit (selector, signals [SELECTED], 0);
630 selector->selecting = FALSE;
633 /* Callback for when the selector button is clicked,
634 or other event which causes the selector's action to occur.
637 on_activate (PsppireSelector *selector, gpointer data)
639 switch (selector->direction)
641 case PSPPIRE_SELECTOR_SOURCE_TO_DEST:
642 select_selection (selector);
644 case PSPPIRE_SELECTOR_DEST_TO_SOURCE:
645 de_select_selection (selector);
648 g_assert_not_reached ();
654 permissive_filter (GtkTreeModel *model, GtkTreeIter *iter,
655 PsppireSelector *selector)
660 /* Default visibility filter for GtkTreeView DEST widget */
662 is_item_in_dest (GtkTreeModel *model, GtkTreeIter *iter,
663 PsppireSelector *selector)
665 GtkTreeModel *dest_model;
666 GtkTreeIter dest_iter;
667 GtkTreeIter source_iter;
670 GtkTreeModel *source_model;
672 if ( GTK_IS_TREE_MODEL_FILTER (model) )
674 source_model = gtk_tree_model_filter_get_model
675 (GTK_TREE_MODEL_FILTER (model));
677 gtk_tree_model_filter_convert_iter_to_child_iter
678 ( GTK_TREE_MODEL_FILTER (model), &source_iter, iter );
682 source_model = model;
686 dest_model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector->dest));
688 path = gtk_tree_model_get_path (source_model, &source_iter);
690 index = *gtk_tree_path_get_indices (path);
692 gtk_tree_path_free (path);
694 if ( ! gtk_tree_model_get_iter_first (dest_model, &dest_iter) )
701 GValue int_value = {0};
702 gtk_tree_model_get_value (dest_model, &dest_iter, 0, &value);
704 g_value_init (&int_value, G_TYPE_INT);
706 g_value_transform (&value, &int_value);
708 x = g_value_get_int (&int_value);
710 g_value_unset (&int_value);
711 g_value_unset (&value);
716 while (gtk_tree_model_iter_next (dest_model, &dest_iter));
721 /* Visibility function for items in the SOURCE widget.
722 Returns TRUE iff *all* the selectors for which SOURCE is associated
725 is_source_item_visible (GtkTreeModel *childmodel,
726 GtkTreeIter *iter, gpointer data)
728 PsppireSelector *selector = data;
729 PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
733 list = g_hash_table_lookup (class->source_hash, selector->source);
737 PsppireSelector *selector = list->data;
739 if ( selector->filter && selector->filter (childmodel, iter, selector))
749 /* set the source widget to SOURCE */
751 set_tree_view_source (PsppireSelector *selector,
757 PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
759 GtkTreeModel *model = gtk_tree_view_get_model (source);
761 if ( ! (list = g_hash_table_lookup (class->source_hash, source)))
763 selector->filtered_source =
764 GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (model, NULL));
766 gtk_tree_view_set_model (source,
767 GTK_TREE_MODEL (selector->filtered_source));
769 list = g_list_append (list, selector);
770 g_hash_table_insert (class->source_hash, source, list);
773 gtk_tree_model_filter_set_visible_func (selector->filtered_source,
774 is_source_item_visible,
779 { /* Append this selector to the list and push the <source,list>
780 pair onto the hash table */
782 selector->filtered_source = GTK_TREE_MODEL_FILTER (model);
784 if ( NULL == g_list_find (list, selector) )
786 if ( selector->primary_requested )
787 list = g_list_prepend (list, selector);
789 list = g_list_append (list, selector);
790 g_hash_table_replace (class->source_hash, source, list);
799 Callback for when the destination treeview's data changes
802 on_dest_data_change (GtkTreeModel *tree_model,
807 PsppireSelector *selector = user_data;
809 if ( selector->selecting) return;
811 gtk_tree_model_filter_refilter (selector->filtered_source);
816 on_dest_data_delete (GtkTreeModel *tree_model,
820 PsppireSelector *selector = user_data;
822 if ( selector->selecting ) return;
824 gtk_tree_model_filter_refilter (selector->filtered_source);
829 xxx (PsppireSelector *selector)
831 GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector->dest));
833 g_signal_connect (model, "row-changed", G_CALLBACK (on_dest_data_change),
836 g_signal_connect (model, "row-deleted", G_CALLBACK (on_dest_data_delete),
840 /* Set the destination widget to DEST */
842 set_tree_view_dest (PsppireSelector *selector,
845 GtkTreeSelection* selection = gtk_tree_view_get_selection (dest);
848 gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
850 g_signal_connect (selection, "changed", G_CALLBACK (on_dest_treeview_select),
854 g_signal_connect_swapped (dest, "notify::model",
855 G_CALLBACK (xxx), selector);
859 /* Callback which causes the filter to be refiltered.
860 Called when the DEST GtkEntry is activated (Enter is pressed), or when it
864 refilter (PsppireSelector *selector)
866 gtk_tree_model_filter_refilter (selector->filtered_source);
870 /* Callback for when the DEST GtkEntry is selected (clicked) */
872 on_entry_dest_select (GtkWidget *widget, GdkEventFocus *event, gpointer data)
874 PsppireSelector * selector = data;
876 gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (selector->source)));
877 set_direction (selector, PSPPIRE_SELECTOR_DEST_TO_SOURCE);
884 /* Callback for when an item disappears from the source list.
885 By implication, this means that the item has been inserted into the
889 on_row_deleted (PsppireSelector *selector)
891 g_signal_emit (selector, signals [SELECTED], 0);
894 /* Callback for when a new item appears in the source list.
895 By implication, this means that an item has been deleted from the
899 on_row_inserted (PsppireSelector *selector)
901 g_signal_emit (selector, signals [DE_SELECTED], 0);
906 /* Set DEST to be the destination GtkEntry widget */
908 set_entry_dest (PsppireSelector *selector,
911 g_signal_connect_swapped (dest, "activate", G_CALLBACK (refilter),
914 g_signal_connect_swapped (dest, "changed", G_CALLBACK (refilter),
917 g_signal_connect (dest, "focus-in-event", G_CALLBACK (on_entry_dest_select),
920 g_signal_connect_swapped (dest, "focus-out-event", G_CALLBACK (refilter),
924 g_signal_connect_swapped (selector->filtered_source, "row-deleted",
925 G_CALLBACK (on_row_deleted), selector);
927 g_signal_connect_swapped (selector->filtered_source, "row-inserted",
928 G_CALLBACK (on_row_inserted), selector);
932 set_default_filter (PsppireSelector *selector)
934 if ( selector->filter == NULL)
936 if (GTK_IS_TREE_VIEW (selector->dest))
937 selector->filter = permissive_filter;
942 update_subjects (PsppireSelector *selector)
944 GtkTreeModel *model = NULL;
946 if ( NULL == selector->dest )
949 set_default_filter (selector);
951 if ( NULL == selector->source )
954 g_signal_connect_swapped (selector->source, "notify::model",
955 G_CALLBACK (update_subjects), selector);
957 model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector->source));
963 if ( GTK_IS_TREE_VIEW (selector->source))
964 set_tree_view_source (selector, GTK_TREE_VIEW (selector->source) );
966 g_error ("Unsupported source widget: %s", G_OBJECT_TYPE_NAME (selector->source));
968 if ( NULL == selector->dest)
970 else if ( GTK_IS_TREE_VIEW (selector->dest))
972 set_tree_view_dest (selector, GTK_TREE_VIEW (selector->dest));
975 else if ( GTK_IS_ENTRY (selector->dest))
976 set_entry_dest (selector, GTK_ENTRY (selector->dest));
978 else if (GTK_IS_TEXT_VIEW (selector->dest))
980 /* Nothing to be done */
983 g_error ("Unsupported destination widget: %s", G_OBJECT_TYPE_NAME (selector->dest));
986 /* FIXME: Remove this dependency */
987 if ( PSPPIRE_IS_DICT_VIEW (selector->source) )
989 GObjectClass *class = G_OBJECT_GET_CLASS (selector);
990 GType type = G_OBJECT_TYPE (selector->dest);
992 SelectItemsFunc *func =
993 g_hash_table_lookup (PSPPIRE_SELECTOR_CLASS (class)->default_selection_funcs, (gpointer) type);
996 psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
1003 psppire_selector_set_default_selection_func (GType type, SelectItemsFunc *func)
1005 GObjectClass *class = g_type_class_ref (PSPPIRE_SELECTOR_TYPE);
1007 g_hash_table_insert (PSPPIRE_SELECTOR_CLASS (class)->default_selection_funcs, (gpointer) type, func);
1009 g_type_class_unref (class);
1015 /* Set FILTER_FUNC for this selector */
1017 psppire_selector_set_filter_func (PsppireSelector *selector,
1018 FilterItemsFunc *filter_func)
1020 selector->filter = filter_func ;
1022 set_default_filter (selector);
1026 /* Set SELECT_FUNC for this selector */
1028 psppire_selector_set_select_func (PsppireSelector *selector,
1029 SelectItemsFunc *select_func,
1032 selector->select_user_data = user_data;
1033 selector->select_items = select_func;
1039 psppire_selector_set_allow (PsppireSelector *selector, AllowSelectionFunc *allow)
1041 selector->allow_selection = allow;
1046 psppire_selector_orientation_get_type (void)
1048 static GType etype = 0;
1050 static const GEnumValue values[] = {
1051 { PSPPIRE_SELECT_SOURCE_BEFORE_DEST, "PSPPIRE_SELECT_SOURCE_BEFORE_DEST", "source before destination" },
1052 { PSPPIRE_SELECT_SOURCE_AFTER_DEST, "PSPPIRE_SELECT_SOURCE_AFTER_DEST", "source after destination" },
1053 { PSPPIRE_SELECT_SOURCE_ABOVE_DEST, "PSPPIRE_SELECT_SOURCE_ABOVE_DEST", "source above destination" },
1054 { PSPPIRE_SELECT_SOURCE_BELOW_DEST, "PSPPIRE_SELECT_SOURCE_BELOW_DEST", "source below destination" },
1057 etype = g_enum_register_static (g_intern_static_string ("PsppireSelectorOrientation"), values);