Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / filefilter.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <gtkmm/filefilter.h>
4 #include <gtkmm/private/filefilter_p.h>
5
6 // -*- c++ -*-
7 /* $Id$ */
8
9 /* Copyright 2003 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/gtkfilefilter.h>
27 #include <gtk/gtktypebuiltins.h> //For gtk_file_filter_flags_get_type().
28
29 namespace
30 {
31
32 //SignalProxy_Custom:
33
34 //This Signal Proxy allows the C++ coder to specify a sigc::slot instead of a static function.
35 class SignalProxy_Custom
36 {
37 public:
38   typedef Gtk::FileFilter::SlotCustom SlotType;
39
40   SignalProxy_Custom(const SlotType& slot);
41   ~SignalProxy_Custom();
42
43   static gboolean gtk_callback(const GtkFileFilterInfo* filter_info, gpointer data);
44   static void gtk_callback_destroy(void* data);
45   
46 protected:
47   SlotType slot_;
48 };
49
50 SignalProxy_Custom::SignalProxy_Custom(const SlotType& slot)
51 :
52   slot_ (slot)
53 {}
54
55 SignalProxy_Custom::~SignalProxy_Custom()
56 {}
57
58 gboolean SignalProxy_Custom::gtk_callback(const GtkFileFilterInfo* filter_info, gpointer data)
59 {
60   SignalProxy_Custom *const self = static_cast<SignalProxy_Custom*>(data);
61
62   try
63   {
64     //Create a suitable C++ instance to pass to the C++ method:
65     Gtk::FileFilter::Info cppInfo;
66     cppInfo.contains = (Gtk::FileFilterFlags)filter_info->contains;
67     cppInfo.filename = Glib::convert_const_gchar_ptr_to_ustring(filter_info->filename);
68     cppInfo.uri = Glib::convert_const_gchar_ptr_to_ustring(filter_info->uri);
69     cppInfo.display_name = Glib::convert_const_gchar_ptr_to_ustring(filter_info->display_name);
70     cppInfo.mime_type = Glib::convert_const_gchar_ptr_to_ustring(filter_info->mime_type);
71   
72     return (self->slot_)(cppInfo);
73   }
74   catch(...)
75   {
76     Glib::exception_handlers_invoke();
77     return false; //arbitrary default;
78   }
79 }
80
81 void SignalProxy_Custom::gtk_callback_destroy(void* data)
82 {
83   delete static_cast<SignalProxy_Custom*>(data);
84 }
85
86 } //anonymous namespace
87
88 namespace Gtk
89 {
90
91 void FileFilter::add_custom(FileFilterFlags needed, const SlotCustom& slot)
92 {
93   //Create a signal proxy. A pointer to this will be passed through the callback's data parameter.
94   //It will be deleted when SignalProxy_Custom::gtk_callback_destroy() is called.
95   SignalProxy_Custom *const pSignalProxy = new SignalProxy_Custom(slot);
96       
97   gtk_file_filter_add_custom(gobj(), (GtkFileFilterFlags)needed,
98                              &SignalProxy_Custom::gtk_callback,
99                              pSignalProxy,
100                              &SignalProxy_Custom::gtk_callback_destroy);     
101 }
102  
103 } // namespace Gtk
104
105
106 namespace
107 {
108 } // anonymous namespace
109
110 // static
111 GType Glib::Value<Gtk::FileFilterFlags>::value_type()
112 {
113   return gtk_file_filter_flags_get_type();
114 }
115
116
117 namespace Glib
118 {
119
120 Gtk::FileFilter* wrap(GtkFileFilter* object, bool take_copy)
121 {
122   return dynamic_cast<Gtk::FileFilter *> (Glib::wrap_auto ((GObject*)(object), take_copy));
123 }
124
125 } /* namespace Glib */
126
127 namespace Gtk
128 {
129
130
131 /* The *_Class implementation: */
132
133 const Glib::Class& FileFilter_Class::init()
134 {
135   if(!gtype_) // create the GType if necessary
136   {
137     // Glib::Class has to know the class init function to clone custom types.
138     class_init_func_ = &FileFilter_Class::class_init_function;
139
140     // This is actually just optimized away, apparently with no harm.
141     // Make sure that the parent type has been created.
142     //CppClassParent::CppObjectType::get_type();
143
144     // Create the wrapper type, with the same class/instance size as the base type.
145     register_derived_type(gtk_file_filter_get_type());
146
147     // Add derived versions of interfaces, if the C type implements any interfaces:
148   }
149
150   return *this;
151 }
152
153 void FileFilter_Class::class_init_function(void* g_class, void* class_data)
154 {
155   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
156   CppClassParent::class_init_function(klass, class_data);
157
158 }
159
160
161 Glib::ObjectBase* FileFilter_Class::wrap_new(GObject* o)
162 {
163   return manage(new FileFilter((GtkFileFilter*)(o)));
164
165 }
166
167
168 /* The implementation: */
169
170 FileFilter::FileFilter(const Glib::ConstructParams& construct_params)
171 :
172   Gtk::Object(construct_params)
173 {
174   }
175
176 FileFilter::FileFilter(GtkFileFilter* castitem)
177 :
178   Gtk::Object((GtkObject*)(castitem))
179 {
180   }
181
182 FileFilter::~FileFilter()
183 {
184   destroy_();
185 }
186
187 FileFilter::CppClassType FileFilter::filefilter_class_; // initialize static member
188
189 GType FileFilter::get_type()
190 {
191   return filefilter_class_.init().get_type();
192 }
193
194 GType FileFilter::get_base_type()
195 {
196   return gtk_file_filter_get_type();
197 }
198
199
200 FileFilter::FileFilter()
201 :
202   Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
203   Gtk::Object(Glib::ConstructParams(filefilter_class_.init()))
204 {
205   }
206
207 void FileFilter::set_name(const Glib::ustring& name)
208 {
209   gtk_file_filter_set_name(gobj(), name.c_str());
210 }
211
212 Glib::ustring FileFilter::get_name() const
213 {
214   return Glib::convert_const_gchar_ptr_to_ustring(gtk_file_filter_get_name(const_cast<GtkFileFilter*>(gobj())));
215 }
216
217 void FileFilter::add_mime_type(const Glib::ustring& mime_type)
218 {
219   gtk_file_filter_add_mime_type(gobj(), mime_type.c_str());
220 }
221
222 void FileFilter::add_pattern(const Glib::ustring& pattern)
223 {
224   gtk_file_filter_add_pattern(gobj(), pattern.c_str());
225 }
226
227 void FileFilter::add_pixbuf_formats()
228 {
229   gtk_file_filter_add_pixbuf_formats(gobj());
230 }
231
232 FileFilterFlags FileFilter::get_needed() const
233 {
234   return ((FileFilterFlags)(gtk_file_filter_get_needed(const_cast<GtkFileFilter*>(gobj()))));
235 }
236
237
238 } // namespace Gtk
239
240