2 /* $Id: filefilter.ccg,v 1.8 2006/05/11 11:40:24 murrayc Exp $ */
4 /* Copyright 2003 The gtkmm Development Team
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gtk/gtkfilefilter.h>
22 #include <gtk/gtktypebuiltins.h> //For gtk_file_filter_flags_get_type().
24 static gboolean SignalProxy_Custom_gtk_callback(const GtkFileFilterInfo* filter_info, gpointer data)
26 Gtk::FileFilter::SlotCustom* the_slot = static_cast<Gtk::FileFilter::SlotCustom*>(data);
28 #ifdef GLIBMM_EXCEPTIONS_ENABLED
31 #endif //GLIBMM_EXCEPTIONS_ENABLED
32 //Create a suitable C++ instance to pass to the C++ method:
33 Gtk::FileFilter::Info cppInfo;
34 cppInfo.contains = (Gtk::FileFilterFlags)filter_info->contains;
35 cppInfo.filename = Glib::convert_const_gchar_ptr_to_ustring(filter_info->filename);
36 cppInfo.uri = Glib::convert_const_gchar_ptr_to_ustring(filter_info->uri);
37 cppInfo.display_name = Glib::convert_const_gchar_ptr_to_ustring(filter_info->display_name);
38 cppInfo.mime_type = Glib::convert_const_gchar_ptr_to_ustring(filter_info->mime_type);
40 return (*the_slot)(cppInfo);
41 #ifdef GLIBMM_EXCEPTIONS_ENABLED
45 Glib::exception_handlers_invoke();
46 return false; //arbitrary default;
48 #endif //GLIBMM_EXCEPTIONS_ENABLED
51 static void SignalProxy_Custom_gtk_callback_destroy(void* data)
53 delete static_cast<Gtk::FileFilter::SlotCustom*>(data);
60 void FileFilter::add_custom(FileFilterFlags needed, const SlotCustom& slot)
62 //Create a copy of the slot. A pointer to this will be passed through the callback's data parameter.
63 //It will be deleted when SignalProxy_Custom::gtk_callback_destroy() is called.
64 SlotCustom* slot_copy = new SlotCustom(slot);
66 gtk_file_filter_add_custom(gobj(), (GtkFileFilterFlags)needed,
67 &SignalProxy_Custom_gtk_callback,
69 &SignalProxy_Custom_gtk_callback_destroy);