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.DockItemT; 20 21 public import dazzle.DockItemIF; 22 public import dazzle.DockManager; 23 public import dazzle.c.functions; 24 public import dazzle.c.types; 25 public import gio.IconIF; 26 public import glib.Str; 27 public import gobject.ObjectG; 28 public import gobject.Signals; 29 public import std.algorithm; 30 31 32 /** */ 33 public template DockItemT(TStruct) 34 { 35 /** Get the main Gtk struct */ 36 public DzlDockItem* getDockItemStruct(bool transferOwnership = false) 37 { 38 if (transferOwnership) 39 ownedRef = false; 40 return cast(DzlDockItem*)getStruct(); 41 } 42 43 static if (is(TStruct == DzlDockWindow)) { 44 /** 45 * Gets the icon_name for the #DzlDockItem. 46 * 47 * Generally, you want to use a #DzlDockWidget which has a "icon-name" property 48 * you can set. But this can be helpful for integration of various container 49 * widgets. 50 * 51 * Returns: A newly allocated string or %NULL. 52 */ 53 public override string getIconName() 54 { 55 auto retStr = dzl_dock_item_get_icon_name(getDockItemStruct()); 56 57 scope(exit) Str.freeString(retStr); 58 return Str.toString(retStr); 59 } 60 61 /** 62 * Gets the title for the #DzlDockItem. 63 * 64 * Generally, you want to use a #DzlDockWidget which has a "title" property you 65 * can set. But this can be helpful for integration of various container 66 * widgets. 67 * 68 * Returns: A newly allocated string or %NULL. 69 */ 70 public override string getTitle() 71 { 72 auto retStr = dzl_dock_item_get_title(getDockItemStruct()); 73 74 scope(exit) Str.freeString(retStr); 75 return Str.toString(retStr); 76 } 77 78 /** 79 * This widget will walk the widget hierarchy to ensure that the 80 * dock item is visible to the user. 81 */ 82 public override void present() 83 { 84 dzl_dock_item_present(getDockItemStruct()); 85 } 86 } else { 87 /** 88 * Gets the icon_name for the #DzlDockItem. 89 * 90 * Generally, you want to use a #DzlDockWidget which has a "icon-name" property 91 * you can set. But this can be helpful for integration of various container 92 * widgets. 93 * 94 * Returns: A newly allocated string or %NULL. 95 */ 96 public string getIconName() 97 { 98 auto retStr = dzl_dock_item_get_icon_name(getDockItemStruct()); 99 100 scope(exit) Str.freeString(retStr); 101 return Str.toString(retStr); 102 } 103 104 /** 105 * Gets the title for the #DzlDockItem. 106 * 107 * Generally, you want to use a #DzlDockWidget which has a "title" property you 108 * can set. But this can be helpful for integration of various container 109 * widgets. 110 * 111 * Returns: A newly allocated string or %NULL. 112 */ 113 public string getTitle() 114 { 115 auto retStr = dzl_dock_item_get_title(getDockItemStruct()); 116 117 scope(exit) Str.freeString(retStr); 118 return Str.toString(retStr); 119 } 120 121 /** 122 * This widget will walk the widget hierarchy to ensure that the 123 * dock item is visible to the user. 124 */ 125 public void present() 126 { 127 dzl_dock_item_present(getDockItemStruct()); 128 } 129 } 130 131 /** 132 */ 133 134 /** */ 135 public bool adopt(DockItemIF child) 136 { 137 return dzl_dock_item_adopt(getDockItemStruct(), (child is null) ? null : child.getDockItemStruct()) != 0; 138 } 139 140 /** 141 * This function will request that the dock item close itself. 142 * 143 * Returns: %TRUE if the dock item was closed 144 */ 145 public bool close() 146 { 147 return dzl_dock_item_close(getDockItemStruct()) != 0; 148 } 149 150 /** 151 * Emits the #DzlDockItem::presented signal. 152 * 153 * Containers should emit this when their descendant has been presented as the 154 * current visible child. This allows dock items to do lazy initialization of 155 * content once the widgetry is visible to the user. 156 * 157 * Currently, this is best effort, as there are a number of situations that 158 * make covering all cases problematic. 159 * 160 * Since: 3.30 161 */ 162 public void emitPresented() 163 { 164 dzl_dock_item_emit_presented(getDockItemStruct()); 165 } 166 167 /** 168 * If this dock item can be closed by the user, this virtual function should be 169 * implemented by the panel and return %TRUE. 170 * 171 * Returns: %TRUE if the dock item can be closed by the user, otherwise %FALSE. 172 */ 173 public bool getCanClose() 174 { 175 return dzl_dock_item_get_can_close(getDockItemStruct()) != 0; 176 } 177 178 /** 179 * Returns: %TRUE if the widget can be minimized. 180 */ 181 public bool getCanMinimize() 182 { 183 return dzl_dock_item_get_can_minimize(getDockItemStruct()) != 0; 184 } 185 186 /** */ 187 public bool getChildVisible(DockItemIF child) 188 { 189 return dzl_dock_item_get_child_visible(getDockItemStruct(), (child is null) ? null : child.getDockItemStruct()) != 0; 190 } 191 192 /** 193 * Gets the dock manager for this dock item. 194 * 195 * Returns: A #DzlDockmanager. 196 */ 197 public DockManager getManager() 198 { 199 auto p = dzl_dock_item_get_manager(getDockItemStruct()); 200 201 if(p is null) 202 { 203 return null; 204 } 205 206 return ObjectG.getDObject!(DockManager)(cast(DzlDockManager*) p); 207 } 208 209 /** 210 * Gets the parent #DzlDockItem, or %NULL. 211 * 212 * Returns: A #DzlDockItem or %NULL. 213 */ 214 public DockItemIF getParent() 215 { 216 auto p = dzl_dock_item_get_parent(getDockItemStruct()); 217 218 if(p is null) 219 { 220 return null; 221 } 222 223 return ObjectG.getDObject!(DockItemIF)(cast(DzlDockItem*) p); 224 } 225 226 /** */ 227 public bool hasWidgets() 228 { 229 return dzl_dock_item_has_widgets(getDockItemStruct()) != 0; 230 } 231 232 /** 233 * This requests that @self minimize @child if it knows how. 234 * 235 * If not, it should suggest the gravity for @child if it knows how to 236 * determine that. For example, a #DzlDockBin might know if the widget was part 237 * of the right panel and therefore may set @position to %GTK_POS_RIGHT. 238 * 239 * Params: 240 * child = A #DzlDockItem that is a child of @self 241 * position = A location for a #GtkPositionType 242 * 243 * Returns: %TRUE if @child was minimized. Otherwise %FALSE and @position 244 * may be updated to a suggested position. 245 */ 246 public bool minimize(DockItemIF child, ref GtkPositionType position) 247 { 248 return dzl_dock_item_minimize(getDockItemStruct(), (child is null) ? null : child.getDockItemStruct(), &position) != 0; 249 } 250 251 /** 252 * Emits the "needs-attention" signal. 253 * 254 * Since: 3.34 255 */ 256 public void needsAttention() 257 { 258 dzl_dock_item_needs_attention(getDockItemStruct()); 259 } 260 261 /** */ 262 public void presentChild(DockItemIF child) 263 { 264 dzl_dock_item_present_child(getDockItemStruct(), (child is null) ? null : child.getDockItemStruct()); 265 } 266 267 /** 268 * Gets a #GIcon for the dock item, if any has been set. 269 * 270 * If an icon-name has been set, a new #GIcon for that icon-name 271 * may be returned. 272 * 273 * Returns: a #GIcon or %NULL 274 * 275 * Since: 3.34 276 */ 277 public IconIF refGicon() 278 { 279 auto p = dzl_dock_item_ref_gicon(getDockItemStruct()); 280 281 if(p is null) 282 { 283 return null; 284 } 285 286 return ObjectG.getDObject!(IconIF)(cast(GIcon*) p, true); 287 } 288 289 /** 290 * This virtual method should remove @child from @self if the 291 * dock item knows how to do so. For example, the #DzlDockStack 292 * will remove @child from it's internal #GtkStack. 293 * 294 * After the virtual function has been executed, child tracking 295 * will be removed so that #DzlDockItem implementations do not 296 * need to implement themselves. 297 */ 298 public void release(DockItemIF child) 299 { 300 dzl_dock_item_release(getDockItemStruct(), (child is null) ? null : child.getDockItemStruct()); 301 } 302 303 /** */ 304 public void setChildVisible(DockItemIF child, bool childVisible) 305 { 306 dzl_dock_item_set_child_visible(getDockItemStruct(), (child is null) ? null : child.getDockItemStruct(), childVisible); 307 } 308 309 /** 310 * Sets the dock manager for this #DzlDockItem. 311 * 312 * Params: 313 * manager = A #DzlDockManager 314 */ 315 public void setManager(DockManager manager) 316 { 317 dzl_dock_item_set_manager(getDockItemStruct(), (manager is null) ? null : manager.getDockManagerStruct()); 318 } 319 320 /** */ 321 public void updateVisibility() 322 { 323 dzl_dock_item_update_visibility(getDockItemStruct()); 324 } 325 326 /** */ 327 gulong addOnManagerSet(void delegate(DockManager, DockItemIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 328 { 329 return Signals.connect(this, "manager-set", dlg, connectFlags ^ ConnectFlags.SWAPPED); 330 } 331 332 /** */ 333 gulong addOnNeedsAttention(void delegate(DockItemIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 334 { 335 return Signals.connect(this, "needs-attention", dlg, connectFlags ^ ConnectFlags.SWAPPED); 336 } 337 338 /** */ 339 gulong addOnPresented(void delegate(DockItemIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 340 { 341 return Signals.connect(this, "presented", dlg, connectFlags ^ ConnectFlags.SWAPPED); 342 } 343 }