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