1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = gtk3-GtkWidgetPath.html
27  * outPack = gtk
28  * outFile = WidgetPath
29  * strct   = GtkWidgetPath
30  * realStrct=
31  * ctorStrct=
32  * clss    = WidgetPath
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_widget_path_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ListSG
48  * 	- gtk.Widget
49  * 	- gtkc.Loader
50  * 	- gtkc.paths
51  * structWrap:
52  * 	- GSList* -> ListSG
53  * 	- GtkWidget* -> Widget
54  * 	- GtkWidgetPath* -> WidgetPath
55  * module aliases:
56  * local aliases:
57  * overrides:
58  * 	- toString
59  */
60 
61 module gtk.WidgetPath;
62 
63 public  import gtkc.gtktypes;
64 
65 private import gtkc.gtk;
66 private import glib.ConstructionException;
67 private import gobject.ObjectG;
68 
69 
70 private import glib.Str;
71 private import glib.ListSG;
72 private import gtk.Widget;
73 private import gtkc.Loader;
74 private import gtkc.paths;
75 
76 
77 
78 
79 /**
80  * GtkWidgetPath is a boxed type that represents a widget hierarchy from
81  * the topmost widget, typically a toplevel, to any child. This widget
82  * path abstraction is used in GtkStyleContext on behalf of the real
83  * widget in order to query style information.
84  *
85  * If you are using GTK+ widgets, you probably will not need to use
86  * this API directly, as there is gtk_widget_get_path(), and the style
87  * context returned by gtk_widget_get_style_context() will be automatically
88  * updated on widget hierarchy changes.
89  *
90  * The widget path generation is generally simple:
91  *
92  * $(DDOC_COMMENT example)
93  *
94  * Although more complex information, such as widget names, or
95  * different classes (property that may be used by other widget
96  * types) and intermediate regions may be included:
97  *
98  * $(DDOC_COMMENT example)
99  *
100  * All this information will be used to match the style information
101  * that applies to the described widget.
102  */
103 public class WidgetPath
104 {
105 	
106 	/** the main Gtk struct */
107 	protected GtkWidgetPath* gtkWidgetPath;
108 	
109 	
110 	public GtkWidgetPath* getWidgetPathStruct()
111 	{
112 		return gtkWidgetPath;
113 	}
114 	
115 	
116 	/** the main Gtk struct as a void* */
117 	protected void* getStruct()
118 	{
119 		return cast(void*)gtkWidgetPath;
120 	}
121 	
122 	/**
123 	 * Sets our main struct and passes it to the parent class
124 	 */
125 	public this (GtkWidgetPath* gtkWidgetPath)
126 	{
127 		this.gtkWidgetPath = gtkWidgetPath;
128 	}
129 	
130 	~this ()
131 	{
132 		if (  Linker.isLoaded(LIBRARY.GTK) && gtkWidgetPath !is null )
133 		{
134 			gtk_widget_path_free(gtkWidgetPath);
135 		}
136 	}
137 	
138 	/**
139 	 */
140 	
141 	/**
142 	 * Appends a widget type to the widget hierarchy represented by path.
143 	 * Params:
144 	 * type = widget type to append
145 	 * Returns: the position where the element was inserted Since 3.0
146 	 */
147 	public int appendType(GType type)
148 	{
149 		// gint gtk_widget_path_append_type (GtkWidgetPath *path,  GType type);
150 		return gtk_widget_path_append_type(gtkWidgetPath, type);
151 	}
152 	
153 	/**
154 	 * Appends a widget type with all its siblings to the widget hierarchy
155 	 * represented by path. Using this function instead of
156 	 * gtk_widget_path_append_type() will allow the CSS theming to use
157 	 * sibling matches in selectors and apply :nth-child() pseudo classes.
158 	 * In turn, it requires a lot more care in widget implementations as
159 	 * widgets need to make sure to call gtk_widget_reset_style() on all
160 	 * involved widgets when the siblings path changes.
161 	 * Params:
162 	 * siblings = a widget path describing a list of siblings. This path
163 	 * may not contain any siblings itself and it must not be modified
164 	 * afterwards.
165 	 * siblingIndex = index into siblings for where the added element is
166 	 * positioned.
167 	 * Returns: the position where the element was inserted. Since 3.2
168 	 */
169 	public int appendWithSiblings(WidgetPath siblings, uint siblingIndex)
170 	{
171 		// gint gtk_widget_path_append_with_siblings  (GtkWidgetPath *path,  GtkWidgetPath *siblings,  guint sibling_index);
172 		return gtk_widget_path_append_with_siblings(gtkWidgetPath, (siblings is null) ? null : siblings.getWidgetPathStruct(), siblingIndex);
173 	}
174 	
175 	/**
176 	 * Appends the data from widget to the widget hierarchy represented
177 	 * by path. This function is a shortcut for adding information from
178 	 * widget to the given path. This includes setting the name or
179 	 * adding the style classes from widget.
180 	 * Params:
181 	 * widget = the widget to append to the widget path
182 	 * Returns: the position where the data was inserted Since 3.2
183 	 */
184 	public int appendForWidget(Widget widget)
185 	{
186 		// gint gtk_widget_path_append_for_widget (GtkWidgetPath *path,  GtkWidget *widget);
187 		return gtk_widget_path_append_for_widget(gtkWidgetPath, (widget is null) ? null : widget.getWidgetStruct());
188 	}
189 	
190 	/**
191 	 * Returns a copy of path
192 	 * Returns: a copy of path. [transfer full] Since 3.0
193 	 */
194 	public WidgetPath copy()
195 	{
196 		// GtkWidgetPath * gtk_widget_path_copy (const GtkWidgetPath *path);
197 		auto p = gtk_widget_path_copy(gtkWidgetPath);
198 		
199 		if(p is null)
200 		{
201 			return null;
202 		}
203 		
204 		return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p);
205 	}
206 	
207 	/**
208 	 * Increments the reference count on path.
209 	 * Returns: path itself. Since 3.2
210 	 */
211 	public WidgetPath doref()
212 	{
213 		// GtkWidgetPath * gtk_widget_path_ref (GtkWidgetPath *path);
214 		auto p = gtk_widget_path_ref(gtkWidgetPath);
215 		
216 		if(p is null)
217 		{
218 			return null;
219 		}
220 		
221 		return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p);
222 	}
223 	
224 	/**
225 	 * Decrements the reference count on path, freeing the structure
226 	 * if the reference count reaches 0.
227 	 */
228 	public void unref()
229 	{
230 		// void gtk_widget_path_unref (GtkWidgetPath *path);
231 		gtk_widget_path_unref(gtkWidgetPath);
232 	}
233 	
234 	/**
235 	 * Decrements the reference count on path, freeing the structure
236 	 * if the reference count reaches 0.
237 	 */
238 	public void free()
239 	{
240 		// void gtk_widget_path_free (GtkWidgetPath *path);
241 		gtk_widget_path_free(gtkWidgetPath);
242 	}
243 	
244 	/**
245 	 * Returns the topmost object type, that is, the object type this path
246 	 * is representing.
247 	 * Returns: The object type Since 3.0
248 	 */
249 	public GType getObjectType()
250 	{
251 		// GType gtk_widget_path_get_object_type (const GtkWidgetPath *path);
252 		return gtk_widget_path_get_object_type(gtkWidgetPath);
253 	}
254 	
255 	/**
256 	 * Returns TRUE if any of the parents of the widget represented
257 	 * in path is of type type, or any subtype of it.
258 	 * Params:
259 	 * type = widget type to check in parents
260 	 * Returns: TRUE if any parent is of type type Since 3.0
261 	 */
262 	public int hasParent(GType type)
263 	{
264 		// gboolean gtk_widget_path_has_parent (const GtkWidgetPath *path,  GType type);
265 		return gtk_widget_path_has_parent(gtkWidgetPath, type);
266 	}
267 	
268 	/**
269 	 * Returns TRUE if the widget type represented by this path
270 	 * is type, or a subtype of it.
271 	 * Params:
272 	 * type = widget type to match
273 	 * Returns: TRUE if the widget represented by path is of type type Since 3.0
274 	 */
275 	public int isType(GType type)
276 	{
277 		// gboolean gtk_widget_path_is_type (const GtkWidgetPath *path,  GType type);
278 		return gtk_widget_path_is_type(gtkWidgetPath, type);
279 	}
280 	
281 	/**
282 	 * Adds the class name to the widget at position pos in
283 	 * the hierarchy defined in path. See
284 	 * gtk_style_context_add_class().
285 	 * Params:
286 	 * pos = position to modify, -1 for the path head
287 	 * name = a class name
288 	 * Since 3.0
289 	 */
290 	public void iterAddClass(int pos, string name)
291 	{
292 		// void gtk_widget_path_iter_add_class (GtkWidgetPath *path,  gint pos,  const gchar *name);
293 		gtk_widget_path_iter_add_class(gtkWidgetPath, pos, Str.toStringz(name));
294 	}
295 	
296 	/**
297 	 * Adds the region name to the widget at position pos in
298 	 * the hierarchy defined in path. See
299 	 * gtk_style_context_add_region().
300 	 * Note
301 	 * Region names must only contain lowercase letters
302 	 * and '-', starting always with a lowercase letter.
303 	 * Params:
304 	 * pos = position to modify, -1 for the path head
305 	 * name = region name
306 	 * flags = flags affecting the region
307 	 * Since 3.0
308 	 */
309 	public void iterAddRegion(int pos, string name, GtkRegionFlags flags)
310 	{
311 		// void gtk_widget_path_iter_add_region (GtkWidgetPath *path,  gint pos,  const gchar *name,  GtkRegionFlags flags);
312 		gtk_widget_path_iter_add_region(gtkWidgetPath, pos, Str.toStringz(name), flags);
313 	}
314 	
315 	/**
316 	 * Removes all classes from the widget at position pos in the
317 	 * hierarchy defined in path.
318 	 * Params:
319 	 * pos = position to modify, -1 for the path head
320 	 * Since 3.0
321 	 */
322 	public void iterClearClasses(int pos)
323 	{
324 		// void gtk_widget_path_iter_clear_classes (GtkWidgetPath *path,  gint pos);
325 		gtk_widget_path_iter_clear_classes(gtkWidgetPath, pos);
326 	}
327 	
328 	/**
329 	 * Removes all regions from the widget at position pos in the
330 	 * hierarchy defined in path.
331 	 * Params:
332 	 * pos = position to modify, -1 for the path head
333 	 * Since 3.0
334 	 */
335 	public void iterClearRegions(int pos)
336 	{
337 		// void gtk_widget_path_iter_clear_regions (GtkWidgetPath *path,  gint pos);
338 		gtk_widget_path_iter_clear_regions(gtkWidgetPath, pos);
339 	}
340 	
341 	/**
342 	 * Returns the name corresponding to the widget found at
343 	 * the position pos in the widget hierarchy defined by
344 	 * path
345 	 * Params:
346 	 * pos = position to get the widget name for, -1 for the path head
347 	 * Returns: The widget name, or NULL if none was set.
348 	 */
349 	public string iterGetName(int pos)
350 	{
351 		// const gchar * gtk_widget_path_iter_get_name (const GtkWidgetPath *path,  gint pos);
352 		return Str.toString(gtk_widget_path_iter_get_name(gtkWidgetPath, pos));
353 	}
354 	
355 	/**
356 	 * Returns the object GType that is at position pos in the widget
357 	 * hierarchy defined in path.
358 	 * Params:
359 	 * pos = position to get the object type for, -1 for the path head
360 	 * Returns: a widget type Since 3.0
361 	 */
362 	public GType iterGetObjectType(int pos)
363 	{
364 		// GType gtk_widget_path_iter_get_object_type  (const GtkWidgetPath *path,  gint pos);
365 		return gtk_widget_path_iter_get_object_type(gtkWidgetPath, pos);
366 	}
367 	
368 	/**
369 	 * Returns the list of siblings for the element at pos. If the element
370 	 * was not added with siblings, NULL is returned.
371 	 * Params:
372 	 * pos = position to get the siblings for, -1 for the path head
373 	 * Returns: NULL or the list of siblings for the element at pos.
374 	 */
375 	public WidgetPath iterGetSiblings(int pos)
376 	{
377 		// const GtkWidgetPath * gtk_widget_path_iter_get_siblings (const GtkWidgetPath *path,  gint pos);
378 		auto p = gtk_widget_path_iter_get_siblings(gtkWidgetPath, pos);
379 		
380 		if(p is null)
381 		{
382 			return null;
383 		}
384 		
385 		return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p);
386 	}
387 	
388 	/**
389 	 * Returns the index into the list of siblings for the element at pos as
390 	 * returned by gtk_widget_path_iter_get_siblings(). If that function would
391 	 * return NULL because the element at pos has no siblings, this function
392 	 * will return 0.
393 	 * Params:
394 	 * pos = position to get the sibling index for, -1 for the path head
395 	 * Returns: 0 or the index into the list of siblings for the element at pos.
396 	 */
397 	public uint iterGetSiblingIndex(int pos)
398 	{
399 		// guint gtk_widget_path_iter_get_sibling_index  (const GtkWidgetPath *path,  gint pos);
400 		return gtk_widget_path_iter_get_sibling_index(gtkWidgetPath, pos);
401 	}
402 	
403 	/**
404 	 * Returns TRUE if the widget at position pos has the class name
405 	 * defined, FALSE otherwise.
406 	 * Params:
407 	 * pos = position to query, -1 for the path head
408 	 * name = class name
409 	 * Returns: TRUE if the class name is defined for the widget at pos Since 3.0
410 	 */
411 	public int iterHasClass(int pos, string name)
412 	{
413 		// gboolean gtk_widget_path_iter_has_class (const GtkWidgetPath *path,  gint pos,  const gchar *name);
414 		return gtk_widget_path_iter_has_class(gtkWidgetPath, pos, Str.toStringz(name));
415 	}
416 	
417 	/**
418 	 * Returns TRUE if the widget at position pos has the name name,
419 	 * FALSE otherwise.
420 	 * Params:
421 	 * pos = position to query, -1 for the path head
422 	 * name = a widget name
423 	 * Returns: TRUE if the widget at pos has this name Since 3.0
424 	 */
425 	public int iterHasName(int pos, string name)
426 	{
427 		// gboolean gtk_widget_path_iter_has_name (const GtkWidgetPath *path,  gint pos,  const gchar *name);
428 		return gtk_widget_path_iter_has_name(gtkWidgetPath, pos, Str.toStringz(name));
429 	}
430 	
431 	/**
432 	 * See gtk_widget_path_iter_has_class(). This is a version that operates
433 	 * with GQuarks.
434 	 * Params:
435 	 * pos = position to query, -1 for the path head
436 	 * qname = class name as a GQuark
437 	 * Returns: TRUE if the widget at pos has the class defined. Since 3.0
438 	 */
439 	public int iterHasQclass(int pos, GQuark qname)
440 	{
441 		// gboolean gtk_widget_path_iter_has_qclass (const GtkWidgetPath *path,  gint pos,  GQuark qname);
442 		return gtk_widget_path_iter_has_qclass(gtkWidgetPath, pos, qname);
443 	}
444 	
445 	/**
446 	 * See gtk_widget_path_iter_has_name(). This is a version
447 	 * that operates on GQuarks.
448 	 * Params:
449 	 * pos = position to query, -1 for the path head
450 	 * qname = widget name as a GQuark
451 	 * Returns: TRUE if the widget at pos has this name Since 3.0
452 	 */
453 	public int iterHasQname(int pos, GQuark qname)
454 	{
455 		// gboolean gtk_widget_path_iter_has_qname (const GtkWidgetPath *path,  gint pos,  GQuark qname);
456 		return gtk_widget_path_iter_has_qname(gtkWidgetPath, pos, qname);
457 	}
458 	
459 	/**
460 	 * See gtk_widget_path_iter_has_region(). This is a version that operates
461 	 * with GQuarks.
462 	 * Params:
463 	 * pos = position to query, -1 for the path head
464 	 * qname = region name as a GQuark
465 	 * flags = return location for the region flags. [out]
466 	 * Returns: TRUE if the widget at pos has the region defined. Since 3.0
467 	 */
468 	public int iterHasQregion(int pos, GQuark qname, out GtkRegionFlags flags)
469 	{
470 		// gboolean gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path,  gint pos,  GQuark qname,  GtkRegionFlags *flags);
471 		return gtk_widget_path_iter_has_qregion(gtkWidgetPath, pos, qname, &flags);
472 	}
473 	
474 	/**
475 	 * Returns TRUE if the widget at position pos has the class name
476 	 * defined, FALSE otherwise.
477 	 * Params:
478 	 * pos = position to query, -1 for the path head
479 	 * name = region name
480 	 * flags = return location for the region flags. [out]
481 	 * Returns: TRUE if the class name is defined for the widget at pos Since 3.0
482 	 */
483 	public int iterHasRegion(int pos, string name, out GtkRegionFlags flags)
484 	{
485 		// gboolean gtk_widget_path_iter_has_region (const GtkWidgetPath *path,  gint pos,  const gchar *name,  GtkRegionFlags *flags);
486 		return gtk_widget_path_iter_has_region(gtkWidgetPath, pos, Str.toStringz(name), &flags);
487 	}
488 	
489 	/**
490 	 * Returns a list with all the class names defined for the widget
491 	 * at position pos in the hierarchy defined in path.
492 	 * Params:
493 	 * pos = position to query, -1 for the path head
494 	 * Returns: The list of classes, This is a list of strings, the GSList contents are owned by GTK+, but you should use g_slist_free() to free the list itself. [transfer container][element-type utf8] Since 3.0
495 	 */
496 	public ListSG iterListClasses(int pos)
497 	{
498 		// GSList * gtk_widget_path_iter_list_classes (const GtkWidgetPath *path,  gint pos);
499 		auto p = gtk_widget_path_iter_list_classes(gtkWidgetPath, pos);
500 		
501 		if(p is null)
502 		{
503 			return null;
504 		}
505 		
506 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
507 	}
508 	
509 	/**
510 	 * Returns a list with all the region names defined for the widget
511 	 * at position pos in the hierarchy defined in path.
512 	 * Params:
513 	 * pos = position to query, -1 for the path head
514 	 * Returns: The list of regions, This is a list of strings, the GSList contents are owned by GTK+, but you should use g_slist_free() to free the list itself. [transfer container][element-type utf8] Since 3.0
515 	 */
516 	public ListSG iterListRegions(int pos)
517 	{
518 		// GSList * gtk_widget_path_iter_list_regions (const GtkWidgetPath *path,  gint pos);
519 		auto p = gtk_widget_path_iter_list_regions(gtkWidgetPath, pos);
520 		
521 		if(p is null)
522 		{
523 			return null;
524 		}
525 		
526 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
527 	}
528 	
529 	/**
530 	 * Removes the class name from the widget at position pos in
531 	 * the hierarchy defined in path.
532 	 * Params:
533 	 * pos = position to modify, -1 for the path head
534 	 * name = class name
535 	 * Since 3.0
536 	 */
537 	public void iterRemoveClass(int pos, string name)
538 	{
539 		// void gtk_widget_path_iter_remove_class (GtkWidgetPath *path,  gint pos,  const gchar *name);
540 		gtk_widget_path_iter_remove_class(gtkWidgetPath, pos, Str.toStringz(name));
541 	}
542 	
543 	/**
544 	 * Removes the region name from the widget at position pos in
545 	 * the hierarchy defined in path.
546 	 * Params:
547 	 * pos = position to modify, -1 for the path head
548 	 * name = region name
549 	 * Since 3.0
550 	 */
551 	public void iterRemoveRegion(int pos, string name)
552 	{
553 		// void gtk_widget_path_iter_remove_region (GtkWidgetPath *path,  gint pos,  const gchar *name);
554 		gtk_widget_path_iter_remove_region(gtkWidgetPath, pos, Str.toStringz(name));
555 	}
556 	
557 	/**
558 	 * Sets the widget name for the widget found at position pos
559 	 * in the widget hierarchy defined by path.
560 	 * Params:
561 	 * pos = position to modify, -1 for the path head
562 	 * name = widget name
563 	 * Since 3.0
564 	 */
565 	public void iterSetName(int pos, string name)
566 	{
567 		// void gtk_widget_path_iter_set_name (GtkWidgetPath *path,  gint pos,  const gchar *name);
568 		gtk_widget_path_iter_set_name(gtkWidgetPath, pos, Str.toStringz(name));
569 	}
570 	
571 	/**
572 	 * Sets the object type for a given position in the widget hierarchy
573 	 * defined by path.
574 	 * Params:
575 	 * pos = position to modify, -1 for the path head
576 	 * type = object type to set
577 	 * Since 3.0
578 	 */
579 	public void iterSetObjectType(int pos, GType type)
580 	{
581 		// void gtk_widget_path_iter_set_object_type  (GtkWidgetPath *path,  gint pos,  GType type);
582 		gtk_widget_path_iter_set_object_type(gtkWidgetPath, pos, type);
583 	}
584 	
585 	/**
586 	 * Returns the number of GtkWidget GTypes between the represented
587 	 * widget and its topmost container.
588 	 * Returns: the number of elements in the path Since 3.0
589 	 */
590 	public int length()
591 	{
592 		// gint gtk_widget_path_length (const GtkWidgetPath *path);
593 		return gtk_widget_path_length(gtkWidgetPath);
594 	}
595 	
596 	/**
597 	 * Returns an empty widget path.
598 	 * Throws: ConstructionException GTK+ fails to create the object.
599 	 */
600 	public this ()
601 	{
602 		// GtkWidgetPath * gtk_widget_path_new (void);
603 		auto p = gtk_widget_path_new();
604 		if(p is null)
605 		{
606 			throw new ConstructionException("null returned by gtk_widget_path_new()");
607 		}
608 		this(cast(GtkWidgetPath*) p);
609 	}
610 	
611 	/**
612 	 * Prepends a widget type to the widget hierachy represented by path.
613 	 * Params:
614 	 * type = widget type to prepend
615 	 * Since 3.0
616 	 */
617 	public void prependType(GType type)
618 	{
619 		// void gtk_widget_path_prepend_type (GtkWidgetPath *path,  GType type);
620 		gtk_widget_path_prepend_type(gtkWidgetPath, type);
621 	}
622 	
623 	/**
624 	 * Dumps the widget path into a string representation. It tries to match
625 	 * the CSS style as closely as possible (Note that there might be paths
626 	 * that cannot be represented in CSS).
627 	 * The main use of this code is for debugging purposes, so that you can
628 	 * g_print() the path or dump it in a gdb session.
629 	 * Returns: A new string describing path. Since 3.2
630 	 */
631 	public override string toString()
632 	{
633 		// char * gtk_widget_path_to_string (const GtkWidgetPath *path);
634 		return Str.toString(gtk_widget_path_to_string(gtkWidgetPath));
635 	}
636 }