alternative to assert
[gtkD.git] / gtkD / src / gtk / StockItem.d
blob01bd84fcae1134d8452627c4515f42710a9e0525
1 /*
2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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 * module aliases:
52 * local aliases:
55 module gtk.StockItem;
57 version(noAssert)
59 version(Tango)
61 import tango.io.Stdout; // use the tango loging?
65 private import gtkc.gtktypes;
67 private import gtkc.gtk;
70 private import glib.Str;
71 private import gtk.StockItem;
72 private import glib.ListSG;
77 /**
78 * Description
79 * Stock items represent commonly-used menu or toolbar items such as
80 * "Open" or "Exit". Each stock item is identified by a stock ID;
81 * stock IDs are just strings, but macros such as GTK_STOCK_OPEN are
82 * provided to avoid typing mistakes in the strings.
83 * Applications can register their own stock items in addition to those
84 * built-in to GTK+.
85 * Each stock ID can be associated with a GtkStockItem, which contains
86 * the user-visible label, keyboard accelerator, and translation domain
87 * of the menu or toolbar item; and/or with an icon stored in a
88 * GtkIconFactory. See GtkIconFactory for
89 * more information on stock icons. The connection between a
90 * GtkStockItem and stock icons is purely conventional (by virtue of
91 * using the same stock ID); it's possible to register a stock item but
92 * no icon, and vice versa. Stock icons may have a RTL variant which gets
93 * used for right-to-left locales.
95 public class StockItem
98 /** the main Gtk struct */
99 protected GtkStockItem* gtkStockItem;
102 public GtkStockItem* getStockItemStruct()
104 return gtkStockItem;
108 /** the main Gtk struct as a void* */
109 protected void* getStruct()
111 return cast(void*)gtkStockItem;
115 * Sets our main struct and passes it to the parent class
117 public this (GtkStockItem* gtkStockItem)
119 version(noAssert)
121 if ( gtkStockItem is null )
123 int zero = 0;
124 version(Tango)
126 Stdout("struct gtkStockItem is null on constructor").newline;
128 else
130 printf("struct gtkStockItem is null on constructor");
132 zero = zero / zero;
135 else
137 assert(gtkStockItem !is null, "struct gtkStockItem is null on constructor");
139 this.gtkStockItem = gtkStockItem;
147 * Registers each of the stock items in items. If an item already
148 * exists with the same stock ID as one of the items, the old item
149 * gets replaced. The stock items are copied, so GTK+ does not hold
150 * any pointer into items and items can be freed. Use
151 * gtk_stock_add_static() if items is persistent and GTK+ need not
152 * copy the array.
153 * items:
154 * a GtkStockItem or array of items
155 * n_items:
156 * number of GtkStockItem in items
158 public void add(uint nItems)
160 // void gtk_stock_add (const GtkStockItem *items, guint n_items);
161 gtk_stock_add(gtkStockItem, nItems);
165 * Same as gtk_stock_add(), but doesn't copy items, so
166 * items must persist until application exit.
167 * items:
168 * a GtkStockItem or array of GtkStockItem
169 * n_items:
170 * number of items
172 public void addStatic(uint nItems)
174 // void gtk_stock_add_static (const GtkStockItem *items, guint n_items);
175 gtk_stock_add_static(gtkStockItem, nItems);
179 * Copies a stock item, mostly useful for language bindings and not in applications.
180 * item:
181 * a GtkStockItem
182 * Returns:
183 * a new GtkStockItem
185 public StockItem itemCopy()
187 // GtkStockItem* gtk_stock_item_copy (const GtkStockItem *item);
188 return new StockItem( gtk_stock_item_copy(gtkStockItem) );
192 * Frees a stock item allocated on the heap, such as one returned by
193 * gtk_stock_item_copy(). Also frees the fields inside the stock item,
194 * if they are not NULL.
195 * item:
196 * a GtkStockItem
198 public void itemFree()
200 // void gtk_stock_item_free (GtkStockItem *item);
201 gtk_stock_item_free(gtkStockItem);
205 * Retrieves a list of all known stock IDs added to a GtkIconFactory
206 * or registered with gtk_stock_add(). The list must be freed with g_slist_free(),
207 * and each string in the list must be freed with g_free().
208 * Returns:
209 * a list of known stock IDs
211 public static ListSG listIds()
213 // GSList* gtk_stock_list_ids (void);
214 return new ListSG( gtk_stock_list_ids() );
218 * Fills item with the registered values for stock_id, returning TRUE
219 * if stock_id was known.
220 * stock_id:
221 * a stock item name
222 * item:
223 * stock item to initialize with values
224 * Returns:
225 * TRUE if item was initialized
227 public static int lookup(char[] stockId, StockItem item)
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());
234 * Sets a function to be used for translating the label of
235 * a stock item.
236 * If no function is registered for a translation domain,
237 * dgettext() is used.
238 * domain:
239 * the translation domain for which func shall be used
240 * func:
241 * a GtkTranslateFunc
242 * data:
243 * data to pass to func
244 * notify:
245 * a GtkDestroyNotify that is called when data is
246 * no longer needed
247 * Since 2.8
249 public static void setTranslateFunc(char[] domain, GtkTranslateFunc func, void* data, GtkDestroyNotify notify)
251 // void gtk_stock_set_translate_func (const gchar *domain, GtkTranslateFunc func, gpointer data, GtkDestroyNotify notify);
252 gtk_stock_set_translate_func(Str.toStringz(domain), func, data, notify);