summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-07-12 21:39:49 +0200
committerBenjamin Otte <otte@redhat.com>2015-07-16 06:15:13 +0200
commit6e4f42f97e4b61d9fb2c3e8ecc0ac9baa3eb890b (patch)
treefe6397faf7a322a2f372bfe45b63d0c817d05697 /gtk
parent79f2400c0dd769755b8e2034a9d574f567987c0d (diff)
downloadgtk+-6e4f42f97e4b61d9fb2c3e8ecc0ac9baa3eb890b.tar.gz
cssnode: Change API of some functions
gtk_css_node_set_after/before() are now called gtk_css_node_insert_after/before(). This brings them in line with other similar APIs (ie GtkListStore). And it allows easier usage of the API (see changes to gtkbox.c).
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkbox.c45
-rw-r--r--gtk/gtkcssnode.c26
-rw-r--r--gtk/gtkcssnodeprivate.h6
-rw-r--r--gtk/gtkflowbox.c12
-rw-r--r--gtk/gtklistbox.c12
5 files changed, 54 insertions, 47 deletions
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 53a52a2803..795779b646 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -1434,43 +1434,40 @@ gtk_box_buildable_init (GtkBuildableIface *iface)
iface->add_child = gtk_box_buildable_add_child;
}
-static void
-gtk_box_invalidate_order_foreach (GtkWidget *widget,
- gpointer prev)
-{
- GtkCssNode **previous = prev;
- GtkCssNode *cur = gtk_widget_get_css_node (widget);
-
- if (*previous)
- gtk_css_node_set_after (cur, *previous);
-
- *previous = cur;
-}
+typedef struct {
+ GtkCssNode *parent;
+ GtkCssNode *previous;
+ gboolean reverse;
+} InvalidateOrderData;
static void
-gtk_box_invalidate_order_foreach_reverse (GtkWidget *widget,
- gpointer prev)
+gtk_box_invalidate_order_foreach (GtkWidget *widget,
+ gpointer datap)
{
- GtkCssNode **previous = prev;
+ InvalidateOrderData *data = datap;
GtkCssNode *cur = gtk_widget_get_css_node (widget);
- if (*previous)
- gtk_css_node_set_before (cur, *previous);
+ if (data->reverse)
+ gtk_css_node_insert_before (data->parent, cur, data->previous);
+ else
+ gtk_css_node_insert_after (data->parent, cur, data->previous);
- *previous = cur;
+ data->previous = cur;
}
static void
gtk_box_invalidate_order (GtkBox *box)
{
- GtkCssNode *previous = NULL;
+ InvalidateOrderData data;
+
+ data.parent = gtk_widget_get_css_node (GTK_WIDGET (box));
+ data.previous = NULL;
+ data.reverse = box->priv->orientation == GTK_ORIENTATION_HORIZONTAL
+ && gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL;
gtk_container_foreach (GTK_CONTAINER (box),
- (box->priv->orientation == GTK_ORIENTATION_HORIZONTAL
- && gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL)
- ? gtk_box_invalidate_order_foreach_reverse
- : gtk_box_invalidate_order_foreach,
- &previous);
+ gtk_box_invalidate_order_foreach,
+ &data);
}
static void
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 0b88b916dd..8f1e4d9df5 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -741,27 +741,35 @@ gtk_css_node_set_parent (GtkCssNode *node,
}
void
-gtk_css_node_set_after (GtkCssNode *cssnode,
- GtkCssNode *previous_sibling)
+gtk_css_node_insert_after (GtkCssNode *parent,
+ GtkCssNode *cssnode,
+ GtkCssNode *previous_sibling)
{
- if (cssnode->previous_sibling == previous_sibling)
+ g_return_if_fail (previous_sibling == NULL || previous_sibling->parent == parent);
+
+ if (cssnode->previous_sibling == previous_sibling &&
+ cssnode->parent == parent)
return;
gtk_css_node_reposition (cssnode,
- previous_sibling->parent,
+ parent,
previous_sibling);
}
void
-gtk_css_node_set_before (GtkCssNode *cssnode,
- GtkCssNode *next_sibling)
+gtk_css_node_insert_before (GtkCssNode *parent,
+ GtkCssNode *cssnode,
+ GtkCssNode *next_sibling)
{
- if (cssnode->next_sibling == next_sibling)
+ g_return_if_fail (next_sibling == NULL || next_sibling->parent == parent);
+
+ if (cssnode->next_sibling == next_sibling &&
+ cssnode->parent == parent)
return;
gtk_css_node_reposition (cssnode,
- next_sibling->parent,
- next_sibling->previous_sibling);
+ parent,
+ next_sibling ? next_sibling->previous_sibling : parent->last_child);
}
GtkCssNode *
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index 293ba0252a..ad606aa93d 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -95,9 +95,11 @@ GType gtk_css_node_get_type (void) G_GNUC_CONST;
void gtk_css_node_set_parent (GtkCssNode *cssnode,
GtkCssNode *parent);
-void gtk_css_node_set_after (GtkCssNode *cssnode,
+void gtk_css_node_insert_after (GtkCssNode *parent,
+ GtkCssNode *cssnode,
GtkCssNode *previous_sibling);
-void gtk_css_node_set_before (GtkCssNode *cssnode,
+void gtk_css_node_insert_before (GtkCssNode *parent,
+ GtkCssNode *cssnode,
GtkCssNode *next_sibling);
GtkCssNode * gtk_css_node_get_parent (GtkCssNode *cssnode);
GtkCssNode * gtk_css_node_get_first_child (GtkCssNode *cssnode);
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 7fe339d756..8a593275ea 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -4013,18 +4013,16 @@ gtk_flow_box_insert_css_node (GtkFlowBox *box,
GSequenceIter *iter)
{
GSequenceIter *prev_iter;
- GtkCssNode *child_node;
- GtkCssNode *sibling_node;
GtkWidget *sibling;
- child_node = gtk_widget_get_css_node (child);
prev_iter = g_sequence_iter_prev (iter);
if (prev_iter != iter)
{
sibling = g_sequence_get (prev_iter);
- sibling_node = gtk_widget_get_css_node (sibling);
- gtk_css_node_set_after (child_node, sibling_node);
+ gtk_css_node_insert_after (gtk_widget_get_css_node (GTK_WIDGET (box)),
+ gtk_widget_get_css_node (child),
+ gtk_widget_get_css_node (sibling));
}
}
@@ -4843,7 +4841,9 @@ gtk_flow_box_css_node_foreach (gpointer data,
{
prev_node = gtk_widget_get_css_node (*previous);
row_node = gtk_widget_get_css_node (row);
- gtk_css_node_set_after (row_node, prev_node);
+ gtk_css_node_insert_after (gtk_css_node_get_parent (row_node),
+ row_node,
+ prev_node);
}
*previous = row;
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 39667eba02..3a5c6d6b79 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -1180,7 +1180,9 @@ gtk_list_box_css_node_foreach (gpointer data,
{
prev_node = gtk_widget_get_css_node (*previous);
row_node = gtk_widget_get_css_node (row);
- gtk_css_node_set_after (row_node, prev_node);
+ gtk_css_node_insert_after (gtk_css_node_get_parent (row_node),
+ row_node,
+ prev_node);
}
*previous = row;
@@ -2626,18 +2628,16 @@ gtk_list_box_insert_css_node (GtkListBox *box,
GSequenceIter *iter)
{
GSequenceIter *prev_iter;
- GtkCssNode *child_node;
- GtkCssNode *sibling_node;
GtkWidget *sibling;
- child_node = gtk_widget_get_css_node (child);
prev_iter = g_sequence_iter_prev (iter);
if (prev_iter != iter)
{
sibling = g_sequence_get (prev_iter);
- sibling_node = gtk_widget_get_css_node (sibling);
- gtk_css_node_set_after (child_node, sibling_node);
+ gtk_css_node_insert_after (gtk_widget_get_css_node (GTK_WIDGET (box)),
+ gtk_widget_get_css_node (child),
+ gtk_widget_get_css_node (sibling));
}
}