diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ld-diagram.c | 31 | ||||
-rw-r--r-- | src/ld-diagram.h | 3 |
2 files changed, 30 insertions, 4 deletions
diff --git a/src/ld-diagram.c b/src/ld-diagram.c index 0d19e93..fb0255e 100644 --- a/src/ld-diagram.c +++ b/src/ld-diagram.c @@ -56,6 +56,7 @@ static void ld_diagram_finalize (GObject *gobject); static void ld_diagram_real_changed (LdDiagram *self); static void ld_diagram_clear_internal (LdDiagram *self); +static void ld_diagram_unselect_all_internal (LdDiagram *self); G_DEFINE_TYPE (LdDiagram, ld_diagram, G_TYPE_OBJECT); @@ -96,6 +97,18 @@ ld_diagram_class_init (LdDiagramClass *klass) G_STRUCT_OFFSET (LdDiagramClass, changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); +/** + * LdDiagram::selection-changed: + * @diagram: The diagram object. + * + * The current selection has changed. + */ + klass->selection_changed_signal = g_signal_new + ("selection-changed", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (LdDiagramClass, selection_changed), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_type_class_add_private (klass, sizeof (LdDiagramPrivate)); } @@ -426,7 +439,7 @@ ld_diagram_selection_add (LdDiagram *self, LdDiagramObject *object, gint pos) g_object_ref (object); g_signal_emit (self, - LD_DIAGRAM_GET_CLASS (self)->changed_signal, 0); + LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0); } } @@ -449,7 +462,7 @@ ld_diagram_selection_remove (LdDiagram *self, LdDiagramObject *object) g_object_unref (object); g_signal_emit (self, - LD_DIAGRAM_GET_CLASS (self)->changed_signal, 0); + LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0); } } @@ -464,10 +477,13 @@ ld_diagram_select_all (LdDiagram *self) { g_return_if_fail (LD_IS_DIAGRAM (self)); - ld_diagram_unselect_all (self); + ld_diagram_unselect_all_internal (self); self->priv->selection = g_slist_copy (self->priv->objects); g_slist_foreach (self->priv->selection, (GFunc) g_object_ref, NULL); + + g_signal_emit (self, + LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0); } /** @@ -481,6 +497,15 @@ ld_diagram_unselect_all (LdDiagram *self) { g_return_if_fail (LD_IS_DIAGRAM (self)); + ld_diagram_unselect_all_internal (self); + + g_signal_emit (self, + LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0); +} + +static void +ld_diagram_unselect_all_internal (LdDiagram *self) +{ g_slist_foreach (self->priv->selection, (GFunc) g_object_unref, NULL); g_slist_free (self->priv->selection); self->priv->selection = NULL; diff --git a/src/ld-diagram.h b/src/ld-diagram.h index 6a6120b..517a944 100644 --- a/src/ld-diagram.h +++ b/src/ld-diagram.h @@ -48,10 +48,11 @@ struct _LdDiagramClass /*< private >*/ GObjectClass parent_class; - /* FIXME: Add a selection_changed signal? */ guint changed_signal; + guint selection_changed_signal; void (*changed) (LdDiagram *self); + void (*selection_changed) (LdDiagram *self); }; |