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 module gtk.ListItem; 26 27 private import gobject.ObjectG; 28 private import gtk.Widget; 29 private import gtk.c.functions; 30 public import gtk.c.types; 31 32 33 /** 34 * `GtkListItem` is used by list widgets to represent items in a `GListModel`. 35 * 36 * The `GtkListItem`s are managed by the list widget (with its factory) 37 * and cannot be created by applications, but they need to be populated 38 * by application code. This is done by calling [method@Gtk.ListItem.set_child]. 39 * 40 * `GtkListItem`s exist in 2 stages: 41 * 42 * 1. The unbound stage where the listitem is not currently connected to 43 * an item in the list. In that case, the [property@Gtk.ListItem:item] 44 * property is set to %NULL. 45 * 46 * 2. The bound stage where the listitem references an item from the list. 47 * The [property@Gtk.ListItem:item] property is not %NULL. 48 */ 49 public class ListItem : ObjectG 50 { 51 /** the main Gtk struct */ 52 protected GtkListItem* gtkListItem; 53 54 /** Get the main Gtk struct */ 55 public GtkListItem* getListItemStruct(bool transferOwnership = false) 56 { 57 if (transferOwnership) 58 ownedRef = false; 59 return gtkListItem; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected override void* getStruct() 64 { 65 return cast(void*)gtkListItem; 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (GtkListItem* gtkListItem, bool ownedRef = false) 72 { 73 this.gtkListItem = gtkListItem; 74 super(cast(GObject*)gtkListItem, ownedRef); 75 } 76 77 78 /** */ 79 public static GType getType() 80 { 81 return gtk_list_item_get_type(); 82 } 83 84 /** 85 * Checks if a list item has been set to be activatable via 86 * gtk_list_item_set_activatable(). 87 * 88 * Returns: %TRUE if the item is activatable 89 */ 90 public bool getActivatable() 91 { 92 return gtk_list_item_get_activatable(gtkListItem) != 0; 93 } 94 95 /** 96 * Gets the child previously set via gtk_list_item_set_child() or 97 * %NULL if none was set. 98 * 99 * Returns: The child 100 */ 101 public Widget getChild() 102 { 103 auto __p = gtk_list_item_get_child(gtkListItem); 104 105 if(__p is null) 106 { 107 return null; 108 } 109 110 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 111 } 112 113 /** 114 * Gets the model item that associated with @self. 115 * 116 * If @self is unbound, this function returns %NULL. 117 * 118 * Returns: The item displayed 119 */ 120 public ObjectG getItem() 121 { 122 auto __p = gtk_list_item_get_item(gtkListItem); 123 124 if(__p is null) 125 { 126 return null; 127 } 128 129 return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p); 130 } 131 132 /** 133 * Gets the position in the model that @self currently displays. 134 * 135 * If @self is unbound, %GTK_INVALID_LIST_POSITION is returned. 136 * 137 * Returns: The position of this item 138 */ 139 public uint getPosition() 140 { 141 return gtk_list_item_get_position(gtkListItem); 142 } 143 144 /** 145 * Checks if a list item has been set to be selectable via 146 * gtk_list_item_set_selectable(). 147 * 148 * Do not confuse this function with [method@Gtk.ListItem.get_selected]. 149 * 150 * Returns: %TRUE if the item is selectable 151 */ 152 public bool getSelectable() 153 { 154 return gtk_list_item_get_selectable(gtkListItem) != 0; 155 } 156 157 /** 158 * Checks if the item is displayed as selected. 159 * 160 * The selected state is maintained by the liste widget and its model 161 * and cannot be set otherwise. 162 * 163 * Returns: %TRUE if the item is selected. 164 */ 165 public bool getSelected() 166 { 167 return gtk_list_item_get_selected(gtkListItem) != 0; 168 } 169 170 /** 171 * Sets @self to be activatable. 172 * 173 * If an item is activatable, double-clicking on the item, using 174 * the Return key or calling gtk_widget_activate() will activate 175 * the item. Activating instructs the containing view to handle 176 * activation. `GtkListView` for example will be emitting the 177 * [signal@Gtk.ListView::activate] signal. 178 * 179 * By default, list items are activatable. 180 * 181 * Params: 182 * activatable = if the item should be activatable 183 */ 184 public void setActivatable(bool activatable) 185 { 186 gtk_list_item_set_activatable(gtkListItem, activatable); 187 } 188 189 /** 190 * Sets the child to be used for this listitem. 191 * 192 * This function is typically called by applications when 193 * setting up a listitem so that the widget can be reused when 194 * binding it multiple times. 195 * 196 * Params: 197 * child = The list item's child or %NULL to unset 198 */ 199 public void setChild(Widget child) 200 { 201 gtk_list_item_set_child(gtkListItem, (child is null) ? null : child.getWidgetStruct()); 202 } 203 204 /** 205 * Sets @self to be selectable. 206 * 207 * If an item is selectable, clicking on the item or using the keyboard 208 * will try to select or unselect the item. If this succeeds is up to 209 * the model to determine, as it is managing the selected state. 210 * 211 * Note that this means that making an item non-selectable has no 212 * influence on the selected state at all. A non-selectable item 213 * may still be selected. 214 * 215 * By default, list items are selectable. When rebinding them to 216 * a new item, they will also be reset to be selectable by GTK. 217 * 218 * Params: 219 * selectable = if the item should be selectable 220 */ 221 public void setSelectable(bool selectable) 222 { 223 gtk_list_item_set_selectable(gtkListItem, selectable); 224 } 225 }