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.TreeListRowSorter;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.Sorter;
30 private import gtk.c.functions;
31 public  import gtk.c.types;
32 
33 
34 /**
35  * `GtkTreeListRowSorter` is a special-purpose sorter that will apply a given
36  * sorter to the levels in a tree.
37  * 
38  * Here is an example for setting up a column view with a tree model and
39  * a `GtkTreeListSorter`:
40  * 
41  * ```c
42  * column_sorter = gtk_column_view_get_sorter (view);
43  * sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
44  * sort_model = gtk_sort_list_model_new (tree_model, sorter);
45  * selection = gtk_single_selection_new (sort_model);
46  * gtk_column_view_set_model (view, G_LIST_MODEL (selection));
47  * ```
48  */
49 public class TreeListRowSorter : Sorter
50 {
51 	/** the main Gtk struct */
52 	protected GtkTreeListRowSorter* gtkTreeListRowSorter;
53 
54 	/** Get the main Gtk struct */
55 	public GtkTreeListRowSorter* getTreeListRowSorterStruct(bool transferOwnership = false)
56 	{
57 		if (transferOwnership)
58 			ownedRef = false;
59 		return gtkTreeListRowSorter;
60 	}
61 
62 	/** the main Gtk struct as a void* */
63 	protected override void* getStruct()
64 	{
65 		return cast(void*)gtkTreeListRowSorter;
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GtkTreeListRowSorter* gtkTreeListRowSorter, bool ownedRef = false)
72 	{
73 		this.gtkTreeListRowSorter = gtkTreeListRowSorter;
74 		super(cast(GtkSorter*)gtkTreeListRowSorter, ownedRef);
75 	}
76 
77 
78 	/** */
79 	public static GType getType()
80 	{
81 		return gtk_tree_list_row_sorter_get_type();
82 	}
83 
84 	/**
85 	 * Create a special-purpose sorter that applies the sorting
86 	 * of @sorter to the levels of a `GtkTreeListModel`.
87 	 *
88 	 * Note that this sorter relies on [property@Gtk.TreeListModel:passthrough]
89 	 * being %FALSE as it can only sort [class@Gtk.TreeListRow]s.
90 	 *
91 	 * Params:
92 	 *     sorter = a `GtkSorter`, or %NULL
93 	 *
94 	 * Returns: a new `GtkTreeListRowSorter`
95 	 *
96 	 * Throws: ConstructionException GTK+ fails to create the object.
97 	 */
98 	public this(Sorter sorter)
99 	{
100 		auto __p = gtk_tree_list_row_sorter_new((sorter is null) ? null : sorter.getSorterStruct());
101 
102 		if(__p is null)
103 		{
104 			throw new ConstructionException("null returned by new");
105 		}
106 
107 		this(cast(GtkTreeListRowSorter*) __p, true);
108 	}
109 
110 	/**
111 	 * Returns the sorter used by @self.
112 	 *
113 	 * Returns: the sorter used
114 	 */
115 	public Sorter getSorter()
116 	{
117 		auto __p = gtk_tree_list_row_sorter_get_sorter(gtkTreeListRowSorter);
118 
119 		if(__p is null)
120 		{
121 			return null;
122 		}
123 
124 		return ObjectG.getDObject!(Sorter)(cast(GtkSorter*) __p);
125 	}
126 
127 	/**
128 	 * Sets the sorter to use for items with the same parent.
129 	 *
130 	 * This sorter will be passed the [property@Gtk.TreeListRow:item] of
131 	 * the tree list rows passed to @self.
132 	 *
133 	 * Params:
134 	 *     sorter = The sorter to use, or %NULL
135 	 */
136 	public void setSorter(Sorter sorter)
137 	{
138 		gtk_tree_list_row_sorter_set_sorter(gtkTreeListRowSorter, (sorter is null) ? null : sorter.getSorterStruct());
139 	}
140 }