add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / gtk / src / recentchooser.hg
1 /* Copyright (C) 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 #include <glibmm/interface.h>
20 #include <gtkmm/recentinfo.h>
21 #include <gtkmm/recentfilter.h>
22 #include <gtkmm/recentmanager.h>
23
24 _DEFS(gtkmm,gtk)
25 _PINCLUDE(glibmm/private/interface_p.h)
26
27 namespace Gtk
28 {
29
30 _WRAP_ENUM(RecentSortType, GtkRecentSortType)
31
32 /** Exception class for Gtk::RecentChooser errors.
33  */
34 _WRAP_GERROR(RecentChooserError,GtkRecentChooserError,GTK_RECENT_CHOOSER_ERROR)
35
36 /** RecentChooser is an interface that can be implemented by widgets
37  * displaying the list of recently used files.  In GTK+, the main objects
38  * that implement this interface are RecentChooserWidget, RecentChooserDialog
39  * and RecentChooserMenu.
40  *
41  * @newin2p10
42  *
43  * @ingroup RecentFiles
44  */
45 class RecentChooser : public Glib::Interface
46 {
47   _CLASS_INTERFACE(RecentChooser, GtkRecentChooser, GTK_RECENT_CHOOSER, GtkRecentChooserIface)
48 public:
49
50   _WRAP_METHOD(void set_show_private(bool show_private = true), gtk_recent_chooser_set_show_private)
51   _WRAP_METHOD(bool get_show_private() const, gtk_recent_chooser_get_show_private)
52   _WRAP_METHOD(void set_show_not_found(bool show_not_found = true), gtk_recent_chooser_set_show_not_found)
53   _WRAP_METHOD(bool get_show_not_found() const, gtk_recent_chooser_get_show_not_found)
54   _WRAP_METHOD(void set_select_multiple(bool select_multiple = true), gtk_recent_chooser_set_select_multiple)
55   _WRAP_METHOD(bool get_select_multiple() const, gtk_recent_chooser_get_select_multiple)
56   _WRAP_METHOD(void set_limit(int limit), gtk_recent_chooser_set_limit)
57   void unset_limit();
58   _WRAP_METHOD(int get_limit() const, gtk_recent_chooser_get_limit)
59   _WRAP_METHOD(void set_local_only(bool local_only = true), gtk_recent_chooser_set_local_only)
60   _WRAP_METHOD(bool get_local_only() const, gtk_recent_chooser_get_local_only)
61   _WRAP_METHOD(void set_show_tips(bool show_tips = true), gtk_recent_chooser_set_show_tips)
62   _WRAP_METHOD(bool get_show_tips() const, gtk_recent_chooser_get_show_tips)
63
64   // Deprecated in GTK+ 2.12. murrayc:
65   _IGNORE(gtk_recent_chooser_get_show_numbers, gtk_recent_chooser_set_show_numbers)
66
67   _WRAP_METHOD(void set_show_icons(bool show_icons = true), gtk_recent_chooser_set_show_icons)
68   _WRAP_METHOD(bool get_show_icons() const, gtk_recent_chooser_get_show_icons)
69   _WRAP_METHOD(void set_sort_type(RecentSortType sort_type), gtk_recent_chooser_set_sort_type)
70   _WRAP_METHOD(RecentSortType get_sort_type() const, gtk_recent_chooser_get_sort_type)
71
72
73   /** This callback should return -1 if b compares before a, 0 if they compare
74    * equal and 1 if a compares after b.
75    * For instance, int on_sort_compare(const Glib::RefPtr<Gtk::RecentInfo>& a, const Gtk::RecentInfo& b);
76    */
77   typedef sigc::slot<int, const Glib::RefPtr<RecentInfo>&, const Glib::RefPtr<RecentInfo>&> SlotCompare;
78   _IGNORE(gtk_recent_chooser_set_sort_func)
79
80   /** Sets the comparison function used when sorting the list of recently
81    * used resources and the sort type is #RECENT_SORT_CUSTOM.
82    */
83   void set_sort_func(const SlotCompare& slot);
84
85   // TODO: Return type should be void since it will never return false but
86   // throwing RecentChooserError instead
87   _WRAP_METHOD(bool set_current_uri(const Glib::ustring& uri), gtk_recent_chooser_set_current_uri, errthrow)
88   _WRAP_METHOD(Glib::ustring get_current_uri() const, gtk_recent_chooser_get_current_uri)
89   _WRAP_METHOD(Glib::RefPtr<RecentInfo> get_current_item(), gtk_recent_chooser_get_current_item, refreturn)
90   _WRAP_METHOD(Glib::RefPtr<const RecentInfo> get_current_item() const, gtk_recent_chooser_get_current_item, refreturn)
91   // TODO: Same here
92   _WRAP_METHOD(bool select_uri(const Glib::ustring& uri), gtk_recent_chooser_select_uri, errthrow)
93   _WRAP_METHOD(void unselect_uri(const Glib::ustring& uri), gtk_recent_chooser_unselect_uri)
94   _WRAP_METHOD(void select_all(), gtk_recent_chooser_select_all)
95   _WRAP_METHOD(void unselect_all(), gtk_recent_chooser_unselect_all)
96
97   typedef Glib::ListHandle<RecentInfo, RecentInfoTraits> ListHandle_RecentInfos;
98   _CONVERSION(`GList*',`ListHandle_RecentInfos',__FL2H_SHALLOW)
99
100   _WRAP_METHOD(ListHandle_RecentInfos get_items() const, gtk_recent_chooser_get_items)
101
102   /** Gets the URI of the recently used resources.
103    *
104    * The return value of this function is affected by the "sort-type" and
105    * "limit" properties of the recent chooser.
106    */
107   Glib::StringArrayHandle get_uris() const;
108   _IGNORE(gtk_recent_chooser_get_uris)
109
110   _WRAP_METHOD(void add_filter(const RecentFilter& filter), gtk_recent_chooser_add_filter)
111   _WRAP_METHOD(void remove_filter(const RecentFilter& filter), gtk_recent_chooser_remove_filter)
112   _WRAP_METHOD(Glib::SListHandle<RecentFilter*> list_filters(), gtk_recent_chooser_list_filters)
113   _WRAP_METHOD(Glib::SListHandle<const RecentFilter*> list_filters() const, gtk_recent_chooser_list_filters)
114   _WRAP_METHOD(void set_filter(const RecentFilter& filter), gtk_recent_chooser_set_filter)
115   _WRAP_METHOD(RecentFilter* get_filter(), gtk_recent_chooser_get_filter)
116   _WRAP_METHOD(const RecentFilter* get_filter() const, gtk_recent_chooser_get_filter)
117
118   /** This signal is emitted when there is a change in the set of
119    * selected recently used resources.  This can happen when a user
120    * modifies the selection with the mouse or the keyboard, or when
121    * explicitely calling functions to change the selection.
122    */
123   _WRAP_SIGNAL(void selection_changed(), "selection-changed", no_default_handler)
124
125   /** This signal is emitted when the user "activates" a recent item
126    * in the recent chooser.  This can happen by double-clicking on an item
127    * in the recently used resources list, or by pressing
128    * <keycap>Enter</keycap>.
129    */
130   _WRAP_SIGNAL(void item_activated(), "item-activated", no_default_handler)
131
132   _WRAP_PROPERTY("recent-manager", Glib::RefPtr<RecentManager>)
133   _WRAP_PROPERTY("show-private", bool)
134   _WRAP_PROPERTY("show-tips", bool)
135   _WRAP_PROPERTY("show-icons", bool)
136   _WRAP_PROPERTY("show-not-found", bool)
137   _WRAP_PROPERTY("select-multiple", bool)
138   _WRAP_PROPERTY("local-only", bool)
139   _WRAP_PROPERTY("limit", int)
140   _WRAP_PROPERTY("sort-type", RecentSortType)
141   _WRAP_PROPERTY("filter", RecentFilter*)
142
143 protected:
144 #m4begin
145   // As in editable.hg
146   _CONVERSION(`Glib::ustring', `gchar*', `g_strdup(($3).c_str())')
147 #m4end
148   // TODO: How to wrap those vfuncs?
149
150   //_CONVERSION(`ListHandle_RecentInfos', `GList*', `($3).data()')
151   //_CONVERSION(`Glib::SListHandle<RecentFilter*>', `GSList*', `($3).data()')
152
153   //_WRAP_VFUNC(bool set_current_uri(const Glib::ustring& uri), "set_current_uri", errthrow)
154   _WRAP_VFUNC(Glib::ustring get_current_uri() const, "get_current_uri")
155   //_WRAP_VFUNC(bool select_uri(const Glib::ustring& uri), "select_uri", errthrow)
156   _WRAP_VFUNC(void unselect_uri(const Glib::ustring& uri), "unselect_uri")
157   _WRAP_VFUNC(void select_all(), "select_all")
158   _WRAP_VFUNC(void unselect_all(), "unselect_all")
159   //_WRAP_VFUNC(ArrayHandle_RecentInfos get_items() const, "get_items")
160   _WRAP_VFUNC(Glib::RefPtr<RecentManager> get_recent_manager(), "get_recent_manager")
161   _WRAP_VFUNC(void add_filter(const RecentFilter& filter), "add_filter")
162   _WRAP_VFUNC(void remove_filter(const RecentFilter& filter), "remove_filter")
163   //_WRAP_VFUNC(Glib::SListHandle<RecentFilter*> list_filters(), "list_filters")
164   //_WRAP_VFUNC(void set_sort_func(const SlotCompare& slot), "set_sort_func")
165 };
166  
167 } // namespace Gtk