1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #include <gtkmm/filefilter.h>
4 #include <gtkmm/private/filefilter_p.h>
9 /* Copyright 2003 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/gtkfilefilter.h>
27 #include <gtk/gtktypebuiltins.h> //For gtk_file_filter_flags_get_type().
34 //This Signal Proxy allows the C++ coder to specify a sigc::slot instead of a static function.
35 class SignalProxy_Custom
38 typedef Gtk::FileFilter::SlotCustom SlotType;
40 SignalProxy_Custom(const SlotType& slot);
41 ~SignalProxy_Custom();
43 static gboolean gtk_callback(const GtkFileFilterInfo* filter_info, gpointer data);
44 static void gtk_callback_destroy(void* data);
50 SignalProxy_Custom::SignalProxy_Custom(const SlotType& slot)
55 SignalProxy_Custom::~SignalProxy_Custom()
58 gboolean SignalProxy_Custom::gtk_callback(const GtkFileFilterInfo* filter_info, gpointer data)
60 SignalProxy_Custom *const self = static_cast<SignalProxy_Custom*>(data);
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);
72 return (self->slot_)(cppInfo);
76 Glib::exception_handlers_invoke();
77 return false; //arbitrary default;
81 void SignalProxy_Custom::gtk_callback_destroy(void* data)
83 delete static_cast<SignalProxy_Custom*>(data);
86 } //anonymous namespace
91 void FileFilter::add_custom(FileFilterFlags needed, const SlotCustom& slot)
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);
97 gtk_file_filter_add_custom(gobj(), (GtkFileFilterFlags)needed,
98 &SignalProxy_Custom::gtk_callback,
100 &SignalProxy_Custom::gtk_callback_destroy);
108 } // anonymous namespace
111 GType Glib::Value<Gtk::FileFilterFlags>::value_type()
113 return gtk_file_filter_flags_get_type();
120 Gtk::FileFilter* wrap(GtkFileFilter* object, bool take_copy)
122 return dynamic_cast<Gtk::FileFilter *> (Glib::wrap_auto ((GObject*)(object), take_copy));
125 } /* namespace Glib */
131 /* The *_Class implementation: */
133 const Glib::Class& FileFilter_Class::init()
135 if(!gtype_) // create the GType if necessary
137 // Glib::Class has to know the class init function to clone custom types.
138 class_init_func_ = &FileFilter_Class::class_init_function;
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();
144 // Create the wrapper type, with the same class/instance size as the base type.
145 register_derived_type(gtk_file_filter_get_type());
147 // Add derived versions of interfaces, if the C type implements any interfaces:
153 void FileFilter_Class::class_init_function(void* g_class, void* class_data)
155 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
156 CppClassParent::class_init_function(klass, class_data);
161 Glib::ObjectBase* FileFilter_Class::wrap_new(GObject* o)
163 return manage(new FileFilter((GtkFileFilter*)(o)));
168 /* The implementation: */
170 FileFilter::FileFilter(const Glib::ConstructParams& construct_params)
172 Gtk::Object(construct_params)
176 FileFilter::FileFilter(GtkFileFilter* castitem)
178 Gtk::Object((GtkObject*)(castitem))
182 FileFilter::~FileFilter()
187 FileFilter::CppClassType FileFilter::filefilter_class_; // initialize static member
189 GType FileFilter::get_type()
191 return filefilter_class_.init().get_type();
194 GType FileFilter::get_base_type()
196 return gtk_file_filter_get_type();
200 FileFilter::FileFilter()
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()))
207 void FileFilter::set_name(const Glib::ustring& name)
209 gtk_file_filter_set_name(gobj(), name.c_str());
212 Glib::ustring FileFilter::get_name() const
214 return Glib::convert_const_gchar_ptr_to_ustring(gtk_file_filter_get_name(const_cast<GtkFileFilter*>(gobj())));
217 void FileFilter::add_mime_type(const Glib::ustring& mime_type)
219 gtk_file_filter_add_mime_type(gobj(), mime_type.c_str());
222 void FileFilter::add_pattern(const Glib::ustring& pattern)
224 gtk_file_filter_add_pattern(gobj(), pattern.c_str());
227 void FileFilter::add_pixbuf_formats()
229 gtk_file_filter_add_pixbuf_formats(gobj());
232 FileFilterFlags FileFilter::get_needed() const
234 return ((FileFilterFlags)(gtk_file_filter_get_needed(const_cast<GtkFileFilter*>(gobj()))));