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 change21 // find conversion definition on APILookup.txt22 // implement new conversion functionalities on the wrap.utils pakage23 24 25 modulegtk.NumericSorter;
26 27 privateimportglib.ConstructionException;
28 privateimportgobject.ObjectG;
29 privateimportgtk.Expression;
30 privateimportgtk.Sorter;
31 privateimportgtk.c.functions;
32 publicimportgtk.c.types;
33 34 35 /**
36 * `GtkNumericSorter` is a `GtkSorter` that compares numbers.
37 *
38 * To obtain the numbers to compare, this sorter evaluates a
39 * [class@Gtk.Expression].
40 */41 publicclassNumericSorter : Sorter42 {
43 /** the main Gtk struct */44 protectedGtkNumericSorter* gtkNumericSorter;
45 46 /** Get the main Gtk struct */47 publicGtkNumericSorter* getNumericSorterStruct(booltransferOwnership = false)
48 {
49 if (transferOwnership)
50 ownedRef = false;
51 returngtkNumericSorter;
52 }
53 54 /** the main Gtk struct as a void* */55 protectedoverridevoid* getStruct()
56 {
57 returncast(void*)gtkNumericSorter;
58 }
59 60 /**
61 * Sets our main struct and passes it to the parent class.
62 */63 publicthis (GtkNumericSorter* gtkNumericSorter, boolownedRef = false)
64 {
65 this.gtkNumericSorter = gtkNumericSorter;
66 super(cast(GtkSorter*)gtkNumericSorter, ownedRef);
67 }
68 69 70 /** */71 publicstaticGTypegetType()
72 {
73 returngtk_numeric_sorter_get_type();
74 }
75 76 /**
77 * Creates a new numeric sorter using the given @expression.
78 *
79 * Smaller numbers will be sorted first. You can call
80 * [method@Gtk.NumericSorter.set_sort_order] to change this.
81 *
82 * Params:
83 * expression = The expression to evaluate
84 *
85 * Returns: a new `GtkNumericSorter`
86 *
87 * Throws: ConstructionException GTK+ fails to create the object.
88 */89 publicthis(Expressionexpression)
90 {
91 auto__p = gtk_numeric_sorter_new((expressionisnull) ? null : expression.getExpressionStruct(true));
92 93 if(__pisnull)
94 {
95 thrownewConstructionException("null returned by new");
96 }
97 98 this(cast(GtkNumericSorter*) __p, true);
99 }
100 101 /**
102 * Gets the expression that is evaluated to obtain numbers from items.
103 *
104 * Returns: a `GtkExpression`, or %NULL
105 */106 publicExpressiongetExpression()
107 {
108 auto__p = gtk_numeric_sorter_get_expression(gtkNumericSorter);
109 110 if(__pisnull)
111 {
112 returnnull;
113 }
114 115 returnObjectG.getDObject!(Expression)(cast(GtkExpression*) __p);
116 }
117 118 /**
119 * Gets whether this sorter will sort smaller numbers first.
120 *
121 * Returns: the order of the numbers
122 */123 publicGtkSortTypegetSortOrder()
124 {
125 returngtk_numeric_sorter_get_sort_order(gtkNumericSorter);
126 }
127 128 /**
129 * Sets the expression that is evaluated to obtain numbers from items.
130 *
131 * Unless an expression is set on @self, the sorter will always
132 * compare items as invalid.
133 *
134 * The expression must have a return type that can be compared
135 * numerically, such as %G_TYPE_INT or %G_TYPE_DOUBLE.
136 *
137 * Params:
138 * expression = a `GtkExpression`, or %NULL
139 */140 publicvoidsetExpression(Expressionexpression)
141 {
142 gtk_numeric_sorter_set_expression(gtkNumericSorter, (expressionisnull) ? null : expression.getExpressionStruct());
143 }
144 145 /**
146 * Sets whether to sort smaller numbers before larger ones.
147 *
148 * Params:
149 * sortOrder = whether to sort smaller numbers first
150 */151 publicvoidsetSortOrder(GtkSortTypesortOrder)
152 {
153 gtk_numeric_sorter_set_sort_order(gtkNumericSorter, sortOrder);
154 }
155 }