Add ld_diagram_{select,unselect}_all().

This commit is contained in:
Přemysl Eric Janouch 2011-01-05 04:28:24 +01:00
parent c4b8f092b7
commit e92bebfa57
2 changed files with 40 additions and 6 deletions

View File

@ -2,7 +2,7 @@
* ld-diagram.c * ld-diagram.c
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright Přemysl Janouch 2010. All rights reserved. * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -205,13 +205,11 @@ ld_diagram_clear (LdDiagram *self)
static void static void
ld_diagram_clear_internal (LdDiagram *self) ld_diagram_clear_internal (LdDiagram *self)
{ {
ld_diagram_unselect_all (self);
g_slist_free (self->priv->connections); g_slist_free (self->priv->connections);
self->priv->connections = NULL; self->priv->connections = NULL;
g_slist_foreach (self->priv->selection, (GFunc) g_object_unref, NULL);
g_slist_free (self->priv->selection);
self->priv->selection = NULL;
g_slist_foreach (self->priv->objects, (GFunc) g_object_unref, NULL); g_slist_foreach (self->priv->objects, (GFunc) g_object_unref, NULL);
g_slist_free (self->priv->objects); g_slist_free (self->priv->objects);
self->priv->objects = NULL; self->priv->objects = NULL;
@ -454,3 +452,36 @@ ld_diagram_selection_remove (LdDiagram *self, LdDiagramObject *object)
LD_DIAGRAM_GET_CLASS (self)->changed_signal, 0); LD_DIAGRAM_GET_CLASS (self)->changed_signal, 0);
} }
} }
/**
* ld_diagram_select_all:
* @self: An #LdDiagram object.
*
* Include all objects in the document to the selection.
*/
void
ld_diagram_select_all (LdDiagram *self)
{
g_return_if_fail (LD_IS_DIAGRAM (self));
ld_diagram_unselect_all (self);
self->priv->selection = g_slist_copy (self->priv->objects);
g_slist_foreach (self->priv->selection, (GFunc) g_object_ref, NULL);
}
/**
* ld_diagram_unselect_all:
* @self: An #LdDiagram object.
*
* Remove all objects from the current selection.
*/
void
ld_diagram_unselect_all (LdDiagram *self)
{
g_return_if_fail (LD_IS_DIAGRAM (self));
g_slist_foreach (self->priv->selection, (GFunc) g_object_unref, NULL);
g_slist_free (self->priv->selection);
self->priv->selection = NULL;
}

View File

@ -2,7 +2,7 @@
* ld-diagram.h * ld-diagram.h
* *
* This file is a part of logdiag. * This file is a part of logdiag.
* Copyright Přemysl Janouch 2010. All rights reserved. * Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
* *
* See the file LICENSE for licensing information. * See the file LICENSE for licensing information.
* *
@ -79,6 +79,9 @@ void ld_diagram_selection_add (LdDiagram *self,
void ld_diagram_selection_remove (LdDiagram *self, void ld_diagram_selection_remove (LdDiagram *self,
LdDiagramObject *object); LdDiagramObject *object);
void ld_diagram_select_all (LdDiagram *self);
void ld_diagram_unselect_all (LdDiagram *self);
/* /*
GSList *ld_diagram_get_connections (LdDiagram *self); GSList *ld_diagram_get_connections (LdDiagram *self);
void ld_diagram_connection_add (LdDiagram *self, void ld_diagram_connection_add (LdDiagram *self,