summaryrefslogtreecommitdiff
path: root/gtk/gtkwidget.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2012-04-07 14:15:35 +0200
committerBenjamin Otte <otte@redhat.com>2012-04-17 08:59:21 +0200
commit33f111a47c47f343ce549ea66bc8608f9c75ab7d (patch)
tree765c985a1f9aed11b463b72e88278914b5698903 /gtk/gtkwidget.c
parent6ac754cdd1b5a273b0c0930866211c9b4bc450f4 (diff)
downloadgtk+-33f111a47c47f343ce549ea66bc8608f9c75ab7d.tar.gz
widget: Don't cache widget paths all the time
Add an internal API that allows GtkStyleContext to create a widget path for the widget and with that bypassing gtk_widget_get_path() and that function caching the path.
Diffstat (limited to 'gtk/gtkwidget.c')
-rw-r--r--gtk/gtkwidget.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index d74c94140e..3c709ca052 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13897,6 +13897,39 @@ gtk_widget_path_append_for_widget (GtkWidgetPath *path,
return pos;
}
+GtkWidgetPath *
+_gtk_widget_create_path (GtkWidget *widget)
+{
+ GtkWidget *parent;
+
+ parent = widget->priv->parent;
+
+ if (parent)
+ return gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
+ else
+ {
+ /* Widget is either toplevel or unparented, treat both
+ * as toplevels style wise, since there are situations
+ * where style properties might be retrieved on that
+ * situation.
+ */
+ GtkWidget *attach_widget = NULL;
+ GtkWidgetPath *result;
+
+ if (GTK_IS_WINDOW (widget))
+ attach_widget = gtk_window_get_attached_to (GTK_WINDOW (widget));
+
+ if (attach_widget != NULL)
+ result = gtk_widget_path_copy (gtk_widget_get_path (attach_widget));
+ else
+ result = gtk_widget_path_new ();
+
+ gtk_widget_path_append_for_widget (result, widget);
+
+ return result;
+ }
+}
+
/**
* gtk_widget_get_path:
* @widget: a #GtkWidget
@@ -13913,33 +13946,7 @@ gtk_widget_get_path (GtkWidget *widget)
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
if (!widget->priv->path)
- {
- GtkWidget *parent;
-
- parent = widget->priv->parent;
-
- if (parent)
- widget->priv->path = gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
- else
- {
- /* Widget is either toplevel or unparented, treat both
- * as toplevels style wise, since there are situations
- * where style properties might be retrieved on that
- * situation.
- */
- GtkWidget *attach_widget = NULL;
-
- if (GTK_IS_WINDOW (widget))
- attach_widget = gtk_window_get_attached_to (GTK_WINDOW (widget));
-
- if (attach_widget != NULL)
- widget->priv->path = gtk_widget_path_copy (gtk_widget_get_path (attach_widget));
- else
- widget->priv->path = gtk_widget_path_new ();
-
- gtk_widget_path_append_for_widget (widget->priv->path, widget);
- }
- }
+ widget->priv->path = _gtk_widget_create_path (widget);
return widget->priv->path;
}