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.CustomSorter; 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 * `GtkCustomSorter` is a `GtkSorter` implementation that sorts via a callback 36 * function. 37 */ 38 public class CustomSorter : Sorter 39 { 40 /** the main Gtk struct */ 41 protected GtkCustomSorter* gtkCustomSorter; 42 43 /** Get the main Gtk struct */ 44 public GtkCustomSorter* getCustomSorterStruct(bool transferOwnership = false) 45 { 46 if (transferOwnership) 47 ownedRef = false; 48 return gtkCustomSorter; 49 } 50 51 /** the main Gtk struct as a void* */ 52 protected override void* getStruct() 53 { 54 return cast(void*)gtkCustomSorter; 55 } 56 57 /** 58 * Sets our main struct and passes it to the parent class. 59 */ 60 public this (GtkCustomSorter* gtkCustomSorter, bool ownedRef = false) 61 { 62 this.gtkCustomSorter = gtkCustomSorter; 63 super(cast(GtkSorter*)gtkCustomSorter, ownedRef); 64 } 65 66 67 /** */ 68 public static GType getType() 69 { 70 return gtk_custom_sorter_get_type(); 71 } 72 73 /** 74 * Creates a new `GtkSorter` that works by calling 75 * @sort_func to compare items. 76 * 77 * If @sort_func is %NULL, all items are considered equal. 78 * 79 * Params: 80 * sortFunc = the `GCompareDataFunc` to use for sorting 81 * userData = user data to pass to @sort_func 82 * userDestroy = destroy notify for @user_data 83 * 84 * Returns: a new `GtkCustomSorter` 85 * 86 * Throws: ConstructionException GTK+ fails to create the object. 87 */ 88 public this(GCompareDataFunc sortFunc, void* userData, GDestroyNotify userDestroy) 89 { 90 auto __p = gtk_custom_sorter_new(sortFunc, userData, userDestroy); 91 92 if(__p is null) 93 { 94 throw new ConstructionException("null returned by new"); 95 } 96 97 this(cast(GtkCustomSorter*) __p, true); 98 } 99 100 /** 101 * Sets (or unsets) the function used for sorting items. 102 * 103 * If @sort_func is %NULL, all items are considered equal. 104 * 105 * If the sort func changes its sorting behavior, 106 * gtk_sorter_changed() needs to be called. 107 * 108 * If a previous function was set, its @user_destroy will be 109 * called now. 110 * 111 * Params: 112 * sortFunc = function to sort items 113 * userData = user data to pass to @match_func 114 * userDestroy = destroy notify for @user_data 115 */ 116 public void setSortFunc(GCompareDataFunc sortFunc, void* userData, GDestroyNotify userDestroy) 117 { 118 gtk_custom_sorter_set_sort_func(gtkCustomSorter, sortFunc, userData, userDestroy); 119 } 120 }