X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-selector.c;h=2b2b2ed5ceeb9f23fe4dcca11fd6fd216c3b8832;hb=82cdb6b894ba84fad617196cdba815c9aa15605f;hp=367502b6ea219dca40b1aaeb07bb65a806996de4;hpb=ec1710dfedad294b9a32838abdbf0967d574aff8;p=pspp-builds.git diff --git a/src/ui/gui/psppire-selector.c b/src/ui/gui/psppire-selector.c index 367502b6..2b2b2ed5 100644 --- a/src/ui/gui/psppire-selector.c +++ b/src/ui/gui/psppire-selector.c @@ -221,8 +221,6 @@ psppire_selector_get_property (GObject *object, }; } - - static void psppire_selector_class_init (PsppireSelectorClass *class) { @@ -299,6 +297,8 @@ psppire_selector_class_init (PsppireSelectorClass *class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + class->default_selection_funcs = g_hash_table_new (g_direct_hash, g_direct_equal); } @@ -320,6 +320,7 @@ psppire_selector_base_finalize(PsppireSelectorClass *class, gpointer class_data) { g_hash_table_destroy (class->source_hash); + g_hash_table_destroy (class->default_selection_funcs); } /* Callback for when the source treeview is activated (double clicked) */ @@ -364,6 +365,9 @@ on_realize (PsppireSelector *selector) GList *list = g_hash_table_lookup (class->source_hash, selector->source); + if ( NULL == list) + return; + if ( g_list_first (list)->data == selector) { if ( selector->row_activate_id ) @@ -978,21 +982,36 @@ 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)) + GObjectClass *class = G_OBJECT_GET_CLASS (selector); + GType type = G_OBJECT_TYPE (selector->dest); + + SelectItemsFunc *func = + g_hash_table_lookup (PSPPIRE_SELECTOR_CLASS (class)->default_selection_funcs, (gpointer) type); + + if ( func ) psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector), - insert_source_row_into_entry, - NULL); + func, NULL); } +} + + +void +psppire_selector_set_default_selection_func (GType type, SelectItemsFunc *func) +{ + GObjectClass *class = g_type_class_ref (PSPPIRE_SELECTOR_TYPE); + g_hash_table_insert (PSPPIRE_SELECTOR_CLASS (class)->default_selection_funcs, (gpointer) type, func); + + g_type_class_unref (class); } + + + /* Set FILTER_FUNC for this selector */ void psppire_selector_set_filter_func (PsppireSelector *selector,