]> Pileus Git - ~andy/gtk/blob - gtk/gtkrecentmanager.h
Remove GtkRecenManager:limit deprecated property
[~andy/gtk] / gtk / gtkrecentmanager.h
1 /* GTK - The GIMP Toolkit
2  * gtkrecentmanager.h: a manager for the recently used resources
3  *
4  * Copyright (C) 2006 Emmanuele Bassi
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  */
20
21 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22 #error "Only <gtk/gtk.h> can be included directly."
23 #endif
24
25 #ifndef __GTK_RECENT_MANAGER_H__
26 #define __GTK_RECENT_MANAGER_H__
27
28 #include <gdk-pixbuf/gdk-pixbuf.h>
29 #include <gdk/gdk.h>
30 #include <time.h>
31
32 G_BEGIN_DECLS
33
34 #define GTK_TYPE_RECENT_INFO                    (gtk_recent_info_get_type ())
35
36 #define GTK_TYPE_RECENT_MANAGER                 (gtk_recent_manager_get_type ())
37 #define GTK_RECENT_MANAGER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_MANAGER, GtkRecentManager))
38 #define GTK_IS_RECENT_MANAGER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_MANAGER))
39 #define GTK_RECENT_MANAGER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_MANAGER, GtkRecentManagerClass))
40 #define GTK_IS_RECENT_MANAGER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_MANAGER))
41 #define GTK_RECENT_MANAGER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_MANAGER, GtkRecentManagerClass))
42
43 typedef struct _GtkRecentInfo           GtkRecentInfo;
44 typedef struct _GtkRecentData           GtkRecentData;
45 typedef struct _GtkRecentManager        GtkRecentManager;
46 typedef struct _GtkRecentManagerClass   GtkRecentManagerClass;
47 typedef struct _GtkRecentManagerPrivate GtkRecentManagerPrivate;
48
49 /**
50  * GtkRecentData:
51  * @display_name: a UTF-8 encoded string, containing the name of the recently
52  *   used resource to be displayed, or %NULL;
53  * @description: a UTF-8 encoded string, containing a short description of
54  *   the resource, or %NULL;
55  * @mime_type: the MIME type of the resource;
56  * @app_name: the name of the application that is registering this recently
57  *   used resource;
58  * @app_exec: command line used to launch this resource; may contain the
59  *   "&percnt;f" and "&percnt;u" escape characters which will be expanded
60  *   to the resource file path and URI respectively when the command line
61  *   is retrieved;
62  * @groups: a vector of strings containing groups names;
63  * @is_private: whether this resource should be displayed only by the
64  *   applications that have registered it or not.
65  *
66  * Meta-data to be passed to gtk_recent_manager_add_full() when
67  * registering a recently used resource.
68  **/
69 struct _GtkRecentData
70 {
71   gchar *display_name;
72   gchar *description;
73
74   gchar *mime_type;
75
76   gchar *app_name;
77   gchar *app_exec;
78
79   gchar **groups;
80
81   gboolean is_private;
82 };
83
84 struct _GtkRecentManager
85 {
86   GObject parent_instance;
87
88   /* <private> */
89   GtkRecentManagerPrivate *priv;
90 };
91
92 struct _GtkRecentManagerClass
93 {
94   /*< private >*/
95   GObjectClass parent_class;
96
97   void (*changed) (GtkRecentManager *manager);
98
99   /* padding for future expansion */
100   void (*_gtk_recent1) (void);
101   void (*_gtk_recent2) (void);
102   void (*_gtk_recent3) (void);
103   void (*_gtk_recent4) (void);
104 };
105
106 /**
107  * GtkRecentManagerError:
108  * @GTK_RECENT_MANAGER_ERROR_NOT_FOUND: the URI specified does not exists in
109  *   the recently used resources list.
110  * @GTK_RECENT_MANAGER_ERROR_INVALID_URI: the URI specified is not valid.
111  * @GTK_RECENT_MANAGER_ERROR_INVALID_ENCODING: the supplied string is not
112  *   UTF-8 encoded.
113  * @GTK_RECENT_MANAGER_ERROR_NOT_REGISTERED: no application has registered
114  *   the specified item.
115  * @GTK_RECENT_MANAGER_ERROR_READ: failure while reading the recently used
116  *   resources file.
117  * @GTK_RECENT_MANAGER_ERROR_WRITE: failure while writing the recently used
118  *   resources file.
119  * @GTK_RECENT_MANAGER_ERROR_UNKNOWN: unspecified error.
120  *
121  * Error codes for GtkRecentManager operations
122  **/
123 typedef enum
124 {
125   GTK_RECENT_MANAGER_ERROR_NOT_FOUND,
126   GTK_RECENT_MANAGER_ERROR_INVALID_URI,
127   GTK_RECENT_MANAGER_ERROR_INVALID_ENCODING,
128   GTK_RECENT_MANAGER_ERROR_NOT_REGISTERED,
129   GTK_RECENT_MANAGER_ERROR_READ,
130   GTK_RECENT_MANAGER_ERROR_WRITE,
131   GTK_RECENT_MANAGER_ERROR_UNKNOWN
132 } GtkRecentManagerError;
133
134 #define GTK_RECENT_MANAGER_ERROR        (gtk_recent_manager_error_quark ())
135 GQuark  gtk_recent_manager_error_quark (void);
136
137
138 GType             gtk_recent_manager_get_type       (void) G_GNUC_CONST;
139
140 GtkRecentManager *gtk_recent_manager_new            (void);
141 GtkRecentManager *gtk_recent_manager_get_default    (void);
142
143 gboolean          gtk_recent_manager_add_item       (GtkRecentManager     *manager,
144                                                      const gchar          *uri);
145 gboolean          gtk_recent_manager_add_full       (GtkRecentManager     *manager,
146                                                      const gchar          *uri,
147                                                      const GtkRecentData  *recent_data);
148 gboolean          gtk_recent_manager_remove_item    (GtkRecentManager     *manager,
149                                                      const gchar          *uri,
150                                                      GError              **error);
151 GtkRecentInfo *   gtk_recent_manager_lookup_item    (GtkRecentManager     *manager,
152                                                      const gchar          *uri,
153                                                      GError              **error);
154 gboolean          gtk_recent_manager_has_item       (GtkRecentManager     *manager,
155                                                      const gchar          *uri);
156 gboolean          gtk_recent_manager_move_item      (GtkRecentManager     *manager,
157                                                      const gchar          *uri,
158                                                      const gchar          *new_uri,
159                                                      GError              **error);
160 GList *           gtk_recent_manager_get_items      (GtkRecentManager     *manager);
161 gint              gtk_recent_manager_purge_items    (GtkRecentManager     *manager,
162                                                      GError              **error);
163
164
165 GType                 gtk_recent_info_get_type             (void) G_GNUC_CONST;
166
167 GtkRecentInfo *       gtk_recent_info_ref                  (GtkRecentInfo  *info);
168 void                  gtk_recent_info_unref                (GtkRecentInfo  *info);
169
170 G_CONST_RETURN gchar *gtk_recent_info_get_uri              (GtkRecentInfo  *info);
171 G_CONST_RETURN gchar *gtk_recent_info_get_display_name     (GtkRecentInfo  *info);
172 G_CONST_RETURN gchar *gtk_recent_info_get_description      (GtkRecentInfo  *info);
173 G_CONST_RETURN gchar *gtk_recent_info_get_mime_type        (GtkRecentInfo  *info);
174 time_t                gtk_recent_info_get_added            (GtkRecentInfo  *info);
175 time_t                gtk_recent_info_get_modified         (GtkRecentInfo  *info);
176 time_t                gtk_recent_info_get_visited          (GtkRecentInfo  *info);
177 gboolean              gtk_recent_info_get_private_hint     (GtkRecentInfo  *info);
178 gboolean              gtk_recent_info_get_application_info (GtkRecentInfo  *info,
179                                                             const gchar    *app_name,
180                                                             const gchar   **app_exec,
181                                                             guint          *count,
182                                                             time_t         *time_);
183 gchar **              gtk_recent_info_get_applications     (GtkRecentInfo  *info,
184                                                             gsize          *length) G_GNUC_MALLOC;
185 gchar *               gtk_recent_info_last_application     (GtkRecentInfo  *info) G_GNUC_MALLOC;
186 gboolean              gtk_recent_info_has_application      (GtkRecentInfo  *info,
187                                                             const gchar    *app_name);
188 gchar **              gtk_recent_info_get_groups           (GtkRecentInfo  *info,
189                                                             gsize          *length) G_GNUC_MALLOC;
190 gboolean              gtk_recent_info_has_group            (GtkRecentInfo  *info,
191                                                             const gchar    *group_name);
192 GdkPixbuf *           gtk_recent_info_get_icon             (GtkRecentInfo  *info,
193                                                             gint            size);
194 gchar *               gtk_recent_info_get_short_name       (GtkRecentInfo  *info) G_GNUC_MALLOC;
195 gchar *               gtk_recent_info_get_uri_display      (GtkRecentInfo  *info) G_GNUC_MALLOC;
196 gint                  gtk_recent_info_get_age              (GtkRecentInfo  *info);
197 gboolean              gtk_recent_info_is_local             (GtkRecentInfo  *info);
198 gboolean              gtk_recent_info_exists               (GtkRecentInfo  *info);
199 gboolean              gtk_recent_info_match                (GtkRecentInfo  *info_a,
200                                                             GtkRecentInfo  *info_b);
201
202 /* private */
203 void _gtk_recent_manager_sync (void);
204
205 G_END_DECLS
206
207 #endif /* __GTK_RECENT_MANAGER_H__ */