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