From 046308c5821bd8448cbaa0aea79f21574b5ef81d Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 20 Dec 2010 19:06:54 +0100 Subject: [PATCH] StBoxLayout: add insert_before Add st_container_move_before internal API, and st_box_layout_insert_before, that inserts an actor before another in the container. https://bugzilla.gnome.org/show_bug.cgi?id=637681 --- src/st/st-box-layout.c | 11 +++++++++++ src/st/st-box-layout.h | 4 ++++ src/st/st-container.c | 23 +++++++++++++++++++++++ src/st/st-container.h | 3 +++ 4 files changed, 41 insertions(+) diff --git a/src/st/st-box-layout.c b/src/st/st-box-layout.c index ae26cd76d..0aa5ef2e8 100644 --- a/src/st/st-box-layout.c +++ b/src/st/st-box-layout.c @@ -1213,3 +1213,14 @@ st_box_layout_insert_actor (StBoxLayout *self, clutter_container_add_actor((ClutterContainer*) self, actor); st_container_move_child (ST_CONTAINER (self), actor, pos); } + +void +st_box_layout_insert_before (StBoxLayout *self, + ClutterActor *actor, + ClutterActor *sibling) +{ + g_return_if_fail (ST_IS_BOX_LAYOUT (self)); + + clutter_container_add_actor(CLUTTER_CONTAINER (self), actor); + st_container_move_before (ST_CONTAINER (self), actor, sibling); +} diff --git a/src/st/st-box-layout.h b/src/st/st-box-layout.h index 54372d53c..f19a065d0 100644 --- a/src/st/st-box-layout.h +++ b/src/st/st-box-layout.h @@ -90,6 +90,10 @@ void st_box_layout_insert_actor (StBoxLayout *self, ClutterActor *actor, int pos); +void st_box_layout_insert_before (StBoxLayout *self, + ClutterActor *actor, + ClutterActor *sibling); + G_END_DECLS #endif /* _ST_BOX_LAYOUT_H */ diff --git a/src/st/st-container.c b/src/st/st-container.c index 4d140a16a..0fb5eb462 100644 --- a/src/st/st-container.c +++ b/src/st/st-container.c @@ -159,6 +159,29 @@ st_container_move_child (StContainer *container, clutter_actor_queue_relayout ((ClutterActor*) container); } +void +st_container_move_before (StContainer *container, + ClutterActor *actor, + ClutterActor *sibling) +{ + StContainerPrivate *priv = container->priv; + GList *actor_item = NULL; + GList *sibling_item = NULL; + + actor_item = g_list_find (priv->children, actor); + sibling_item = g_list_find (priv->children, sibling); + + g_return_if_fail (actor_item != NULL); + g_return_if_fail (sibling_item != NULL); + + priv->children = g_list_delete_link (priv->children, actor_item); + priv->children = g_list_insert_before (priv->children, sibling_item, actor); + + st_container_update_pseudo_classes (container); + + clutter_actor_queue_relayout (CLUTTER_ACTOR (container)); +} + /** * st_container_get_children_list: * @container: An #StContainer diff --git a/src/st/st-container.h b/src/st/st-container.h index f5f04aa09..91f457f26 100644 --- a/src/st/st-container.h +++ b/src/st/st-container.h @@ -62,6 +62,9 @@ GList * st_container_get_focus_chain (StContainer *container); void st_container_move_child (StContainer *container, ClutterActor *actor, int pos); +void st_container_move_before (StContainer *container, + ClutterActor *actor, + ClutterActor *sibling); GList * st_container_get_children_list (StContainer *container); G_END_DECLS