rollback to 3428, before the mysterious removal of libs/* at 3431/3432
[ardour.git] / libs / gtkmm2 / gtk / src / recentchooser.ccg
1 /* Copyright 2006 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 Library General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 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  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public
14  * License along with this library; if not, write to the Free
15  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  */
17
18 #include <gtk/gtkrecentchooser.h>
19
20 // This Signal Proxy allows the C++ coder to specify a sigc::slot instead of a static function.
21
22 static int SignalProxy_Compare_gtk_callback(GtkRecentInfo* a, GtkRecentInfo* b, gpointer data)
23 {
24   const Gtk::RecentChooser::SlotCompare* the_slot = static_cast<Gtk::RecentChooser::SlotCompare*>(data);
25
26   #ifdef GLIBMM_EXCEPTIONS_ENABLED
27   try
28   {
29   #endif //GLIBMM_EXCEPTIONS_ENABLED
30     return (*the_slot)(Glib::wrap(a, true /* take reference */), Glib::wrap(b, true /* take reference */));
31   #ifdef GLIBMM_EXCEPTIONS_ENABLED
32   }
33   catch(...)
34   {
35     Glib::exception_handlers_invoke();
36   }
37
38   return 0;
39   #endif //GLIBMM_EXCEPTIONS_ENABLED
40 }
41
42 static void SignalProxy_Compare_gtk_callback_destroy(gpointer data)
43 {
44   delete static_cast<Gtk::RecentChooser::SlotCompare*>(data);
45 }
46
47
48 namespace Gtk
49 {
50
51 //Allow the generated code to work without the prefix:
52 typedef RecentChooser::ListHandle_RecentInfos ListHandle_RecentInfos;
53
54 void RecentChooser::set_sort_func(const SlotCompare& slot)
55 {
56   SlotCompare* slot_copy = new SlotCompare(slot);
57
58   gtk_recent_chooser_set_sort_func(
59       gobj(),
60       &SignalProxy_Compare_gtk_callback, slot_copy,
61       &SignalProxy_Compare_gtk_callback_destroy);
62 }
63
64 Glib::StringArrayHandle RecentChooser::get_uris() const
65 {
66   return Glib::StringArrayHandle(gtk_recent_chooser_get_uris(const_cast<GtkRecentChooser*>(gobj()), NULL));
67 }
68
69 void RecentChooser::unset_limit()
70 {
71   gtk_recent_chooser_set_limit(gobj(), -1 /* See C docs */);
72 }
73
74 } // namespace Gtk
75