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.ListItemFactory; 26 27 private import gobject.ObjectG; 28 private import gtk.c.functions; 29 public import gtk.c.types; 30 31 32 /** 33 * A `GtkListItemFactory` creates widgets for the items taken from a `GListModel`. 34 * 35 * This is one of the core concepts of handling list widgets such 36 * as [class@Gtk.ListView] or [class@Gtk.GridView]. 37 * 38 * The `GtkListItemFactory` is tasked with creating widgets for items 39 * taken from the model when the views need them and updating them as 40 * the items displayed by the view change. 41 * 42 * A view is usually only able to display anything after both a factory 43 * and a model have been set on the view. So it is important that you do 44 * not skip this step when setting up your first view. 45 * 46 * Because views do not display the whole list at once but only a few 47 * items, they only need to maintain a few widgets at a time. They will 48 * instruct the `GtkListItemFactory` to create these widgets and bind them 49 * to the items that are currently displayed. 50 * 51 * As the list model changes or the user scrolls to the list, the items will 52 * change and the view will instruct the factory to bind the widgets to those 53 * new items. 54 * 55 * The actual widgets used for displaying those widgets is provided by you. 56 * 57 * When the factory needs widgets created, it will create a `GtkListItem` 58 * and hand it to your code to set up a widget for. This list item will provide 59 * various properties with information about what item to display and provide 60 * you with some opportunities to configure its behavior. See the 61 * [class@Gtk.ListItem] documentation for further details. 62 * 63 * Various implementations of `GtkListItemFactory` exist to allow you different 64 * ways to provide those widgets. The most common implementations are 65 * [class@Gtk.BuilderListItemFactory] which takes a `GtkBuilder` .ui file 66 * and then creates widgets and manages everything automatically from the 67 * information in that file and [class@Gtk.SignalListItemFactory] which allows 68 * you to connect to signals with your own code and retain full control over 69 * how the widgets are setup and managed. 70 * 71 * A `GtkListItemFactory` is supposed to be final - that means its behavior should 72 * not change and the first widget created from it should behave the same way as 73 * the last widget created from it. 74 * If you intend to do changes to the behavior, it is recommended that you create 75 * a new `GtkListItemFactory` which will allow the views to recreate its widgets. 76 * 77 * Once you have chosen your factory and created it, you need to set it 78 * on the view widget you want to use it with, such as via 79 * [method@Gtk.ListView.set_factory]. Reusing factories across different 80 * views is allowed, but very uncommon. 81 */ 82 public class ListItemFactory : ObjectG 83 { 84 /** the main Gtk struct */ 85 protected GtkListItemFactory* gtkListItemFactory; 86 87 /** Get the main Gtk struct */ 88 public GtkListItemFactory* getListItemFactoryStruct(bool transferOwnership = false) 89 { 90 if (transferOwnership) 91 ownedRef = false; 92 return gtkListItemFactory; 93 } 94 95 /** the main Gtk struct as a void* */ 96 protected override void* getStruct() 97 { 98 return cast(void*)gtkListItemFactory; 99 } 100 101 /** 102 * Sets our main struct and passes it to the parent class. 103 */ 104 public this (GtkListItemFactory* gtkListItemFactory, bool ownedRef = false) 105 { 106 this.gtkListItemFactory = gtkListItemFactory; 107 super(cast(GObject*)gtkListItemFactory, ownedRef); 108 } 109 110 111 /** */ 112 public static GType getType() 113 { 114 return gtk_list_item_factory_get_type(); 115 } 116 }