Debian Codegraph @

gtk/src/recentmanager.hg

raw
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 _CONFIGINCLUDE(gtkmmconfig.h)
18
19 #include <vector>
20
21 #include <gdkmm/screen.h>
22 #include <gdkmm/pixbuf.h>
23
24 #include <gtkmm/recentinfo.h>
25
26 #include <glibmm/object.h>
27
28 _DEFS(gtkmm,gtk)
29 _PINCLUDE(glibmm/private/object_p.h)
30
31 namespace Gtk
32 {
33
34 /** Exception class for Gtk::RecentManager errors.
35 */
36 _WRAP_GERROR(RecentManagerError, GtkRecentManagerError, GTK_RECENT_MANAGER_ERROR, decl_prefix GTKMM_API)
37
38 /** @defgroup RecentFiles RecentFiles
39 */
40
41 /** RecentManager provides a facility for adding, removing and
42 * looking up recently used files. Each recently used file is
43 * identified by its URI, and has meta-data associated to it, like
44 * the names and command lines of the applications that have
45 * registered it, the number of time each application has registered
46 * the same file, the mime type of the file and whether the file
47 * should be displayed only by the applications that have
48 * registered it.
49 *
50 * The RecentManager acts like a database of all the recently
51 * used files. You can create new RecentManager objects, but
52 * it is more efficient to use the standard recent manager for
53 * the Gdk::Screen so that informations about the recently used
54 * files is shared with other people using them. Normally, you
55 * retrieve the recent manager for a particular screen using
56 * get_for_screen() and it will contain information about current
57 * recent manager for that screen.
58 *
59 * @newin{2,10}
60 *
61 * @ingroup RecentFiles
62 */
63 class GTKMM_API RecentManager : public Glib::Object
64 {
65 _CLASS_GOBJECT(RecentManager, GtkRecentManager, GTK_RECENT_MANAGER, Glib::Object, GObject, , , GTKMM_API)
66
67 protected:
68 _CTOR_DEFAULT
69
70 public:
71 _WRAP_CREATE()
72
73 _WRAP_METHOD(static Glib::RefPtr<RecentManager> get_default(), gtk_recent_manager_get_default, refreturn)
74
75 /** Meta-data passed to add_item(). You should
76 * use RecentManager::Data if you want to control the meta-data associated
77 * to an entry of the recently used files list when you are adding
78 * a new file to it.
79 *
80 * - display_name: the string to be used when displaying the file inside a RecentChooser
81 * - description: a user readable description of the file
82 * - mime_type: the mime type of the file
83 * - app_name: the name of the application that is registering the file
84 * - app_exec: the command line that should be used when launching the file
85 * - groups: the list of group names to which the file belongs to
86 * - is_private: whether the file should be displayed only by the applications that have registered it
87 */
88 class Data
89 {
90 public:
91 Glib::ustring display_name;
92 Glib::ustring description;
93
94 Glib::ustring mime_type;
95
96 Glib::ustring app_name;
97 Glib::ustring app_exec;
98
99 std::vector<Glib::ustring> groups;
100
101 bool is_private;
102 };
103
104 /** Adds a new resource into the recently used resources list. This function
105 * will try and guess some of the meta-data associated to a URI. If you
106 * know some of meta-data about the document yourself, set the desired
107 * fields of a RecentManager::Data structure and pass it to add_item().
108 */
109 _WRAP_METHOD(bool add_item(const Glib::ustring& uri), gtk_recent_manager_add_item, errthrow)
110
111 /** Adds a new resource into the recently used resources list, taking
112 * meta data from the given Data instead of guessing it from the URI.
113 */
114 bool add_item(const Glib::ustring& uri, const Data& recent_data);
115 _IGNORE(gtk_recent_manager_add_full)
116
117 _WRAP_METHOD(bool remove_item(const Glib::ustring& uri), gtk_recent_manager_remove_item, errthrow)
118 _WRAP_METHOD(Glib::RefPtr<RecentInfo> lookup_item(const Glib::ustring& uri), gtk_recent_manager_lookup_item, errthrow)
119 _WRAP_METHOD(Glib::RefPtr<const RecentInfo> lookup_item(const Glib::ustring& uri) const, gtk_recent_manager_lookup_item, errthrow)
120 _WRAP_METHOD(bool has_item(const Glib::ustring& uri) const, gtk_recent_manager_has_item)
121 _WRAP_METHOD(bool move_item(const Glib::ustring& uri, const Glib::ustring& new_uri), gtk_recent_manager_move_item, errthrow)
122
123 #m4 _CONVERSION(`GList*',`std::vector<Glib::RefPtr<RecentInfo> >',`Glib::ListHandler<Glib::RefPtr<RecentInfo>, RecentInfoTraits>::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
124 _WRAP_METHOD(std::vector<Glib::RefPtr<RecentInfo> > get_items() const, gtk_recent_manager_get_items)
125
126 _WRAP_METHOD(int purge_items(), gtk_recent_manager_purge_items, errthrow)
127
128 //TODO: Who needs this typedef? Remove when we can break API?
129 /// For instance, void on_changed();
130 typedef sigc::slot<void> SlotChanged;
131
132 _WRAP_SIGNAL(void changed(), "changed")
133
134 _WRAP_PROPERTY("filename", Glib::ustring)
135 _WRAP_PROPERTY("size", int)
136 };
137
138 } // namespace Gtk