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.FlowBoxChild; 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 FlowBoxChild : Bin 39 { 40 /** the main Gtk struct */ 41 protected GtkFlowBoxChild* gtkFlowBoxChild; 42 43 /** Get the main Gtk struct */ 44 public GtkFlowBoxChild* getFlowBoxChildStruct(bool transferOwnership = false) 45 { 46 if (transferOwnership) 47 ownedRef = false; 48 return gtkFlowBoxChild; 49 } 50 51 /** the main Gtk struct as a void* */ 52 protected override void* getStruct() 53 { 54 return cast(void*)gtkFlowBoxChild; 55 } 56 57 protected override void setStruct(GObject* obj) 58 { 59 gtkFlowBoxChild = cast(GtkFlowBoxChild*)obj; 60 super.setStruct(obj); 61 } 62 63 /** 64 * Sets our main struct and passes it to the parent class. 65 */ 66 public this (GtkFlowBoxChild* gtkFlowBoxChild, bool ownedRef = false) 67 { 68 this.gtkFlowBoxChild = gtkFlowBoxChild; 69 super(cast(GtkBin*)gtkFlowBoxChild, ownedRef); 70 } 71 72 73 /** */ 74 public static GType getType() 75 { 76 return gtk_flow_box_child_get_type(); 77 } 78 79 /** 80 * Creates a new #GtkFlowBoxChild, to be used as a child 81 * of a #GtkFlowBox. 82 * 83 * Returns: a new #GtkFlowBoxChild 84 * 85 * Since: 3.12 86 * 87 * Throws: ConstructionException GTK+ fails to create the object. 88 */ 89 public this() 90 { 91 auto p = gtk_flow_box_child_new(); 92 93 if(p is null) 94 { 95 throw new ConstructionException("null returned by new"); 96 } 97 98 this(cast(GtkFlowBoxChild*) p); 99 } 100 101 /** 102 * Marks @child as changed, causing any state that depends on this 103 * to be updated. This affects sorting and filtering. 104 * 105 * Note that calls to this method must be in sync with the data 106 * used for the sorting and filtering functions. For instance, if 107 * the list is mirroring some external data set, and *two* children 108 * changed in the external data set when you call 109 * gtk_flow_box_child_changed() on the first child, the sort function 110 * must only read the new data for the first of the two changed 111 * children, otherwise the resorting of the children will be wrong. 112 * 113 * This generally means that if you don’t fully control the data 114 * model, you have to duplicate the data that affects the sorting 115 * and filtering functions into the widgets themselves. Another 116 * alternative is to call gtk_flow_box_invalidate_sort() on any 117 * model change, but that is more expensive. 118 * 119 * Since: 3.12 120 */ 121 public void changed() 122 { 123 gtk_flow_box_child_changed(gtkFlowBoxChild); 124 } 125 126 /** 127 * Gets the current index of the @child in its #GtkFlowBox container. 128 * 129 * Returns: the index of the @child, or -1 if the @child is not 130 * in a flow box. 131 * 132 * Since: 3.12 133 */ 134 public int getIndex() 135 { 136 return gtk_flow_box_child_get_index(gtkFlowBoxChild); 137 } 138 139 /** 140 * Returns whether the @child is currently selected in its 141 * #GtkFlowBox container. 142 * 143 * Returns: %TRUE if @child is selected 144 * 145 * Since: 3.12 146 */ 147 public bool isSelected() 148 { 149 return gtk_flow_box_child_is_selected(gtkFlowBoxChild) != 0; 150 } 151 152 protected class OnActivateDelegateWrapper 153 { 154 static OnActivateDelegateWrapper[] listeners; 155 void delegate(FlowBoxChild) dlg; 156 gulong handlerId; 157 158 this(void delegate(FlowBoxChild) dlg) 159 { 160 this.dlg = dlg; 161 this.listeners ~= this; 162 } 163 164 void remove(OnActivateDelegateWrapper source) 165 { 166 foreach(index, wrapper; listeners) 167 { 168 if (wrapper.handlerId == source.handlerId) 169 { 170 listeners[index] = null; 171 listeners = std.algorithm.remove(listeners, index); 172 break; 173 } 174 } 175 } 176 } 177 178 /** 179 * The ::activate signal is emitted when the user activates 180 * a child widget in a #GtkFlowBox, either by clicking or 181 * double-clicking, or by using the Space or Enter key. 182 * 183 * While this signal is used as a 184 * [keybinding signal][GtkBindingSignal], 185 * it can be used by applications for their own purposes. 186 */ 187 gulong addOnActivate(void delegate(FlowBoxChild) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 188 { 189 auto wrapper = new OnActivateDelegateWrapper(dlg); 190 wrapper.handlerId = Signals.connectData( 191 this, 192 "activate", 193 cast(GCallback)&callBackActivate, 194 cast(void*)wrapper, 195 cast(GClosureNotify)&callBackActivateDestroy, 196 connectFlags); 197 return wrapper.handlerId; 198 } 199 200 extern(C) static void callBackActivate(GtkFlowBoxChild* flowboxchildStruct, OnActivateDelegateWrapper wrapper) 201 { 202 wrapper.dlg(wrapper.outer); 203 } 204 205 extern(C) static void callBackActivateDestroy(OnActivateDelegateWrapper wrapper, GClosure* closure) 206 { 207 wrapper.remove(wrapper); 208 } 209 }