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.ListBoxRow; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.Bin; 31 private import gtk.Widget; 32 private import gtkc.gtk; 33 public import gtkc.gtktypes; 34 private import std.algorithm; 35 36 37 /** */ 38 public class ListBoxRow : Bin 39 { 40 /** the main Gtk struct */ 41 protected GtkListBoxRow* gtkListBoxRow; 42 43 /** Get the main Gtk struct */ 44 public GtkListBoxRow* getListBoxRowStruct(bool transferOwnership = false) 45 { 46 if (transferOwnership) 47 ownedRef = false; 48 return gtkListBoxRow; 49 } 50 51 /** the main Gtk struct as a void* */ 52 protected override void* getStruct() 53 { 54 return cast(void*)gtkListBoxRow; 55 } 56 57 protected override void setStruct(GObject* obj) 58 { 59 gtkListBoxRow = cast(GtkListBoxRow*)obj; 60 super.setStruct(obj); 61 } 62 63 /** 64 * Sets our main struct and passes it to the parent class. 65 */ 66 public this (GtkListBoxRow* gtkListBoxRow, bool ownedRef = false) 67 { 68 this.gtkListBoxRow = gtkListBoxRow; 69 super(cast(GtkBin*)gtkListBoxRow, ownedRef); 70 } 71 72 73 /** */ 74 public static GType getType() 75 { 76 return gtk_list_box_row_get_type(); 77 } 78 79 /** 80 * Creates a new #GtkListBoxRow, to be used as a child of a #GtkListBox. 81 * 82 * Returns: a new #GtkListBoxRow 83 * 84 * Since: 3.10 85 * 86 * Throws: ConstructionException GTK+ fails to create the object. 87 */ 88 public this() 89 { 90 auto p = gtk_list_box_row_new(); 91 92 if(p is null) 93 { 94 throw new ConstructionException("null returned by new"); 95 } 96 97 this(cast(GtkListBoxRow*) p); 98 } 99 100 /** 101 * Marks @row as changed, causing any state that depends on this 102 * to be updated. This affects sorting, filtering and headers. 103 * 104 * Note that calls to this method must be in sync with the data 105 * used for the row functions. For instance, if the list is 106 * mirroring some external data set, and *two* rows changed in the 107 * external data set then when you call gtk_list_box_row_changed() 108 * on the first row the sort function must only read the new data 109 * for the first of the two changed rows, otherwise the resorting 110 * of the rows will be wrong. 111 * 112 * This generally means that if you don’t fully control the data 113 * model you have to duplicate the data that affects the listbox 114 * row functions into the row widgets themselves. Another alternative 115 * is to call gtk_list_box_invalidate_sort() on any model change, 116 * but that is more expensive. 117 * 118 * Since: 3.10 119 */ 120 public void changed() 121 { 122 gtk_list_box_row_changed(gtkListBoxRow); 123 } 124 125 /** 126 * Gets the value of the #GtkListBoxRow:activatable property 127 * for this row. 128 * 129 * Returns: %TRUE if the row is activatable 130 * 131 * Since: 3.14 132 */ 133 public bool getActivatable() 134 { 135 return gtk_list_box_row_get_activatable(gtkListBoxRow) != 0; 136 } 137 138 /** 139 * Returns the current header of the @row. This can be used 140 * in a #GtkListBoxUpdateHeaderFunc to see if there is a header 141 * set already, and if so to update the state of it. 142 * 143 * Returns: the current header, or %NULL if none 144 * 145 * Since: 3.10 146 */ 147 public Widget getHeader() 148 { 149 auto p = gtk_list_box_row_get_header(gtkListBoxRow); 150 151 if(p is null) 152 { 153 return null; 154 } 155 156 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 157 } 158 159 /** 160 * Gets the current index of the @row in its #GtkListBox container. 161 * 162 * Returns: the index of the @row, or -1 if the @row is not in a listbox 163 * 164 * Since: 3.10 165 */ 166 public int getIndex() 167 { 168 return gtk_list_box_row_get_index(gtkListBoxRow); 169 } 170 171 /** 172 * Gets the value of the #GtkListBoxRow:selectable property 173 * for this row. 174 * 175 * Returns: %TRUE if the row is selectable 176 * 177 * Since: 3.14 178 */ 179 public bool getSelectable() 180 { 181 return gtk_list_box_row_get_selectable(gtkListBoxRow) != 0; 182 } 183 184 /** 185 * Returns whether the child is currently selected in its 186 * #GtkListBox container. 187 * 188 * Returns: %TRUE if @row is selected 189 * 190 * Since: 3.14 191 */ 192 public bool isSelected() 193 { 194 return gtk_list_box_row_is_selected(gtkListBoxRow) != 0; 195 } 196 197 /** 198 * Set the #GtkListBoxRow:activatable property for this row. 199 * 200 * Params: 201 * activatable = %TRUE to mark the row as activatable 202 * 203 * Since: 3.14 204 */ 205 public void setActivatable(bool activatable) 206 { 207 gtk_list_box_row_set_activatable(gtkListBoxRow, activatable); 208 } 209 210 /** 211 * Sets the current header of the @row. This is only allowed to be called 212 * from a #GtkListBoxUpdateHeaderFunc. It will replace any existing 213 * header in the row, and be shown in front of the row in the listbox. 214 * 215 * Params: 216 * header = the header, or %NULL 217 * 218 * Since: 3.10 219 */ 220 public void setHeader(Widget header) 221 { 222 gtk_list_box_row_set_header(gtkListBoxRow, (header is null) ? null : header.getWidgetStruct()); 223 } 224 225 /** 226 * Set the #GtkListBoxRow:selectable property for this row. 227 * 228 * Params: 229 * selectable = %TRUE to mark the row as selectable 230 * 231 * Since: 3.14 232 */ 233 public void setSelectable(bool selectable) 234 { 235 gtk_list_box_row_set_selectable(gtkListBoxRow, selectable); 236 } 237 238 protected class OnActivateDelegateWrapper 239 { 240 static OnActivateDelegateWrapper[] listeners; 241 void delegate(ListBoxRow) dlg; 242 gulong handlerId; 243 244 this(void delegate(ListBoxRow) dlg) 245 { 246 this.dlg = dlg; 247 this.listeners ~= this; 248 } 249 250 void remove(OnActivateDelegateWrapper source) 251 { 252 foreach(index, wrapper; listeners) 253 { 254 if (wrapper.handlerId == source.handlerId) 255 { 256 listeners[index] = null; 257 listeners = std.algorithm.remove(listeners, index); 258 break; 259 } 260 } 261 } 262 } 263 264 /** */ 265 gulong addOnActivate(void delegate(ListBoxRow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 266 { 267 auto wrapper = new OnActivateDelegateWrapper(dlg); 268 wrapper.handlerId = Signals.connectData( 269 this, 270 "activate", 271 cast(GCallback)&callBackActivate, 272 cast(void*)wrapper, 273 cast(GClosureNotify)&callBackActivateDestroy, 274 connectFlags); 275 return wrapper.handlerId; 276 } 277 278 extern(C) static void callBackActivate(GtkListBoxRow* listboxrowStruct, OnActivateDelegateWrapper wrapper) 279 { 280 wrapper.dlg(wrapper.outer); 281 } 282 283 extern(C) static void callBackActivateDestroy(OnActivateDelegateWrapper wrapper, GClosure* closure) 284 { 285 wrapper.remove(wrapper); 286 } 287 }