1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 #include "gtkwidget.h"
25 #include "gtkwidgetpath.h"
26 #include "gtkstylecontextprivate.h"
29 * SECTION:gtkwidgetpath
30 * @Short_description: Widget path abstraction
31 * @Title: GtkWidgetPath
32 * @See_also: #GtkStyleContext
34 * GtkWidgetPath is a boxed type that represents a widget hierarchy from
35 * the topmost widget, typically a toplevel, to any child. This widget
36 * path abstraction is used in #GtkStyleContext on behalf of the real
37 * widget in order to query style information.
39 * If you are using GTK+ widgets, you probably will not need to use
40 * this API directly, as there is gtk_widget_get_path(), and the style
41 * context returned by gtk_widget_get_style_context() will be automatically
42 * updated on widget hierarchy changes.
44 * The widget path generation is generally simple:
46 * <title>Defining a button within a window</title>
49 * GtkWidgetPath *path;
51 * path = gtk_widget_path_new ();
52 * gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
53 * gtk_widget_path_append_type (path, GTK_TYPE_BUTTON);
58 * Although more complex information, such as widget names, or
59 * different classes (property that may be used by other widget
60 * types) and intermediate regions may be included:
63 * <title>Defining the first tab widget in a notebook</title>
66 * GtkWidgetPath *path;
69 * path = gtk_widget_path_new ();
71 * pos = gtk_widget_path_append_type (path, GTK_TYPE_NOTEBOOK);
72 * gtk_widget_path_iter_add_region (path, pos, "tab", GTK_REGION_EVEN | GTK_REGION_FIRST);
74 * pos = gtk_widget_path_append_type (path, GTK_TYPE_LABEL);
75 * gtk_widget_path_iter_set_name (path, pos, "first tab label");
80 * All this information will be used to match the style information
81 * that applies to the described widget.
84 G_DEFINE_BOXED_TYPE (GtkWidgetPath, gtk_widget_path,
85 gtk_widget_path_copy, gtk_widget_path_free)
88 typedef struct GtkPathElement GtkPathElement;
100 GArray *elems; /* First element contains the described widget */
104 * gtk_widget_path_new:
106 * Returns an empty widget path.
108 * Returns: (transfer full): A newly created, empty, #GtkWidgetPath
113 gtk_widget_path_new (void)
117 path = g_slice_new0 (GtkWidgetPath);
118 path->elems = g_array_new (FALSE, TRUE, sizeof (GtkPathElement));
124 * gtk_widget_path_copy:
125 * @path: a #GtkWidgetPath
127 * Returns a copy of @path
129 * Returns: (transfer full): a copy of @path
134 gtk_widget_path_copy (const GtkWidgetPath *path)
136 GtkWidgetPath *new_path;
139 g_return_val_if_fail (path != NULL, NULL);
141 new_path = gtk_widget_path_new ();
143 for (i = 0; i < path->elems->len; i++)
145 GtkPathElement *elem, new = { 0 };
147 elem = &g_array_index (path->elems, GtkPathElement, i);
149 new.type = elem->type;
150 new.name = elem->name;
157 g_hash_table_iter_init (&iter, elem->regions);
158 new.regions = g_hash_table_new (NULL, NULL);
160 while (g_hash_table_iter_next (&iter, &key, &value))
161 g_hash_table_insert (new.regions, key, value);
166 new.classes = g_array_new (FALSE, FALSE, sizeof (GQuark));
167 g_array_append_vals (new.classes, elem->classes->data, elem->classes->len);
170 g_array_append_val (new_path->elems, new);
177 * gtk_widget_path_free:
178 * @path: a #GtkWidgetPath
180 * Frees a #GtkWidgetPath.
185 gtk_widget_path_free (GtkWidgetPath *path)
189 g_return_if_fail (path != NULL);
191 for (i = 0; i < path->elems->len; i++)
193 GtkPathElement *elem;
195 elem = &g_array_index (path->elems, GtkPathElement, i);
198 g_hash_table_destroy (elem->regions);
201 g_array_free (elem->classes, TRUE);
204 g_array_free (path->elems, TRUE);
205 g_slice_free (GtkWidgetPath, path);
209 * gtk_widget_path_length:
210 * @path: a #GtkWidgetPath
212 * Returns the number of #GtkWidget #GTypes between the represented
213 * widget and its topmost container.
215 * Returns: the number of elements in the path
220 gtk_widget_path_length (const GtkWidgetPath *path)
222 g_return_val_if_fail (path != NULL, 0);
224 return path->elems->len;
228 * gtk_widget_path_to_string:
231 * Dumps the widget path into a string representation. It tries to match
232 * the CSS style as closely as possible (Note that there might be paths
233 * that cannot be represented in CSS).
235 * The main use of this code is for debugging purposes, so that you can
236 * g_print() the path or dump it in a gdb session.
238 * Returns: A new string describing @path.
241 gtk_widget_path_to_string (const GtkWidgetPath *path)
246 g_return_val_if_fail (path != NULL, NULL);
248 string = g_string_new ("");
250 for (i = 0; i < path->elems->len; i++)
252 GtkPathElement *elem;
254 elem = &g_array_index (path->elems, GtkPathElement, i);
257 g_string_append_c (string, ' ');
259 g_string_append (string, g_type_name (elem->type));
263 g_string_append_c (string, '(');
264 g_string_append (string, g_quark_to_string (elem->name));
265 g_string_append_c (string, ')');
270 for (j = 0; j < elem->classes->len; j++)
272 g_string_append_c (string, '.');
273 g_string_append (string, g_quark_to_string (g_array_index (elem->classes, GQuark, j)));
282 g_hash_table_iter_init (&iter, elem->regions);
283 while (g_hash_table_iter_next (&iter, &key, &value))
285 GtkRegionFlags flags = GPOINTER_TO_UINT (value);
286 static const char *flag_names[] = {
294 g_string_append_c (string, ' ');
295 g_string_append (string, g_quark_to_string (GPOINTER_TO_UINT (key)));
296 for (j = 0; j < G_N_ELEMENTS(flag_names); j++)
298 if (flags & (1 << j))
300 g_string_append_c (string, ':');
301 g_string_append (string, flag_names[j]);
308 return g_string_free (string, FALSE);
312 * gtk_widget_path_prepend_type:
313 * @path: a #GtkWidgetPath
314 * @type: widget type to prepend
316 * Prepends a widget type to the widget hierachy represented by @path.
321 gtk_widget_path_prepend_type (GtkWidgetPath *path,
324 GtkPathElement new = { 0 };
326 g_return_if_fail (path != NULL);
329 g_array_prepend_val (path->elems, new);
333 * gtk_widget_path_append_type:
334 * @path: a #GtkWidgetPath
335 * @type: widget type to append
337 * Appends a widget type to the widget hierachy represented by @path.
339 * Returns: the position where the element was inserted
344 gtk_widget_path_append_type (GtkWidgetPath *path,
347 GtkPathElement new = { 0 };
349 g_return_val_if_fail (path != NULL, 0);
352 g_array_append_val (path->elems, new);
354 return path->elems->len - 1;
358 * gtk_widget_path_iter_get_object_type:
359 * @path: a #GtkWidgetPath
360 * @pos: position to get the object type for, -1 for the path head
362 * Returns the object #GType that is at position @pos in the widget
363 * hierarchy defined in @path.
365 * Returns: a widget type
370 gtk_widget_path_iter_get_object_type (const GtkWidgetPath *path,
373 GtkPathElement *elem;
375 g_return_val_if_fail (path != NULL, G_TYPE_INVALID);
376 g_return_val_if_fail (path->elems->len != 0, G_TYPE_INVALID);
378 if (pos < 0 || pos >= path->elems->len)
379 pos = path->elems->len - 1;
381 elem = &g_array_index (path->elems, GtkPathElement, pos);
386 * gtk_widget_path_iter_set_object_type:
387 * @path: a #GtkWidgetPath
388 * @pos: position to modify, -1 for the path head
389 * @type: object type to set
391 * Sets the object type for a given position in the widget hierarchy
397 gtk_widget_path_iter_set_object_type (GtkWidgetPath *path,
401 GtkPathElement *elem;
403 g_return_if_fail (path != NULL);
404 g_return_if_fail (path->elems->len != 0);
406 if (pos < 0 || pos >= path->elems->len)
407 pos = path->elems->len - 1;
409 elem = &g_array_index (path->elems, GtkPathElement, pos);
414 * gtk_widget_path_iter_get_name:
415 * @path: a #GtkWidgetPath
416 * @pos: position to get the widget name for, -1 for the path head
418 * Returns the name corresponding to the widget found at
419 * the position @pos in the widget hierarchy defined by
422 * Returns: The widget name, or %NULL if none was set.
424 G_CONST_RETURN gchar *
425 gtk_widget_path_iter_get_name (const GtkWidgetPath *path,
428 GtkPathElement *elem;
430 g_return_val_if_fail (path != NULL, NULL);
431 g_return_val_if_fail (path->elems->len != 0, NULL);
433 if (pos < 0 || pos >= path->elems->len)
434 pos = path->elems->len - 1;
436 elem = &g_array_index (path->elems, GtkPathElement, pos);
437 return g_quark_to_string (elem->name);
441 * gtk_widget_path_iter_set_name:
442 * @path: a #GtkWidgetPath
443 * @pos: position to modify, -1 for the path head
446 * Sets the widget name for the widget found at position @pos
447 * in the widget hierarchy defined by @path.
452 gtk_widget_path_iter_set_name (GtkWidgetPath *path,
456 GtkPathElement *elem;
458 g_return_if_fail (path != NULL);
459 g_return_if_fail (path->elems->len != 0);
460 g_return_if_fail (name != NULL);
462 if (pos < 0 || pos >= path->elems->len)
463 pos = path->elems->len - 1;
465 elem = &g_array_index (path->elems, GtkPathElement, pos);
467 elem->name = g_quark_from_string (name);
471 * gtk_widget_path_iter_has_qname:
472 * @path: a #GtkWidgetPath
473 * @pos: position to query, -1 for the path head
474 * @qname: widget name as a #GQuark
476 * See gtk_widget_path_iter_has_name(). This is a version
477 * that operates on #GQuark<!-- -->s.
479 * Returns: %TRUE if the widget at @pos has this name
484 gtk_widget_path_iter_has_qname (const GtkWidgetPath *path,
488 GtkPathElement *elem;
490 g_return_val_if_fail (path != NULL, FALSE);
491 g_return_val_if_fail (path->elems->len != 0, FALSE);
492 g_return_val_if_fail (qname != 0, FALSE);
494 if (pos < 0 || pos >= path->elems->len)
495 pos = path->elems->len - 1;
497 elem = &g_array_index (path->elems, GtkPathElement, pos);
499 return (elem->name == qname);
503 * gtk_widget_path_iter_has_name:
504 * @path: a #GtkWidgetPath
505 * @pos: position to query, -1 for the path head
506 * @name: a widget name
508 * Returns %TRUE if the widget at position @pos has the name @name,
511 * Returns: %TRUE if the widget at @pos has this name
516 gtk_widget_path_iter_has_name (const GtkWidgetPath *path,
522 g_return_val_if_fail (path != NULL, FALSE);
523 g_return_val_if_fail (path->elems->len != 0, FALSE);
525 if (pos < 0 || pos >= path->elems->len)
526 pos = path->elems->len - 1;
528 qname = g_quark_try_string (name);
533 return gtk_widget_path_iter_has_qname (path, pos, qname);
537 * gtk_widget_path_iter_add_class:
538 * @path: a #GtkWidget
539 * @pos: position to modify, -1 for the path head
540 * @name: a class name
542 * Adds the class @name to the widget at position @pos in
543 * the hierarchy defined in @path. See
544 * gtk_style_context_add_class().
549 gtk_widget_path_iter_add_class (GtkWidgetPath *path,
553 GtkPathElement *elem;
554 gboolean added = FALSE;
558 g_return_if_fail (path != NULL);
559 g_return_if_fail (path->elems->len != 0);
560 g_return_if_fail (name != NULL);
562 if (pos < 0 || pos >= path->elems->len)
563 pos = path->elems->len - 1;
565 elem = &g_array_index (path->elems, GtkPathElement, pos);
566 qname = g_quark_from_string (name);
569 elem->classes = g_array_new (FALSE, FALSE, sizeof (GQuark));
571 for (i = 0; i < elem->classes->len; i++)
575 quark = g_array_index (elem->classes, GQuark, i);
585 g_array_insert_val (elem->classes, i, qname);
592 g_array_append_val (elem->classes, qname);
596 * gtk_widget_path_iter_remove_class:
597 * @path: a #GtkWidgetPath
598 * @pos: position to modify, -1 for the path head
601 * Removes the class @name from the widget at position @pos in
602 * the hierarchy defined in @path.
607 gtk_widget_path_iter_remove_class (GtkWidgetPath *path,
611 GtkPathElement *elem;
615 g_return_if_fail (path != NULL);
616 g_return_if_fail (path->elems->len != 0);
617 g_return_if_fail (name != NULL);
619 if (pos < 0 || pos >= path->elems->len)
620 pos = path->elems->len - 1;
622 qname = g_quark_try_string (name);
627 elem = &g_array_index (path->elems, GtkPathElement, pos);
632 for (i = 0; i < elem->classes->len; i++)
636 quark = g_array_index (elem->classes, GQuark, i);
640 else if (quark == qname)
642 g_array_remove_index (elem->classes, i);
649 * gtk_widget_path_iter_clear_classes:
650 * @path: a #GtkWidget
651 * @pos: position to modify, -1 for the path head
653 * Removes all classes from the widget at position @pos in the
654 * hierarchy defined in @path.
659 gtk_widget_path_iter_clear_classes (GtkWidgetPath *path,
662 GtkPathElement *elem;
664 g_return_if_fail (path != NULL);
665 g_return_if_fail (path->elems->len != 0);
667 if (pos < 0 || pos >= path->elems->len)
668 pos = path->elems->len - 1;
670 elem = &g_array_index (path->elems, GtkPathElement, pos);
675 if (elem->classes->len > 0)
676 g_array_remove_range (elem->classes, 0, elem->classes->len);
680 * gtk_widget_path_iter_list_classes:
681 * @path: a #GtkWidgetPath
682 * @pos: position to query, -1 for the path head
684 * Returns a list with all the class names defined for the widget
685 * at position @pos in the hierarchy defined in @path.
687 * Returns: (transfer container) (element-type utf8): The list of
688 * classes, This is a list of strings, the #GSList contents
689 * are owned by GTK+, but you should use g_slist_free() to
690 * free the list itself.
695 gtk_widget_path_iter_list_classes (const GtkWidgetPath *path,
698 GtkPathElement *elem;
702 g_return_val_if_fail (path != NULL, NULL);
703 g_return_val_if_fail (path->elems->len != 0, NULL);
705 if (pos < 0 || pos >= path->elems->len)
706 pos = path->elems->len - 1;
708 elem = &g_array_index (path->elems, GtkPathElement, pos);
713 for (i = 0; i < elem->classes->len; i++)
717 quark = g_array_index (elem->classes, GQuark, i);
718 list = g_slist_prepend (list, (gchar *) g_quark_to_string (quark));
721 return g_slist_reverse (list);
725 * gtk_widget_path_iter_has_qclass:
726 * @path: a #GtkWidgetPath
727 * @pos: position to query, -1 for the path head
728 * @qname: class name as a #GQuark
730 * See gtk_widget_path_iter_has_class(). This is a version that operates
731 * with GQuark<!-- -->s.
733 * Returns: %TRUE if the widget at @pos has the class defined.
738 gtk_widget_path_iter_has_qclass (const GtkWidgetPath *path,
742 GtkPathElement *elem;
745 g_return_val_if_fail (path != NULL, FALSE);
746 g_return_val_if_fail (path->elems->len != 0, FALSE);
747 g_return_val_if_fail (qname != 0, FALSE);
749 if (pos < 0 || pos >= path->elems->len)
750 pos = path->elems->len - 1;
752 elem = &g_array_index (path->elems, GtkPathElement, pos);
757 for (i = 0; i < elem->classes->len; i++)
761 quark = g_array_index (elem->classes, GQuark, i);
765 else if (quark > qname)
773 * gtk_widget_path_iter_has_class:
774 * @path: a #GtkWidgetPath
775 * @pos: position to query, -1 for the path head
778 * Returns %TRUE if the widget at position @pos has the class @name
779 * defined, %FALSE otherwise.
781 * Returns: %TRUE if the class @name is defined for the widget at @pos
786 gtk_widget_path_iter_has_class (const GtkWidgetPath *path,
792 g_return_val_if_fail (path != NULL, FALSE);
793 g_return_val_if_fail (path->elems->len != 0, FALSE);
794 g_return_val_if_fail (name != NULL, FALSE);
796 if (pos < 0 || pos >= path->elems->len)
797 pos = path->elems->len - 1;
799 qname = g_quark_try_string (name);
804 return gtk_widget_path_iter_has_qclass (path, pos, qname);
808 * gtk_widget_path_iter_add_region:
809 * @path: a #GtkWidgetPath
810 * @pos: position to modify, -1 for the path head
812 * @flags: flags affecting the region
814 * Adds the region @name to the widget at position @pos in
815 * the hierarchy defined in @path. See
816 * gtk_style_context_add_region().
818 * <note><para>Region names must only contain lowercase letters
819 * and '-', starting always with a lowercase letter.</para></note>
824 gtk_widget_path_iter_add_region (GtkWidgetPath *path,
827 GtkRegionFlags flags)
829 GtkPathElement *elem;
832 g_return_if_fail (path != NULL);
833 g_return_if_fail (path->elems->len != 0);
834 g_return_if_fail (name != NULL);
835 g_return_if_fail (_gtk_style_context_check_region_name (name));
837 if (pos < 0 || pos >= path->elems->len)
838 pos = path->elems->len - 1;
840 elem = &g_array_index (path->elems, GtkPathElement, pos);
841 qname = g_quark_from_string (name);
844 elem->regions = g_hash_table_new (NULL, NULL);
846 g_hash_table_insert (elem->regions,
847 GUINT_TO_POINTER (qname),
848 GUINT_TO_POINTER (flags));
852 * gtk_widget_path_iter_remove_region:
853 * @path: a #GtkWidgetPath
854 * @pos: position to modify, -1 for the path head
857 * Removes the region @name from the widget at position @pos in
858 * the hierarchy defined in @path.
863 gtk_widget_path_iter_remove_region (GtkWidgetPath *path,
867 GtkPathElement *elem;
870 g_return_if_fail (path != NULL);
871 g_return_if_fail (path->elems->len != 0);
872 g_return_if_fail (name != NULL);
874 if (pos < 0 || pos >= path->elems->len)
875 pos = path->elems->len - 1;
877 qname = g_quark_try_string (name);
882 elem = &g_array_index (path->elems, GtkPathElement, pos);
885 g_hash_table_remove (elem->regions, GUINT_TO_POINTER (qname));
889 * gtk_widget_path_iter_clear_regions:
890 * @path: a #GtkWidgetPath
891 * @pos: position to modify, -1 for the path head
893 * Removes all regions from the widget at position @pos in the
894 * hierarchy defined in @path.
899 gtk_widget_path_iter_clear_regions (GtkWidgetPath *path,
902 GtkPathElement *elem;
904 g_return_if_fail (path != NULL);
905 g_return_if_fail (path->elems->len != 0);
907 if (pos < 0 || pos >= path->elems->len)
908 pos = path->elems->len - 1;
910 elem = &g_array_index (path->elems, GtkPathElement, pos);
913 g_hash_table_remove_all (elem->regions);
917 * gtk_widget_path_iter_list_regions:
918 * @path: a #GtkWidgetPath
919 * @pos: position to query, -1 for the path head
921 * Returns a list with all the region names defined for the widget
922 * at position @pos in the hierarchy defined in @path.
924 * Returns: (transfer container) (element-type utf8): The list of
925 * regions, This is a list of strings, the #GSList contents
926 * are owned by GTK+, but you should use g_slist_free() to
927 * free the list itself.
932 gtk_widget_path_iter_list_regions (const GtkWidgetPath *path,
935 GtkPathElement *elem;
940 g_return_val_if_fail (path != NULL, NULL);
941 g_return_val_if_fail (path->elems->len != 0, NULL);
943 if (pos < 0 || pos >= path->elems->len)
944 pos = path->elems->len - 1;
946 elem = &g_array_index (path->elems, GtkPathElement, pos);
951 g_hash_table_iter_init (&iter, elem->regions);
953 while (g_hash_table_iter_next (&iter, &key, NULL))
957 qname = GPOINTER_TO_UINT (key);
958 list = g_slist_prepend (list, (gchar *) g_quark_to_string (qname));
965 * gtk_widget_path_iter_has_qregion:
966 * @path: a #GtkWidgetPath
967 * @pos: position to query, -1 for the path head
968 * @qname: region name as a #GQuark
969 * @flags: (out): return location for the region flags
971 * See gtk_widget_path_iter_has_region(). This is a version that operates
972 * with GQuark<!-- -->s.
974 * Returns: %TRUE if the widget at @pos has the region defined.
979 gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path,
982 GtkRegionFlags *flags)
984 GtkPathElement *elem;
987 g_return_val_if_fail (path != NULL, FALSE);
988 g_return_val_if_fail (path->elems->len != 0, FALSE);
989 g_return_val_if_fail (qname != 0, FALSE);
991 if (pos < 0 || pos >= path->elems->len)
992 pos = path->elems->len - 1;
994 elem = &g_array_index (path->elems, GtkPathElement, pos);
999 if (!g_hash_table_lookup_extended (elem->regions,
1000 GUINT_TO_POINTER (qname),
1005 *flags = GPOINTER_TO_UINT (value);
1011 * gtk_widget_path_iter_has_region:
1012 * @path: a #GtkWidgetPath
1013 * @pos: position to query, -1 for the path head
1014 * @name: region name
1015 * @flags: (out): return location for the region flags
1017 * Returns %TRUE if the widget at position @pos has the class @name
1018 * defined, %FALSE otherwise.
1020 * Returns: %TRUE if the class @name is defined for the widget at @pos
1025 gtk_widget_path_iter_has_region (const GtkWidgetPath *path,
1028 GtkRegionFlags *flags)
1032 g_return_val_if_fail (path != NULL, FALSE);
1033 g_return_val_if_fail (path->elems->len != 0, FALSE);
1034 g_return_val_if_fail (name != NULL, FALSE);
1036 if (pos < 0 || pos >= path->elems->len)
1037 pos = path->elems->len - 1;
1039 qname = g_quark_try_string (name);
1044 return gtk_widget_path_iter_has_qregion (path, pos, qname, flags);
1048 * gtk_widget_path_get_object_type:
1049 * @path: a #GtkWidget
1051 * Returns the topmost object type, that is, the object type this path
1054 * Returns: The object type
1059 gtk_widget_path_get_object_type (const GtkWidgetPath *path)
1061 GtkPathElement *elem;
1063 g_return_val_if_fail (path != NULL, G_TYPE_INVALID);
1065 elem = &g_array_index (path->elems, GtkPathElement,
1066 path->elems->len - 1);
1071 * gtk_widget_path_is_type:
1072 * @path: a #GtkWidgetPath
1073 * @type: widget type to match
1075 * Returns %TRUE if the widget type represented by this path
1076 * is @type, or a subtype of it.
1078 * Returns: %TRUE if the widget represented by @path is of type @type
1083 gtk_widget_path_is_type (const GtkWidgetPath *path,
1086 GtkPathElement *elem;
1088 g_return_val_if_fail (path != NULL, FALSE);
1090 elem = &g_array_index (path->elems, GtkPathElement,
1091 path->elems->len - 1);
1093 if (elem->type == type ||
1094 g_type_is_a (elem->type, type))
1101 * gtk_widget_path_has_parent:
1102 * @path: a #GtkWidgetPath
1103 * @type: widget type to check in parents
1105 * Returns %TRUE if any of the parents of the widget represented
1106 * in @path is of type @type, or any subtype of it.
1108 * Returns: %TRUE if any parent is of type @type
1113 gtk_widget_path_has_parent (const GtkWidgetPath *path,
1118 g_return_val_if_fail (path != NULL, FALSE);
1120 for (i = 0; i < path->elems->len - 1; i++)
1122 GtkPathElement *elem;
1124 elem = &g_array_index (path->elems, GtkPathElement, i);
1126 if (elem->type == type ||
1127 g_type_is_a (elem->type, type))