};
}
-
-
static void
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);
}
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) */
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 )
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,
/* This is a hash of Lists of FilterItemsFunc pointers, keyed by address of
the source widget */
GHashTable *source_hash;
+
+ /* A hash of SelectItemFuncs indexed by GType */
+ GHashTable *default_selection_funcs;
};
GType psppire_selector_get_type (void);
(psppire_selector_orientation_get_type())
+void psppire_selector_set_default_selection_func (GType type, SelectItemsFunc *);
+
G_END_DECLS
#include <gtk/gtk.h>
#include "psppire-dict.h"
+#include "dict-display.h"
+#include "psppire-selector.h"
+#include "psppire-var-view.h"
#include "psppire-var-store.h"
#include "psppire-data-store.h"
#include "executor.h"
the_recent_mgr = gtk_recent_manager_get_default ();
+ psppire_selector_set_default_selection_func (GTK_TYPE_ENTRY, insert_source_row_into_entry);
+ psppire_selector_set_default_selection_func (PSPPIRE_VAR_VIEW_TYPE, insert_source_row_into_tree_view);
+ psppire_selector_set_default_selection_func (GTK_TYPE_TREE_VIEW, insert_source_row_into_tree_view);
+
the_data_window = psppire_data_window_new ();
command_line_processor_replace_aux (clp, &post_init_argp, the_source_stream);