| 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 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 <vector> |
| 18 |
|
| 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 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 28 |
extern "C" |
| 29 |
{ |
| 30 |
typedef struct _GtkRecentChooserIface GtkRecentChooserIface; |
| 31 |
} |
| 32 |
#endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 33 |
|
| 34 |
namespace Gtk |
| 35 |
{ |
| 36 |
|
| 37 |
_WRAP_ENUM(RecentSortType, GtkRecentSortType, decl_prefix GTKMM_API) |
| 38 |
|
| 39 |
/** Exception class for Gtk::RecentChooser errors. |
| 40 |
*/ |
| 41 |
_WRAP_GERROR(RecentChooserError,GtkRecentChooserError,GTK_RECENT_CHOOSER_ERROR,decl_prefix GTKMM_API) |
| 42 |
|
| 43 |
/** RecentChooser is an interface that can be implemented by widgets |
| 44 |
* displaying the list of recently used files. In GTK+, the main objects |
| 45 |
* that implement this interface are RecentChooserWidget, RecentChooserDialog |
| 46 |
* and RecentChooserMenu. |
| 47 |
* |
| 48 |
* @newin{2,10} |
| 49 |
* |
| 50 |
* @ingroup RecentFiles |
| 51 |
*/ |
| 52 |
class GTKMM_API RecentChooser : public Glib::Interface |
| 53 |
{ |
| 54 |
_CLASS_INTERFACE(RecentChooser, GtkRecentChooser, GTK_RECENT_CHOOSER, GtkRecentChooserIface, , , GTKMM_API) |
| 55 |
public: |
| 56 |
|
| 57 |
_WRAP_METHOD(void set_show_private(bool show_private = true), gtk_recent_chooser_set_show_private) |
| 58 |
_WRAP_METHOD(bool get_show_private() const, gtk_recent_chooser_get_show_private) |
| 59 |
_WRAP_METHOD(void set_show_not_found(bool show_not_found = true), gtk_recent_chooser_set_show_not_found) |
| 60 |
_WRAP_METHOD(bool get_show_not_found() const, gtk_recent_chooser_get_show_not_found) |
| 61 |
_WRAP_METHOD(void set_select_multiple(bool select_multiple = true), gtk_recent_chooser_set_select_multiple) |
| 62 |
_WRAP_METHOD(bool get_select_multiple() const, gtk_recent_chooser_get_select_multiple) |
| 63 |
_WRAP_METHOD(void set_limit(int limit), gtk_recent_chooser_set_limit) |
| 64 |
void unset_limit(); |
| 65 |
_WRAP_METHOD(int get_limit() const, gtk_recent_chooser_get_limit) |
| 66 |
_WRAP_METHOD(void set_local_only(bool local_only = true), gtk_recent_chooser_set_local_only) |
| 67 |
_WRAP_METHOD(bool get_local_only() const, gtk_recent_chooser_get_local_only) |
| 68 |
_WRAP_METHOD(void set_show_tips(bool show_tips = true), gtk_recent_chooser_set_show_tips) |
| 69 |
_WRAP_METHOD(bool get_show_tips() const, gtk_recent_chooser_get_show_tips) |
| 70 |
|
| 71 |
_WRAP_METHOD(void set_show_icons(bool show_icons = true), gtk_recent_chooser_set_show_icons) |
| 72 |
_WRAP_METHOD(bool get_show_icons() const, gtk_recent_chooser_get_show_icons) |
| 73 |
_WRAP_METHOD(void set_sort_type(RecentSortType sort_type), gtk_recent_chooser_set_sort_type) |
| 74 |
_WRAP_METHOD(RecentSortType get_sort_type() const, gtk_recent_chooser_get_sort_type) |
| 75 |
|
| 76 |
|
| 77 |
/** This callback should return -1 if b compares before a, 0 if they compare |
| 78 |
* equal and 1 if a compares after b. |
| 79 |
* For instance, int on_sort_compare(const Glib::RefPtr<Gtk::RecentInfo>& a, const Gtk::RecentInfo& b); |
| 80 |
*/ |
| 81 |
typedef sigc::slot<int, const Glib::RefPtr<RecentInfo>&, const Glib::RefPtr<RecentInfo>&> SlotCompare; |
| 82 |
_IGNORE(gtk_recent_chooser_set_sort_func) |
| 83 |
|
| 84 |
/** Sets the comparison function used when sorting the list of recently |
| 85 |
* used resources and the sort type is #RECENT_SORT_CUSTOM. |
| 86 |
*/ |
| 87 |
void set_sort_func(const SlotCompare& slot); |
| 88 |
|
| 89 |
// TODO: Return type should be void since it will never return false but |
| 90 |
// throwing RecentChooserError instead |
| 91 |
_WRAP_METHOD(bool set_current_uri(const Glib::ustring& uri), gtk_recent_chooser_set_current_uri, errthrow) |
| 92 |
_WRAP_METHOD(Glib::ustring get_current_uri() const, gtk_recent_chooser_get_current_uri) |
| 93 |
_WRAP_METHOD(Glib::RefPtr<RecentInfo> get_current_item(), gtk_recent_chooser_get_current_item, refreturn) |
| 94 |
_WRAP_METHOD(Glib::RefPtr<const RecentInfo> get_current_item() const, gtk_recent_chooser_get_current_item, refreturn) |
| 95 |
// TODO: Same here |
| 96 |
_WRAP_METHOD(bool select_uri(const Glib::ustring& uri), gtk_recent_chooser_select_uri, errthrow) |
| 97 |
_WRAP_METHOD(void unselect_uri(const Glib::ustring& uri), gtk_recent_chooser_unselect_uri) |
| 98 |
_WRAP_METHOD(void select_all(), gtk_recent_chooser_select_all) |
| 99 |
_WRAP_METHOD(void unselect_all(), gtk_recent_chooser_unselect_all) |
| 100 |
|
| 101 |
//typedef Glib::ListHandle<RecentInfo, RecentInfoTraits> ListHandle_RecentInfos; |
| 102 |
#m4 _CONVERSION(`GList*',`std::vector<Glib::RefPtr<RecentInfo> >',`Glib::ListHandler<Glib::RefPtr<RecentInfo>, RecentInfoTraits>::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)') |
| 103 |
|
| 104 |
_WRAP_METHOD(std::vector<Glib::RefPtr<RecentInfo> > get_items() const, gtk_recent_chooser_get_items) |
| 105 |
|
| 106 |
/** Gets the URI of the recently used resources. |
| 107 |
* |
| 108 |
* The return value of this function is affected by the "sort-type" and |
| 109 |
* "limit" properties of the recent chooser. |
| 110 |
*/ |
| 111 |
std::vector<Glib::ustring> get_uris() const; |
| 112 |
_IGNORE(gtk_recent_chooser_get_uris) |
| 113 |
|
| 114 |
_WRAP_METHOD(void add_filter(const Glib::RefPtr<RecentFilter>& filter), gtk_recent_chooser_add_filter) |
| 115 |
_WRAP_METHOD(void remove_filter(const Glib::RefPtr<RecentFilter>& filter), gtk_recent_chooser_remove_filter) |
| 116 |
|
| 117 |
#m4 _CONVERSION(`GSList*',`std::vector< Glib::RefPtr<RecentFilter> >',`Glib::SListHandler<Glib::RefPtr<RecentFilter> >::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)') |
| 118 |
_WRAP_METHOD(std::vector< Glib::RefPtr<RecentFilter> > list_filters(), gtk_recent_chooser_list_filters) |
| 119 |
#m4 _CONVERSION(`GSList*',`std::vector< Glib::RefPtr<const RecentFilter> >',`Glib::SListHandler<Glib::RefPtr<const RecentFilter> >::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)') |
| 120 |
_WRAP_METHOD(std::vector< Glib::RefPtr<const RecentFilter> > list_filters() const, gtk_recent_chooser_list_filters) |
| 121 |
|
| 122 |
_WRAP_METHOD(void set_filter(const Glib::RefPtr<RecentFilter>& filter), gtk_recent_chooser_set_filter) |
| 123 |
_WRAP_METHOD(Glib::RefPtr<RecentFilter> get_filter(), gtk_recent_chooser_get_filter, refreturn) |
| 124 |
_WRAP_METHOD(Glib::RefPtr<const RecentFilter> get_filter() const, gtk_recent_chooser_get_filter, refreturn, constversion) |
| 125 |
|
| 126 |
_WRAP_SIGNAL(void selection_changed(), "selection-changed") |
| 127 |
_WRAP_SIGNAL(void item_activated(), "item-activated") |
| 128 |
|
| 129 |
//Not wrapped because it's write-only and construct-only: _WRAP_PROPERTY("recent-manager", Glib::RefPtr<RecentManager>) |
| 130 |
_WRAP_PROPERTY("show-private", bool) |
| 131 |
_WRAP_PROPERTY("show-tips", bool) |
| 132 |
_WRAP_PROPERTY("show-icons", bool) |
| 133 |
_WRAP_PROPERTY("show-not-found", bool) |
| 134 |
_WRAP_PROPERTY("select-multiple", bool) |
| 135 |
_WRAP_PROPERTY("local-only", bool) |
| 136 |
_WRAP_PROPERTY("limit", int) |
| 137 |
_WRAP_PROPERTY("sort-type", RecentSortType) |
| 138 |
_WRAP_PROPERTY("filter", Glib::RefPtr<RecentFilter>) |
| 139 |
|
| 140 |
protected: |
| 141 |
// TODO: How to wrap those vfuncs? |
| 142 |
// TODO: Also: use vectorutils. |
| 143 |
|
| 144 |
//_CONVERSION(`ListHandle_RecentInfos', `GList*', `($3).data()') |
| 145 |
//_CONVERSION(`Glib::SListHandle<RecentFilter*>', `GSList*', `($3).data()') |
| 146 |
|
| 147 |
//_WRAP_VFUNC(bool set_current_uri(const Glib::ustring& uri), "set_current_uri", errthrow) |
| 148 |
#m4 _CONVERSION(`Glib::ustring', `gchar*', `g_strdup(($3).c_str())') |
| 149 |
#m4 _CONVERSION(`gchar*', `Glib::ustring', `Glib::convert_return_gchar_ptr_to_ustring($3)') |
| 150 |
_WRAP_VFUNC(Glib::ustring get_current_uri() const, "get_current_uri") |
| 151 |
|
| 152 |
#m4 _CONVERSION(`const char*',`const Glib::ustring&',__GCHARP_TO_USTRING) |
| 153 |
//_WRAP_VFUNC(bool select_uri(const Glib::ustring& uri), "select_uri", errthrow) |
| 154 |
_WRAP_VFUNC(void unselect_uri(const Glib::ustring& uri), "unselect_uri") |
| 155 |
_WRAP_VFUNC(void select_all(), "select_all") |
| 156 |
_WRAP_VFUNC(void unselect_all(), "unselect_all") |
| 157 |
//_WRAP_VFUNC(ArrayHandle_RecentInfos get_items() const, "get_items") |
| 158 |
_WRAP_VFUNC(Glib::RefPtr<RecentManager> get_recent_manager(), "get_recent_manager") |
| 159 |
|
| 160 |
#m4 _CONVERSION(`GtkRecentFilter*',`const Glib::RefPtr<RecentFilter>&',`Glib::wrap($3, true)') |
| 161 |
_WRAP_VFUNC(void add_filter(const Glib::RefPtr<RecentFilter>& filter), "add_filter") |
| 162 |
_WRAP_VFUNC(void remove_filter(const Glib::RefPtr<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 |