alternative to assert
[gtkD.git] / src / gtk / StockItem.d
blob67a19734f2036e0b24ea08e2f0434d7bef4a60dc
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gtk-Stock-Items.html
26 * outPack = gtk
27 * outFile = StockItem
28 * strct = GtkStockItem
29 * realStrct=
30 * ctorStrct=
31 * clss = StockItem
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_stock_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gtk.StockItem
47 * - glib.ListSG
48 * structWrap:
49 * - GSList* -> ListSG
50 * - GtkStockItem* -> StockItem
51 * local aliases:
54 module gtk.StockItem;
56 private import gtk.gtktypes;
58 private import lib.gtk;
60 private import glib.Str;
61 private import gtk.StockItem;
62 private import glib.ListSG;
64 /**
65 * Description
66 * Stock items represent commonly-used menu or toolbar items such as
67 * "Open" or "Exit". Each stock item is identified by a stock ID;
68 * stock IDs are just strings, but macros such as GTK_STOCK_OPEN are
69 * provided to avoid typing mistakes in the strings.
70 * Applications can register their own stock items in addition to those
71 * built-in to GTK+.
72 * Each stock ID can be associated with a GtkStockItem, which contains
73 * the user-visible label, keyboard accelerator, and translation domain
74 * of the menu or toolbar item; and/or with an icon stored in a
75 * GtkIconFactory. See GtkIconFactory for
76 * more information on stock icons. The connection between a
77 * GtkStockItem and stock icons is purely conventional (by virtue of
78 * using the same stock ID); it's possible to register a stock item but
79 * no icon, and vice versa. Stock icons may have a RTL variant which gets
80 * used for right-to-left locales.
82 public class StockItem
85 /** the main Gtk struct */
86 protected GtkStockItem* gtkStockItem;
89 public GtkStockItem* getStockItemStruct()
91 return gtkStockItem;
95 /** the main Gtk struct as a void* */
96 protected void* getStruct()
98 return cast(void*)gtkStockItem;
102 * Sets our main struct and passes it to the parent class
104 public this (GtkStockItem* gtkStockItem)
106 this.gtkStockItem = gtkStockItem;
114 * Registers each of the stock items in items. If an item already
115 * exists with the same stock ID as one of the items, the old item
116 * gets replaced. The stock items are copied, so GTK+ does not hold
117 * any pointer into items and items can be freed. Use
118 * gtk_stock_add_static() if items is persistent and GTK+ need not
119 * copy the array.
120 * items:
121 * a GtkStockItem or array of items
122 * n_items:
123 * number of GtkStockItem in items
125 public void add(uint nItems)
127 // void gtk_stock_add (const GtkStockItem *items, guint n_items);
128 gtk_stock_add(gtkStockItem, nItems);
132 * Same as gtk_stock_add(), but doesn't copy items, so
133 * items must persist until application exit.
134 * items:
135 * a GtkStockItem or array of GtkStockItem
136 * n_items:
137 * number of items
139 public void addStatic(uint nItems)
141 // void gtk_stock_add_static (const GtkStockItem *items, guint n_items);
142 gtk_stock_add_static(gtkStockItem, nItems);
146 * Copies a stock item, mostly useful for language bindings and not in applications.
147 * item:
148 * a GtkStockItem
149 * Returns:
150 * a new GtkStockItem
152 public StockItem itemCopy()
154 // GtkStockItem* gtk_stock_item_copy (const GtkStockItem *item);
155 return new StockItem( gtk_stock_item_copy(gtkStockItem) );
159 * Frees a stock item allocated on the heap, such as one returned by
160 * gtk_stock_item_copy(). Also frees the fields inside the stock item,
161 * if they are not NULL.
162 * item:
163 * a GtkStockItem
165 public void itemFree()
167 // void gtk_stock_item_free (GtkStockItem *item);
168 gtk_stock_item_free(gtkStockItem);
172 * Retrieves a list of all known stock IDs added to a GtkIconFactory
173 * or registered with gtk_stock_add(). The list must be freed with g_slist_free(),
174 * and each string in the list must be freed with g_free().
175 * Returns:
176 * a list of known stock IDs
178 public static ListSG listIds()
180 // GSList* gtk_stock_list_ids (void);
181 return new ListSG( gtk_stock_list_ids() );
185 * Fills item with the registered values for stock_id, returning TRUE
186 * if stock_id was known.
187 * stock_id:
188 * a stock item name
189 * item:
190 * stock item to initialize with values
191 * Returns:
192 * TRUE if item was initialized
194 public static int lookup(char[] stockId, StockItem item)
196 // gboolean gtk_stock_lookup (const gchar *stock_id, GtkStockItem *item);
197 return gtk_stock_lookup(Str.toStringz(stockId), (item is null) ? null : item.getStockItemStruct());
201 * Sets a function to be used for translating the label of
202 * a stock item.
203 * If no function is registered for a translation domain,
204 * dgettext() is used.
205 * domain:
206 * the translation domain for which func shall be used
207 * func:
208 * a GtkTranslateFunc
209 * data:
210 * data to pass to func
211 * notify:
212 * a GtkDestroyNotify that is called when data is
213 * no longer needed
214 * Since 2.8
216 public static void setTranslateFunc(char[] domain, GtkTranslateFunc func, void* data, GtkDestroyNotify notify)
218 // void gtk_stock_set_translate_func (const gchar *domain, GtkTranslateFunc func, gpointer data, GtkDestroyNotify notify);
219 gtk_stock_set_translate_func(Str.toStringz(domain), func, data, notify);