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