Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / stockitem.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <gtkmm/stockitem.h>
4 #include <gtkmm/private/stockitem_p.h>
5
6 // -*- c++ -*-
7 /* $Id$ */
8
9 /* Copyright 1998-2002 The gtkmm Development Team
10  *
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.
15  *
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.
20  *
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.
24  */
25
26 #include <gtk/gtkstock.h>
27  
28 namespace Gtk
29 {
30
31 StockItem::StockItem(const Gtk::StockID&  stock_id,
32                      const Glib::ustring& label,
33                      Gdk::ModifierType    modifier,
34                      unsigned int         keyval,
35                      const Glib::ustring& translation_domain)
36 {
37   const GtkStockItem stock_item =
38   {
39     const_cast<char*>(stock_id.get_c_str()),
40     const_cast<char*>(label.c_str()),
41     static_cast<GdkModifierType>(unsigned(modifier)),
42     keyval,
43     (translation_domain.empty()) ? 0 : const_cast<char*>(translation_domain.c_str())
44   };
45
46   gobject_ = gtk_stock_item_copy(&stock_item);
47 }
48
49 // static
50 bool StockItem::lookup(const Gtk::StockID& stock_id, Gtk::StockItem& item)
51 {
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);
54
55   if(item.gobject_)
56     gtk_stock_item_free(item.gobject_);
57
58   item.gobject_ = (known_id) ? gtk_stock_item_copy(&item_gobj) : 0;
59
60   return known_id;
61 }
62
63 } // namespace Gtk
64
65
66 namespace
67 {
68 } // anonymous namespace
69
70
71 namespace Glib
72 {
73
74 Gtk::StockItem wrap(GtkStockItem* object, bool take_copy /* = false */)
75 {
76   return Gtk::StockItem(object, take_copy);
77 }
78
79 } // namespace Glib
80
81
82 namespace Gtk
83 {
84
85
86 StockItem::StockItem()
87 :
88   gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
89 {}
90
91 StockItem::StockItem(const StockItem& src)
92 :
93   gobject_ ((src.gobject_) ? gtk_stock_item_copy(src.gobject_) : 0)
94 {}
95
96 StockItem::StockItem(GtkStockItem* castitem, bool make_a_copy /* = false */)
97 {
98   if(!make_a_copy)
99   {
100     // It was given to us by a function which has already made a copy for us to keep.
101     gobject_ = castitem;
102   }
103   else
104   {
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.
107     if(castitem)
108       gobject_ = gtk_stock_item_copy(castitem);
109     else
110       gobject_ = 0;
111   }
112 }
113
114 StockItem& StockItem::operator=(const StockItem& src)
115 {
116   GtkStockItem *const new_gobject = (src.gobject_) ? gtk_stock_item_copy(src.gobject_) : 0;
117
118   if(gobject_)
119     gtk_stock_item_free(gobject_);
120
121   gobject_ = new_gobject;
122
123   return *this;
124 }
125
126 StockItem::~StockItem()
127 {
128   if(gobject_)
129     gtk_stock_item_free(gobject_);
130 }
131
132 GtkStockItem* StockItem::gobj_copy() const
133 {
134   return gtk_stock_item_copy(gobject_);
135 }
136
137
138 StockID StockItem::get_stock_id() const
139 {
140   return StockID(gobj()->stock_id);
141 }
142
143 Glib::ustring StockItem::get_label() const
144 {
145   return Glib::convert_const_gchar_ptr_to_ustring(gobj()->label);
146 }
147
148 Gdk::ModifierType StockItem::get_modifier() const
149 {
150   return ((Gdk::ModifierType)(gobj()->modifier));
151 }
152
153 guint StockItem::get_keyval() const
154 {
155   return gobj()->keyval;
156 }
157
158 Glib::ustring StockItem::get_translation_domain() const
159 {
160   return Glib::convert_const_gchar_ptr_to_ustring(gobj()->translation_domain);
161 }
162
163
164 } // namespace Gtk
165
166