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 * Conversion parameters: 26 * inFile = gtk3-Stock-Items.html 27 * outPack = gtk 28 * outFile = StockItem 29 * strct = GtkStockItem 30 * realStrct= 31 * ctorStrct= 32 * clss = StockItem 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_stock_item_ 41 * - gtk_stock_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gtkc.paths 49 * - gtkc.Loader 50 * - glib.ListSG 51 * structWrap: 52 * - GSList* -> ListSG 53 * - GtkStockItem* -> StockItem 54 * module aliases: 55 * local aliases: 56 * overrides: 57 */ 58 59 module gtk.StockItem; 60 61 public import gtkc.gtktypes; 62 63 private import gtkc.gtk; 64 private import glib.ConstructionException; 65 private import gobject.ObjectG; 66 67 private import glib.Str; 68 private import gtkc.paths; 69 private import gtkc.Loader; 70 private import glib.ListSG; 71 72 73 74 /** 75 * Stock items represent commonly-used menu or toolbar items such as 76 * "Open" or "Exit". Each stock item is identified by a stock ID; 77 * stock IDs are just strings, but macros such as GTK_STOCK_OPEN are 78 * provided to avoid typing mistakes in the strings. 79 * Applications can register their own stock items in addition to those 80 * built-in to GTK+. 81 * 82 * Each stock ID can be associated with a GtkStockItem, which contains 83 * the user-visible label, keyboard accelerator, and translation domain 84 * of the menu or toolbar item; and/or with an icon stored in a 85 * GtkIconFactory. See GtkIconFactory for 86 * more information on stock icons. The connection between a 87 * GtkStockItem and stock icons is purely conventional (by virtue of 88 * using the same stock ID); it's possible to register a stock item but 89 * no icon, and vice versa. Stock icons may have a RTL variant which gets 90 * used for right-to-left locales. 91 */ 92 public class StockItem 93 { 94 95 /** the main Gtk struct */ 96 protected GtkStockItem* gtkStockItem; 97 98 99 /** Get the main Gtk struct */ 100 public GtkStockItem* getStockItemStruct() 101 { 102 return gtkStockItem; 103 } 104 105 106 /** the main Gtk struct as a void* */ 107 protected void* getStruct() 108 { 109 return cast(void*)gtkStockItem; 110 } 111 112 /** 113 * Sets our main struct and passes it to the parent class 114 */ 115 public this (GtkStockItem* gtkStockItem) 116 { 117 this.gtkStockItem = gtkStockItem; 118 } 119 120 ~this () 121 { 122 if ( Linker.isLoaded(LIBRARY.GTK) && gtkStockItem !is null ) 123 { 124 gtk_stock_item_free(gtkStockItem); 125 } 126 } 127 128 /** 129 */ 130 131 /** 132 * Warning 133 * gtk_stock_add is deprecated and should not be used in newly-written code. 3.10 134 * Registers each of the stock items in items. If an item already 135 * exists with the same stock ID as one of the items, the old item 136 * gets replaced. The stock items are copied, so GTK+ does not hold 137 * any pointer into items and items can be freed. Use 138 * gtk_stock_add_static() if items is persistent and GTK+ need not 139 * copy the array. 140 * Params: 141 * items = a GtkStockItem or array of items. [array length=n_items] 142 */ 143 public static void add(GtkStockItem[] items) 144 { 145 // void gtk_stock_add (const GtkStockItem *items, guint n_items); 146 gtk_stock_add(items.ptr, cast(int) items.length); 147 } 148 149 /** 150 * Warning 151 * gtk_stock_add_static is deprecated and should not be used in newly-written code. 3.10 152 * Same as gtk_stock_add(), but doesn't copy items, so 153 * items must persist until application exit. 154 * Params: 155 * items = a GtkStockItem or array of GtkStockItem. [array length=n_items] 156 */ 157 public static void addStatic(GtkStockItem[] items) 158 { 159 // void gtk_stock_add_static (const GtkStockItem *items, guint n_items); 160 gtk_stock_add_static(items.ptr, cast(int) items.length); 161 } 162 163 /** 164 * Warning 165 * gtk_stock_item_copy is deprecated and should not be used in newly-written code. 3.10 166 * Copies a stock item, mostly useful for language bindings and not in applications. 167 * Returns: a new GtkStockItem 168 */ 169 public StockItem copy() 170 { 171 // GtkStockItem * gtk_stock_item_copy (const GtkStockItem *item); 172 auto p = gtk_stock_item_copy(gtkStockItem); 173 174 if(p is null) 175 { 176 return null; 177 } 178 179 return ObjectG.getDObject!(StockItem)(cast(GtkStockItem*) p); 180 } 181 182 /** 183 * Warning 184 * gtk_stock_item_free is deprecated and should not be used in newly-written code. 3.10 185 * Frees a stock item allocated on the heap, such as one returned by 186 * gtk_stock_item_copy(). Also frees the fields inside the stock item, 187 * if they are not NULL. 188 */ 189 public void free() 190 { 191 // void gtk_stock_item_free (GtkStockItem *item); 192 gtk_stock_item_free(gtkStockItem); 193 } 194 195 /** 196 * Warning 197 * gtk_stock_list_ids is deprecated and should not be used in newly-written code. 3.10 198 * Retrieves a list of all known stock IDs added to a GtkIconFactory 199 * or registered with gtk_stock_add(). The list must be freed with g_slist_free(), 200 * and each string in the list must be freed with g_free(). 201 * Returns: a list of known stock IDs. [element-type utf8][transfer full] 202 */ 203 public static ListSG listIds() 204 { 205 // GSList * gtk_stock_list_ids (void); 206 auto p = gtk_stock_list_ids(); 207 208 if(p is null) 209 { 210 return null; 211 } 212 213 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 214 } 215 216 /** 217 * Warning 218 * gtk_stock_lookup is deprecated and should not be used in newly-written code. 3.10 219 * Fills item with the registered values for stock_id, returning TRUE 220 * if stock_id was known. 221 * Params: 222 * stockId = a stock item name 223 * item = stock item to initialize with values. [out] 224 * Returns: TRUE if item was initialized 225 */ 226 public static int lookup(string stockId, StockItem item) 227 { 228 // gboolean gtk_stock_lookup (const gchar *stock_id, GtkStockItem *item); 229 return gtk_stock_lookup(Str.toStringz(stockId), (item is null) ? null : item.getStockItemStruct()); 230 } 231 232 /** 233 * Warning 234 * gtk_stock_set_translate_func is deprecated and should not be used in newly-written code. 3.10 235 * Sets a function to be used for translating the label of 236 * a stock item. 237 * If no function is registered for a translation domain, 238 * g_dgettext() is used. 239 * The function is used for all stock items whose 240 * translation_domain matches domain. Note that it is possible 241 * to use strings different from the actual gettext translation domain 242 * of your application for this, as long as your GtkTranslateFunc uses 243 * the correct domain when calling dgettext(). This can be useful, e.g. 244 * Since 2.8 245 * Params: 246 * domain = the translation domain for which func shall be used 247 * func = a GtkTranslateFunc 248 * data = data to pass to func 249 * notify = a GDestroyNotify that is called when data is 250 * no longer needed 251 */ 252 public static void setTranslateFunc(string domain, GtkTranslateFunc func, void* data, GDestroyNotify notify) 253 { 254 // void gtk_stock_set_translate_func (const gchar *domain, GtkTranslateFunc func, gpointer data, GDestroyNotify notify); 255 gtk_stock_set_translate_func(Str.toStringz(domain), func, data, notify); 256 } 257 }