1 /* 2 * This file is part of d-dazzle. 3 * 4 * d-dazzle 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 * d-dazzle 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 d-dazzle; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 module dazzle.PathElement; 20 21 private import dazzle.c.functions; 22 public import dazzle.c.types; 23 private import glib.ConstructionException; 24 private import glib.Str; 25 private import gobject.ObjectG; 26 27 28 /** */ 29 public class PathElement : ObjectG 30 { 31 /** the main Gtk struct */ 32 protected DzlPathElement* dzlPathElement; 33 34 /** Get the main Gtk struct */ 35 public DzlPathElement* getPathElementStruct(bool transferOwnership = false) 36 { 37 if (transferOwnership) 38 ownedRef = false; 39 return dzlPathElement; 40 } 41 42 /** the main Gtk struct as a void* */ 43 protected override void* getStruct() 44 { 45 return cast(void*)dzlPathElement; 46 } 47 48 /** 49 * Sets our main struct and passes it to the parent class. 50 */ 51 public this (DzlPathElement* dzlPathElement, bool ownedRef = false) 52 { 53 this.dzlPathElement = dzlPathElement; 54 super(cast(GObject*)dzlPathElement, ownedRef); 55 } 56 57 58 /** */ 59 public static GType getType() 60 { 61 return dzl_path_element_get_type(); 62 } 63 64 /** 65 * Creates a new path element for an #DzlPath. 66 * 67 * Params: 68 * id = An id for the path element. 69 * iconName = An optional icon name for the element 70 * title = The title of the element. 71 * 72 * Returns: A #DzlPathElement 73 * 74 * Since: 3.26 75 * 76 * Throws: ConstructionException GTK+ fails to create the object. 77 */ 78 public this(string id, string iconName, string title) 79 { 80 auto p = dzl_path_element_new(Str.toStringz(id), Str.toStringz(iconName), Str.toStringz(title)); 81 82 if(p is null) 83 { 84 throw new ConstructionException("null returned by new"); 85 } 86 87 this(cast(DzlPathElement*) p, true); 88 } 89 90 /** 91 * Gets the #DzlPathElement:icon-name property. This is used by the 92 * path bar to display an icon next to the element of the path. 93 * 94 * Returns: The icon-name for the #DzlPathElement. 95 * 96 * Since: 3.26 97 */ 98 public string getIconName() 99 { 100 return Str.toString(dzl_path_element_get_icon_name(dzlPathElement)); 101 } 102 103 /** 104 * Gets the id for the element. Generally, a path is built of 105 * multiple elements and each element should have an id that 106 * is useful to the application that it using it. You might store 107 * the name of a directory, or some other key as the id. 108 * 109 * Returns: The id for the #DzlPathElement. 110 * 111 * Since: 3.26 112 */ 113 public string getId() 114 { 115 return Str.toString(dzl_path_element_get_id(dzlPathElement)); 116 } 117 118 /** 119 * Gets the #DzlPathElement:title property. This is used by the 120 * path bar to display text representing the element of the path. 121 * 122 * Returns: The title for the #DzlPathElement. 123 * 124 * Since: 3.26 125 */ 126 public string getTitle() 127 { 128 return Str.toString(dzl_path_element_get_title(dzlPathElement)); 129 } 130 }