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.MultiSorter;
26 
27 private import gio.ListModelIF;
28 private import gio.ListModelT;
29 private import glib.ConstructionException;
30 private import gobject.ObjectG;
31 private import gtk.BuildableIF;
32 private import gtk.BuildableT;
33 private import gtk.Sorter;
34 private import gtk.c.functions;
35 public  import gtk.c.types;
36 
37 
38 /**
39  * `GtkMultiSorter` combines multiple sorters by trying them
40  * in turn.
41  * 
42  * If the first sorter compares two items as equal,
43  * the second is tried next, and so on.
44  */
45 public class MultiSorter : Sorter, ListModelIF, BuildableIF
46 {
47 	/** the main Gtk struct */
48 	protected GtkMultiSorter* gtkMultiSorter;
49 
50 	/** Get the main Gtk struct */
51 	public GtkMultiSorter* getMultiSorterStruct(bool transferOwnership = false)
52 	{
53 		if (transferOwnership)
54 			ownedRef = false;
55 		return gtkMultiSorter;
56 	}
57 
58 	/** the main Gtk struct as a void* */
59 	protected override void* getStruct()
60 	{
61 		return cast(void*)gtkMultiSorter;
62 	}
63 
64 	/**
65 	 * Sets our main struct and passes it to the parent class.
66 	 */
67 	public this (GtkMultiSorter* gtkMultiSorter, bool ownedRef = false)
68 	{
69 		this.gtkMultiSorter = gtkMultiSorter;
70 		super(cast(GtkSorter*)gtkMultiSorter, ownedRef);
71 	}
72 
73 	// add the ListModel capabilities
74 	mixin ListModelT!(GtkMultiSorter);
75 
76 	// add the Buildable capabilities
77 	mixin BuildableT!(GtkMultiSorter);
78 
79 
80 	/** */
81 	public static GType getType()
82 	{
83 		return gtk_multi_sorter_get_type();
84 	}
85 
86 	/**
87 	 * Creates a new multi sorter.
88 	 *
89 	 * This sorter compares items by trying each of the sorters
90 	 * in turn, until one returns non-zero. In particular, if
91 	 * no sorter has been added to it, it will always compare
92 	 * items as equal.
93 	 *
94 	 * Returns: a new `GtkMultiSorter`
95 	 *
96 	 * Throws: ConstructionException GTK+ fails to create the object.
97 	 */
98 	public this()
99 	{
100 		auto __p = gtk_multi_sorter_new();
101 
102 		if(__p is null)
103 		{
104 			throw new ConstructionException("null returned by new");
105 		}
106 
107 		this(cast(GtkMultiSorter*) __p, true);
108 	}
109 
110 	/**
111 	 * Add @sorter to @self to use for sorting at the end.
112 	 *
113 	 * @self will consult all existing sorters before it will
114 	 * sort with the given @sorter.
115 	 *
116 	 * Params:
117 	 *     sorter = a sorter to add
118 	 */
119 	public void append(Sorter sorter)
120 	{
121 		gtk_multi_sorter_append(gtkMultiSorter, (sorter is null) ? null : sorter.getSorterStruct());
122 	}
123 
124 	/**
125 	 * Removes the sorter at the given @position from the list of sorter
126 	 * used by @self.
127 	 *
128 	 * If @position is larger than the number of sorters, nothing happens.
129 	 *
130 	 * Params:
131 	 *     position = position of sorter to remove
132 	 */
133 	public void remove(uint position)
134 	{
135 		gtk_multi_sorter_remove(gtkMultiSorter, position);
136 	}
137 }