MIDI branch becomes trunk
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / icontheme.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <gtkmm/icontheme.h>
4 #include <gtkmm/private/icontheme_p.h>
5
6 /* Copyright 2003 The gtkmm Development Team
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #include <gtk/gtkicontheme.h>
24 #include <gtk/gtktypebuiltins.h> //For gtk_icon_theme_error_get_type().
25
26
27 namespace Gtk
28 {
29
30 void IconTheme::set_search_path(const Glib::ArrayHandle<Glib::ustring>& path)
31 {
32   gtk_icon_theme_set_search_path(gobj(), const_cast<const char**>(path.data()), path.size());
33 }
34
35 Glib::ArrayHandle<Glib::ustring> IconTheme::get_search_path() const
36 {
37   int* temp_int = 0;
38   gchar*** temp_path = 0;
39   gtk_icon_theme_get_search_path(const_cast<GtkIconTheme*>(gobj()), temp_path, temp_int);
40   return Glib::ArrayHandle<Glib::ustring>((const char**)(*temp_path), *temp_int, Glib::OWNERSHIP_SHALLOW);
41 }
42
43 Glib::ArrayHandle<int> IconTheme::get_icon_sizes(const Glib::ustring& icon_name) const
44 {
45   int* pArrayInts = gtk_icon_theme_get_icon_sizes(const_cast<GtkIconTheme*>(gobj()), icon_name.c_str());
46   
47   //pArrayInts is null-terminated.
48   return Glib::ArrayHandle<int>(pArrayInts, Glib::OWNERSHIP_SHALLOW); //TODO: I'm not sure about the ownership. murrayc.
49 }
50   
51
52 } // namespace Gtk
53
54
55 namespace
56 {
57
58 const Glib::SignalProxyInfo IconTheme_signal_changed_info =
59 {
60   "changed",
61   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
62   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
63 };
64
65 } // anonymous namespace
66
67
68 Gtk::IconThemeError::IconThemeError(Gtk::IconThemeError::Code error_code, const Glib::ustring& error_message)
69 :
70   Glib::Error (GTK_ICON_THEME_ERROR, error_code, error_message)
71 {}
72
73 Gtk::IconThemeError::IconThemeError(GError* gobject)
74 :
75   Glib::Error (gobject)
76 {}
77
78 Gtk::IconThemeError::Code Gtk::IconThemeError::code() const
79 {
80   return static_cast<Code>(Glib::Error::code());
81 }
82
83 void Gtk::IconThemeError::throw_func(GError* gobject)
84 {
85   throw Gtk::IconThemeError(gobject);
86 }
87
88 // static
89 GType Glib::Value<Gtk::IconThemeError::Code>::value_type()
90 {
91   return gtk_icon_theme_error_get_type();
92 }
93
94
95 namespace Glib
96 {
97
98 Glib::RefPtr<Gtk::IconTheme> wrap(GtkIconTheme* object, bool take_copy)
99 {
100   return Glib::RefPtr<Gtk::IconTheme>( dynamic_cast<Gtk::IconTheme*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
101   //We use dynamic_cast<> in case of multiple inheritance.
102 }
103
104 } /* namespace Glib */
105
106
107 namespace Gtk
108 {
109
110
111 /* The *_Class implementation: */
112
113 const Glib::Class& IconTheme_Class::init()
114 {
115   if(!gtype_) // create the GType if necessary
116   {
117     // Glib::Class has to know the class init function to clone custom types.
118     class_init_func_ = &IconTheme_Class::class_init_function;
119
120     // This is actually just optimized away, apparently with no harm.
121     // Make sure that the parent type has been created.
122     //CppClassParent::CppObjectType::get_type();
123
124     // Create the wrapper type, with the same class/instance size as the base type.
125     register_derived_type(gtk_icon_theme_get_type());
126
127     // Add derived versions of interfaces, if the C type implements any interfaces:
128   }
129
130   return *this;
131 }
132
133 void IconTheme_Class::class_init_function(void* g_class, void* class_data)
134 {
135   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
136   CppClassParent::class_init_function(klass, class_data);
137
138   klass->changed = &changed_callback;
139 }
140
141
142 void IconTheme_Class::changed_callback(GtkIconTheme* self)
143 {
144   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
145       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
146
147   // Non-gtkmmproc-generated custom classes implicitly call the default
148   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
149   // generated classes can use this optimisation, which avoids the unnecessary
150   // parameter conversions if there is no possibility of the virtual function
151   // being overridden:
152   if(obj && obj->is_derived_())
153   {
154     try // Trap C++ exceptions which would normally be lost because this is a C callback.
155     {
156       // Call the virtual member method, which derived classes might override.
157       obj->on_changed();
158     }
159     catch(...)
160     {
161       Glib::exception_handlers_invoke();
162     }
163   }
164   else
165   {
166     BaseClassType *const base = static_cast<BaseClassType*>(
167         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
168     );
169
170     // Call the original underlying C function:
171     if(base && base->changed)
172       (*base->changed)(self);
173   }
174 }
175
176
177 Glib::ObjectBase* IconTheme_Class::wrap_new(GObject* object)
178 {
179   return new IconTheme((GtkIconTheme*)object);
180 }
181
182
183 /* The implementation: */
184
185 GtkIconTheme* IconTheme::gobj_copy()
186 {
187   reference();
188   return gobj();
189 }
190
191 IconTheme::IconTheme(const Glib::ConstructParams& construct_params)
192 :
193   Glib::Object(construct_params)
194 {}
195
196 IconTheme::IconTheme(GtkIconTheme* castitem)
197 :
198   Glib::Object((GObject*)(castitem))
199 {}
200
201 IconTheme::~IconTheme()
202 {}
203
204
205 IconTheme::CppClassType IconTheme::icontheme_class_; // initialize static member
206
207 GType IconTheme::get_type()
208 {
209   return icontheme_class_.init().get_type();
210 }
211
212 GType IconTheme::get_base_type()
213 {
214   return gtk_icon_theme_get_type();
215 }
216
217
218 IconTheme::IconTheme()
219 :
220   Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
221   Glib::Object(Glib::ConstructParams(icontheme_class_.init()))
222 {
223   }
224
225 Glib::RefPtr<IconTheme> IconTheme::create()
226 {
227   return Glib::RefPtr<IconTheme>( new IconTheme() );
228 }
229 Glib::RefPtr<IconTheme> IconTheme::get_default()
230 {
231
232   Glib::RefPtr<IconTheme> retvalue = Glib::wrap(gtk_icon_theme_get_default());
233
234   if(retvalue)
235     retvalue->reference(); //The function does not do a ref for us.
236   return retvalue;
237 }
238
239 Glib::RefPtr<IconTheme> IconTheme::get_for_screen(const Glib::RefPtr<Gdk::Screen>& screen)
240 {
241
242   Glib::RefPtr<IconTheme> retvalue = Glib::wrap(gtk_icon_theme_get_for_screen(Glib::unwrap(screen)));
243
244   if(retvalue)
245     retvalue->reference(); //The function does not do a ref for us.
246   return retvalue;
247 }
248
249 void IconTheme::set_screen(const Glib::RefPtr<Gdk::Screen>& screen)
250 {
251   gtk_icon_theme_set_screen(gobj(), Glib::unwrap(screen));
252 }
253
254 void IconTheme::append_search_path(const Glib::ustring& path)
255 {
256   gtk_icon_theme_append_search_path(gobj(), path.c_str());
257 }
258
259 void IconTheme::prepend_search_path(const Glib::ustring& path)
260 {
261   gtk_icon_theme_prepend_search_path(gobj(), path.c_str());
262 }
263
264 void IconTheme::set_custom_theme(const Glib::ustring& theme_name)
265 {
266   gtk_icon_theme_set_custom_theme(gobj(), theme_name.c_str());
267 }
268
269 bool IconTheme::has_icon(const Glib::ustring& icon_name) const
270 {
271   return gtk_icon_theme_has_icon(const_cast<GtkIconTheme*>(gobj()), icon_name.c_str());
272 }
273
274 IconInfo IconTheme::lookup_icon(const Glib::ustring& icon_name, int size, IconLookupFlags flags) const
275 {
276   return Glib::wrap(gtk_icon_theme_lookup_icon(const_cast<GtkIconTheme*>(gobj()), icon_name.c_str(), size, ((GtkIconLookupFlags)(flags))));
277 }
278
279 Glib::RefPtr<Gdk::Pixbuf> IconTheme::load_icon(const Glib::ustring& icon_name, int size, IconLookupFlags flags) const
280 {
281   GError *error = 0;
282   Glib::RefPtr<Gdk::Pixbuf> retvalue = Glib::wrap(gtk_icon_theme_load_icon(const_cast<GtkIconTheme*>(gobj()), icon_name.c_str(), size, ((GtkIconLookupFlags)(flags)), &(error)));
283   if(error) ::Glib::Error::throw_exception(error);
284   return retvalue;
285 }
286
287 Glib::ListHandle<Glib::ustring> IconTheme::list_icons(const Glib::ustring& context) const
288 {
289   return Glib::ListHandle<Glib::ustring>(gtk_icon_theme_list_icons(const_cast<GtkIconTheme*>(gobj()), context.c_str()), Glib::OWNERSHIP_SHALLOW);
290 }
291
292 Glib::ustring IconTheme::get_example_icon_name() const
293 {
294   return Glib::convert_return_gchar_ptr_to_ustring(gtk_icon_theme_get_example_icon_name(const_cast<GtkIconTheme*>(gobj())));
295 }
296
297 bool IconTheme::rescan_if_needed()
298 {
299   return gtk_icon_theme_rescan_if_needed(gobj());
300 }
301
302 void IconTheme::add_builtin_icon(const Glib::ustring& icon_name, int size, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
303 {
304   gtk_icon_theme_add_builtin_icon(icon_name.c_str(), size, Glib::unwrap(pixbuf));
305 }
306
307
308 Glib::SignalProxy0< void > IconTheme::signal_changed()
309 {
310   return Glib::SignalProxy0< void >(this, &IconTheme_signal_changed_info);
311 }
312
313
314 void Gtk::IconTheme::on_changed()
315 {
316   BaseClassType *const base = static_cast<BaseClassType*>(
317       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
318   );
319
320   if(base && base->changed)
321     (*base->changed)(gobj());
322 }
323
324
325 } // namespace Gtk
326
327