1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #include <gtkmm/stockitem.h>
4 #include <gtkmm/private/stockitem_p.h>
9 /* Copyright 1998-2002 The gtkmm Development Team
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free
23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <gtk/gtkstock.h>
31 StockItem::StockItem(const Gtk::StockID& stock_id,
32 const Glib::ustring& label,
33 Gdk::ModifierType modifier,
35 const Glib::ustring& translation_domain)
37 const GtkStockItem stock_item =
39 const_cast<char*>(stock_id.get_c_str()),
40 const_cast<char*>(label.c_str()),
41 static_cast<GdkModifierType>(unsigned(modifier)),
43 (translation_domain.empty()) ? 0 : const_cast<char*>(translation_domain.c_str())
46 gobject_ = gtk_stock_item_copy(&stock_item);
50 bool StockItem::lookup(const Gtk::StockID& stock_id, Gtk::StockItem& item)
52 GtkStockItem item_gobj = { 0, 0, GdkModifierType(0), 0, 0, };
53 const bool known_id = gtk_stock_lookup(stock_id.get_c_str(), &item_gobj);
56 gtk_stock_item_free(item.gobject_);
58 item.gobject_ = (known_id) ? gtk_stock_item_copy(&item_gobj) : 0;
68 } // anonymous namespace
74 Gtk::StockItem wrap(GtkStockItem* object, bool take_copy /* = false */)
76 return Gtk::StockItem(object, take_copy);
86 StockItem::StockItem()
88 gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
91 StockItem::StockItem(const StockItem& src)
93 gobject_ ((src.gobject_) ? gtk_stock_item_copy(src.gobject_) : 0)
96 StockItem::StockItem(GtkStockItem* castitem, bool make_a_copy /* = false */)
100 // It was given to us by a function which has already made a copy for us to keep.
105 // We are probably getting it via direct access to a struct,
106 // so we can not just take it - we have to take a copy of it.
108 gobject_ = gtk_stock_item_copy(castitem);
114 StockItem& StockItem::operator=(const StockItem& src)
116 GtkStockItem *const new_gobject = (src.gobject_) ? gtk_stock_item_copy(src.gobject_) : 0;
119 gtk_stock_item_free(gobject_);
121 gobject_ = new_gobject;
126 StockItem::~StockItem()
129 gtk_stock_item_free(gobject_);
132 GtkStockItem* StockItem::gobj_copy() const
134 return gtk_stock_item_copy(gobject_);
138 StockID StockItem::get_stock_id() const
140 return StockID(gobj()->stock_id);
143 Glib::ustring StockItem::get_label() const
145 return Glib::convert_const_gchar_ptr_to_ustring(gobj()->label);
148 Gdk::ModifierType StockItem::get_modifier() const
150 return ((Gdk::ModifierType)(gobj()->modifier));
153 guint StockItem::get_keyval() const
155 return gobj()->keyval;
158 Glib::ustring StockItem::get_translation_domain() const
160 return Glib::convert_const_gchar_ptr_to_ustring(gobj()->translation_domain);