diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c index 2573273616..c39b4c75d1 100644 --- a/gtk/gtkwidgetpath.c +++ b/gtk/gtkwidgetpath.c @@ -305,6 +305,35 @@ gtk_widget_path_iter_has_region (GtkWidgetPath *path, return TRUE; } +GType +gtk_widget_path_get_widget_type (const GtkWidgetPath *path) +{ + GtkPathElement *elem; + + g_return_val_if_fail (path != NULL, G_TYPE_INVALID); + + elem = &g_array_index (path->elems, GtkPathElement, 0); + return elem->type; +} + +gboolean +gtk_widget_path_is_type (const GtkWidgetPath *path, + GType type) +{ + 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, 0); + + if (elem->type == type || + g_type_is_a (elem->type, type)) + return TRUE; + + return FALSE; +} + gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, GType type) diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h index 7020c826a3..9e2d0edf1e 100644 --- a/gtk/gtkwidgetpath.h +++ b/gtk/gtkwidgetpath.h @@ -68,8 +68,12 @@ gboolean gtk_widget_path_iter_has_region (GtkWidgetPath *path, const gchar *name, GtkChildClassFlags *flags); -gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, - GType type); +GType gtk_widget_path_get_widget_type (const GtkWidgetPath *path); + +gboolean gtk_widget_path_is_type (const GtkWidgetPath *path, + GType type); +gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path, + GType type); G_END_DECLS