Debian Codegraph @

gtk/src/fontchooser.ccg

raw
1 /* Copyright (C) 2011 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtk/gtk.h>
18
19
20 namespace
21 {
22 extern "C"
23 {
24 static gboolean SignalProxy_Filter_gtk_callback(const PangoFontFamily* family, const PangoFontFace* face, gpointer user_data)
25 {
26 auto the_slot = static_cast<Gtk::FontChooser::SlotFontFilter*>(user_data);
27
28 try
29 {
30 // Create suitable C++ instances to pass to the C++ method:
31 const Glib::RefPtr<const Pango::FontFamily> cppFamily = Glib::wrap(const_cast<PangoFontFamily*>(family), true);
32 const Glib::RefPtr<const Pango::FontFace> cppFace = Glib::wrap(const_cast<PangoFontFace*>(face), true);
33 return (*the_slot)(cppFamily, cppFace);
34 }
35 catch(...)
36 {
37 Glib::exception_handlers_invoke();
38 }
39
40 return false; // arbitrary value
41 }
42
43 static void SignalProxy_Filter_gtk_callback_destroy(void* data)
44 {
45 delete static_cast<Gtk::FontChooser::SlotFontFilter*>(data);
46 }
47
48 } // extern "C"
49 } // anonymous namespace
50
51 namespace Gtk
52 {
53
54 void FontChooser::set_filter_func(const SlotFontFilter& slot)
55 {
56 auto slot_copy = new SlotFontFilter(slot);
57 gtk_font_chooser_set_filter_func(gobj(), &SignalProxy_Filter_gtk_callback, slot_copy, &SignalProxy_Filter_gtk_callback_destroy);
58 }
59
60 } //namespace Gtk