diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index e16eb06bf3..a96ec21128 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5383,7 +5383,7 @@ GtkWidgetPath gtk_widget_path_append_type gtk_widget_path_copy gtk_widget_path_free -gtk_widget_path_get_widget_type +gtk_widget_path_get_object_type gtk_widget_path_has_parent gtk_widget_path_is_type gtk_widget_path_iter_add_class @@ -5391,7 +5391,7 @@ gtk_widget_path_iter_add_region gtk_widget_path_iter_clear_classes gtk_widget_path_iter_clear_regions gtk_widget_path_iter_get_name -gtk_widget_path_iter_get_widget_type +gtk_widget_path_iter_get_object_type gtk_widget_path_iter_has_class gtk_widget_path_iter_has_name gtk_widget_path_iter_has_qclass @@ -5403,7 +5403,7 @@ gtk_widget_path_iter_list_regions gtk_widget_path_iter_remove_class gtk_widget_path_iter_remove_region gtk_widget_path_iter_set_name -gtk_widget_path_iter_set_widget_type +gtk_widget_path_iter_set_object_type gtk_widget_path_length gtk_widget_path_new gtk_widget_path_prepend_type diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index ad10d607e3..d93271540e 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -3498,7 +3498,7 @@ gtk_widget_path_append_type gtk_widget_path_copy gtk_widget_path_free gtk_widget_path_get_type G_GNUC_CONST -gtk_widget_path_get_widget_type +gtk_widget_path_get_object_type gtk_widget_path_has_parent gtk_widget_path_is_type gtk_widget_path_iter_add_class @@ -3506,7 +3506,7 @@ gtk_widget_path_iter_add_region gtk_widget_path_iter_clear_classes gtk_widget_path_iter_clear_regions gtk_widget_path_iter_get_name -gtk_widget_path_iter_get_widget_type +gtk_widget_path_iter_get_object_type gtk_widget_path_iter_has_class gtk_widget_path_iter_has_name gtk_widget_path_iter_has_qclass @@ -3518,7 +3518,7 @@ gtk_widget_path_iter_list_regions gtk_widget_path_iter_remove_class gtk_widget_path_iter_remove_region gtk_widget_path_iter_set_name -gtk_widget_path_iter_set_widget_type +gtk_widget_path_iter_set_object_type gtk_widget_path_length gtk_widget_path_new gtk_widget_path_prepend_type diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 1ea5ed9ae2..90a50d310a 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1073,7 +1073,7 @@ compare_selector_element (GtkWidgetPath *path, { GType type; - type = gtk_widget_path_iter_get_widget_type (path, index); + type = gtk_widget_path_iter_get_object_type (path, index); if (!g_type_is_a (type, elem->type)) return FALSE; diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 3abea8b12f..8217b37d73 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2386,7 +2386,15 @@ gtk_style_context_get_style_property (GtkStyleContext *context, if (!priv->widget_path) return; - widget_type = gtk_widget_path_get_widget_type (priv->widget_path); + widget_type = gtk_widget_path_get_object_type (priv->widget_path); + + if (!g_type_is_a (widget_type, GTK_TYPE_WIDGET)) + { + g_warning ("%s: can't get style properties for non-widget class `%s'", + G_STRLOC, + g_type_name (widget_type)); + return; + } widget_class = g_type_class_ref (widget_type); pspec = gtk_widget_class_find_style_property (widget_class, property_name); @@ -2433,6 +2441,7 @@ gtk_style_context_get_style_valist (GtkStyleContext *context, GtkStyleContextPrivate *priv; const gchar *prop_name; GtkStateFlags state; + GType widget_type; g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); @@ -2442,6 +2451,16 @@ gtk_style_context_get_style_valist (GtkStyleContext *context, if (!priv->widget_path) return; + widget_type = gtk_widget_path_get_object_type (priv->widget_path); + + if (!g_type_is_a (widget_type, GTK_TYPE_WIDGET)) + { + g_warning ("%s: can't get style properties for non-widget class `%s'", + G_STRLOC, + g_type_name (widget_type)); + return; + } + state = gtk_style_context_get_state (context); while (prop_name) @@ -2449,11 +2468,8 @@ gtk_style_context_get_style_valist (GtkStyleContext *context, GtkWidgetClass *widget_class; GParamSpec *pspec; const GValue *peek_value; - GType widget_type; gchar *error; - widget_type = gtk_widget_path_get_widget_type (priv->widget_path); - widget_class = g_type_class_ref (widget_type); pspec = gtk_widget_class_find_style_property (widget_class, prop_name); g_type_class_unref (widget_class); diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c index 8ed0d975ca..5cd63e4f06 100644 --- a/gtk/gtkstyleprovider.c +++ b/gtk/gtkstyleprovider.c @@ -107,7 +107,7 @@ gtk_style_provider_get_style_property (GtkStyleProvider *provider, g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), FALSE); g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE); g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (g_type_is_a (gtk_widget_path_get_widget_type (path), pspec->owner_type), FALSE); + g_return_val_if_fail (g_type_is_a (gtk_widget_path_get_object_type (path), pspec->owner_type), FALSE); g_return_val_if_fail (value != NULL, FALSE); iface = GTK_STYLE_PROVIDER_GET_IFACE (provider); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3e3f7a0a93..31672e01ff 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13754,7 +13754,7 @@ gtk_widget_get_path (GtkWidget *widget) * implementation with a wrong widget type in the widget path */ if (widget->priv->path && - G_OBJECT_TYPE (widget) != gtk_widget_path_get_widget_type (widget->priv->path)) + G_OBJECT_TYPE (widget) != gtk_widget_path_get_object_type (widget->priv->path)) { gtk_widget_path_free (widget->priv->path); widget->priv->path = NULL; diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index d25f550975..6636abdd14 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -239,7 +239,6 @@ gtk_widget_path_prepend_type (GtkWidgetPath *path, GtkPathElement new = { 0 }; g_return_if_fail (path != NULL); - g_return_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET)); new.type = type; g_array_prepend_val (path->elems, new); @@ -263,7 +262,6 @@ gtk_widget_path_append_type (GtkWidgetPath *path, GtkPathElement new = { 0 }; g_return_val_if_fail (path != NULL, 0); - g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), 0); new.type = type; g_array_append_val (path->elems, new); @@ -272,11 +270,11 @@ gtk_widget_path_append_type (GtkWidgetPath *path, } /** - * gtk_widget_path_iter_get_widget_type: + * gtk_widget_path_iter_get_object_type: * @path: a #GtkWidgetPath - * @pos: position to get the widget type for, -1 for the path head + * @pos: position to get the object type for, -1 for the path head * - * Returns the widget #GType that is at position @pos in the widget + * Returns the object #GType that is at position @pos in the widget * hierarchy defined in @path. * * Returns: a widget type @@ -284,7 +282,7 @@ gtk_widget_path_append_type (GtkWidgetPath *path, * Since: 3.0 **/ GType -gtk_widget_path_iter_get_widget_type (const GtkWidgetPath *path, +gtk_widget_path_iter_get_object_type (const GtkWidgetPath *path, gint pos) { GtkPathElement *elem; @@ -300,18 +298,18 @@ gtk_widget_path_iter_get_widget_type (const GtkWidgetPath *path, } /** - * gtk_widget_path_iter_set_widget_type: + * gtk_widget_path_iter_set_object_type: * @path: a #GtkWidgetPath * @pos: position to modify, -1 for the path head - * @type: widget type to set + * @type: object type to set * - * Sets the widget type for a given position in the widget hierarchy - * defined by @path. @type must be a #GtkWidget derived #GType. + * Sets the object type for a given position in the widget hierarchy + * defined by @path. * * Since: 3.0 **/ void -gtk_widget_path_iter_set_widget_type (GtkWidgetPath *path, +gtk_widget_path_iter_set_object_type (GtkWidgetPath *path, gint pos, GType type) { @@ -319,7 +317,6 @@ gtk_widget_path_iter_set_widget_type (GtkWidgetPath *path, g_return_if_fail (path != NULL); g_return_if_fail (path->elems->len != 0); - g_return_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET)); if (pos < 0 || pos > path->elems->len) pos = path->elems->len - 1; @@ -959,18 +956,18 @@ gtk_widget_path_iter_has_region (const GtkWidgetPath *path, } /** - * gtk_widget_path_get_widget_type: + * gtk_widget_path_get_object_type: * @path: a #GtkWidget * - * Returns the topmost widget type, that is, the widget type this path + * Returns the topmost object type, that is, the object type this path * is representing. * - * Returns: The widget type + * Returns: The object type * * Since: 3.0 **/ GType -gtk_widget_path_get_widget_type (const GtkWidgetPath *path) +gtk_widget_path_get_object_type (const GtkWidgetPath *path) { GtkPathElement *elem; @@ -1000,7 +997,6 @@ gtk_widget_path_is_type (const GtkWidgetPath *path, GtkPathElement *elem; g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), FALSE); elem = &g_array_index (path->elems, GtkPathElement, path->elems->len - 1); @@ -1031,7 +1027,6 @@ gtk_widget_path_has_parent (const GtkWidgetPath *path, guint i; g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (g_type_is_a (type, GTK_TYPE_WIDGET), FALSE); for (i = 0; i < path->elems->len - 1; i++) { diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 87b44b8ef9..2c9c981e41 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -46,9 +46,9 @@ gint gtk_widget_path_append_type (GtkWidgetPath *path, void gtk_widget_path_prepend_type (GtkWidgetPath *path, GType type); -GType gtk_widget_path_iter_get_widget_type (const GtkWidgetPath *path, +GType gtk_widget_path_iter_get_object_type (const GtkWidgetPath *path, gint pos); -void gtk_widget_path_iter_set_widget_type (GtkWidgetPath *path, +void gtk_widget_path_iter_set_object_type (GtkWidgetPath *path, gint pos, GType type); @@ -103,7 +103,7 @@ gboolean gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path, GQuark qname, GtkRegionFlags *flags); -GType gtk_widget_path_get_widget_type (const GtkWidgetPath *path); +GType gtk_widget_path_get_object_type (const GtkWidgetPath *path); gboolean gtk_widget_path_is_type (const GtkWidgetPath *path, GType type); diff --git a/gtk/tests/stylecontext.c b/gtk/tests/stylecontext.c index 69b9510bfd..b1e413f197 100644 --- a/gtk/tests/stylecontext.c +++ b/gtk/tests/stylecontext.c @@ -274,14 +274,14 @@ test_path (void) pos = gtk_widget_path_append_type (path, GTK_TYPE_WINDOW); g_assert_cmpint (pos, ==, 0); g_assert_cmpint (gtk_widget_path_length (path), ==, 1); - g_assert (gtk_widget_path_iter_get_widget_type (path, 0) == GTK_TYPE_WINDOW); + g_assert (gtk_widget_path_iter_get_object_type (path, 0) == GTK_TYPE_WINDOW); g_assert (gtk_widget_path_is_type (path, GTK_TYPE_WIDGET)); g_assert (gtk_widget_path_iter_get_name (path, 0) == NULL); pos = gtk_widget_path_append_type (path, GTK_TYPE_WIDGET); g_assert_cmpint (pos, ==, 1); g_assert_cmpint (gtk_widget_path_length (path), ==, 2); - gtk_widget_path_iter_set_widget_type (path, pos, GTK_TYPE_BUTTON); + gtk_widget_path_iter_set_object_type (path, pos, GTK_TYPE_BUTTON); g_assert (gtk_widget_path_is_type (path, GTK_TYPE_BUTTON)); g_assert (gtk_widget_path_has_parent (path, GTK_TYPE_WIDGET)); g_assert (gtk_widget_path_has_parent (path, GTK_TYPE_WINDOW));