aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-node.c
diff options
context:
space:
mode:
authorXan Lopez <xan@src.gnome.org>2003-04-26 00:06:19 +0800
committerXan Lopez <xan@src.gnome.org>2003-04-26 00:06:19 +0800
commit98f768009939e3b06f2777ccb4307245f0637f36 (patch)
treefdfac352ab0901919cb99d5caf4d72d40622ed3f /lib/ephy-node.c
parent942e954a637fe6a462f3337c2aef8fa683877976 (diff)
downloadgsoc2013-epiphany-98f768009939e3b06f2777ccb4307245f0637f36.tar
gsoc2013-epiphany-98f768009939e3b06f2777ccb4307245f0637f36.tar.gz
gsoc2013-epiphany-98f768009939e3b06f2777ccb4307245f0637f36.tar.bz2
gsoc2013-epiphany-98f768009939e3b06f2777ccb4307245f0637f36.tar.lz
gsoc2013-epiphany-98f768009939e3b06f2777ccb4307245f0637f36.tar.xz
gsoc2013-epiphany-98f768009939e3b06f2777ccb4307245f0637f36.tar.zst
gsoc2013-epiphany-98f768009939e3b06f2777ccb4307245f0637f36.zip
Implement ephy_node_reorder_children (from Rhythmbox).
Implement ephy_node_reorder_children (from Rhythmbox).
Diffstat (limited to 'lib/ephy-node.c')
-rw-r--r--lib/ephy-node.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/ephy-node.c b/lib/ephy-node.c
index f3283cc88..42477c6f3 100644
--- a/lib/ephy-node.c
+++ b/lib/ephy-node.c
@@ -93,6 +93,7 @@ enum
CHILD_ADDED,
CHILD_CHANGED,
CHILD_REMOVED,
+ CHILDREN_REORDERED,
LAST_SIGNAL
};
@@ -202,6 +203,16 @@ ephy_node_class_init (EphyNodeClass *klass)
G_TYPE_NONE,
1,
EPHY_TYPE_NODE);
+ ephy_node_signals[CHILDREN_REORDERED] =
+ g_signal_new ("children_reordered",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyNodeClass, children_reordered),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
}
static gboolean
@@ -1225,6 +1236,48 @@ ephy_node_has_child (EphyNode *node,
return ret;
}
+void
+ephy_node_reorder_children (EphyNode *node,
+ int *new_order)
+{
+ GPtrArray *newkids;
+ int i;
+
+ g_return_if_fail (EPHY_IS_NODE (node));
+ g_return_if_fail (new_order != NULL);
+
+ lock_gdk ();
+
+ g_static_rw_lock_writer_lock (node->priv->lock);
+
+ newkids = g_ptr_array_new ();
+ g_ptr_array_set_size (newkids, node->priv->children->len);
+
+ for (i = 0; i < node->priv->children->len; i++) {
+ EphyNode *child;
+ EphyNodeParent *node_info;
+
+ child = g_ptr_array_index (node->priv->children, i);
+
+ g_ptr_array_index (newkids, new_order[i]) = child;
+
+ node_info = g_hash_table_lookup (child->priv->parents,
+ GINT_TO_POINTER (node->priv->id));
+ node_info->index = new_order[i];
+ }
+
+ g_ptr_array_free (node->priv->children, FALSE);
+ node->priv->children = newkids;
+
+ write_lock_to_read_lock (node);
+
+ g_signal_emit (G_OBJECT (node), ephy_node_signals[CHILDREN_REORDERED], 0, new_order);
+
+ g_static_rw_lock_reader_unlock (node->priv->lock);
+
+ unlock_gdk ();
+}
+
GPtrArray *
ephy_node_get_children (EphyNode *node)
{