+static void
+psppire_selector_dispose (GObject *obj)
+{
+ PsppireSelector *sel = PSPPIRE_SELECTOR (obj);
+ PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
+ GList *list;
+
+ if (sel->dispose_has_run)
+ return;
+
+ /* Make sure dispose does not run twice. */
+ sel->dispose_has_run = TRUE;
+
+ /* Remove ourself from the source map. If we are the only entry for this source
+ widget, that will result in an empty list for the source. In that case, we
+ remove the entire entry too. */
+ if ((list = g_hash_table_lookup (class->source_hash, sel->source)))
+ {
+ GList *newlist = g_list_remove_link (list, sel->source_litem);
+ g_list_free (sel->source_litem);
+ if (newlist == NULL)
+ g_hash_table_remove (class->source_hash, sel->source);
+ else
+ g_hash_table_replace (class->source_hash, sel->source, newlist);
+
+ sel->source_litem = NULL;
+ }
+
+ g_object_unref (sel->dest);
+ g_object_unref (sel->source);
+
+ /* Chain up to the parent class */
+ G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+
+/* Properties */
+enum
+{
+ PROP_0,
+ PROP_ORIENTATION,
+ PROP_PRIMARY,
+ PROP_SOURCE_WIDGET,
+ PROP_DEST_WIDGET
+};
+
+
+static void on_click (GtkButton *b);
+static void on_realize (GtkWidget *selector);
+
+
+static void update_subjects (PsppireSelector *selector);
+
+
+static void
+psppire_selector_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ PsppireSelector *selector = PSPPIRE_SELECTOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_ORIENTATION:
+ 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);
+ break;
+ case PROP_DEST_WIDGET:
+ selector->dest = g_value_dup_object (value);
+ update_subjects (selector);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ };
+}
+
+
+static void
+psppire_selector_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ PsppireSelector *selector = PSPPIRE_SELECTOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_ORIENTATION:
+ g_value_set_enum (value, selector->orientation);
+ break;
+ case PROP_SOURCE_WIDGET:
+ g_value_take_object (value, selector->source);
+ break;
+ case PROP_DEST_WIDGET:
+ g_value_take_object (value, selector->dest);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ };
+}
+