]> Pileus Git - ~andy/gtk/blob - gtk/gtkrecentmanager.h
whitespace cleanup: remove trailing whitespace and excess newlines and
[~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_DISABLE_SINGLE_INCLUDES) && !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 <glib-object.h>
29 #include <gdk-pixbuf/gdk-pixbuf.h>
30 #include <gdk/gdk.h>
31 #include <time.h>
32
33 G_BEGIN_DECLS
34
35 #define GTK_TYPE_RECENT_INFO                    (gtk_recent_info_get_type ())
36
37 #define GTK_TYPE_RECENT_MANAGER                 (gtk_recent_manager_get_type ())
38 #define GTK_RECENT_MANAGER(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_MANAGER, GtkRecentManager))
39 #define GTK_IS_RECENT_MANAGER(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_MANAGER))
40 #define GTK_RECENT_MANAGER_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_MANAGER, GtkRecentManagerClass))
41 #define GTK_IS_RECENT_MANAGER_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_MANAGER))
42 #define GTK_RECENT_MANAGER_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_MANAGER, GtkRecentManagerClass))
43
44 typedef struct _GtkRecentInfo           GtkRecentInfo;
45 typedef struct _GtkRecentData           GtkRecentData;
46 typedef struct _GtkRecentManager        GtkRecentManager;
47 typedef struct _GtkRecentManagerClass   GtkRecentManagerClass;
48 typedef struct _GtkRecentManagerPrivate GtkRecentManagerPrivate;
49
50 /**
51  * GtkRecentData:
52  * @display_name: a UTF-8 encoded string, containing the name of the recently
53  *   used resource to be displayed, or %NULL;
54  * @description: a UTF-8 encoded string, containing a short description of
55  *   the resource, or %NULL;
56  * @mime_type: the MIME type of the resource;
57  * @app_name: the name of the application that is registering this recently
58  *   used resource;
59  * @app_exec: command line used to launch this resource; may contain the
60  *   "&percnt;f" and "&percnt;u" escape characters which will be expanded
61  *   to the resource file path and URI respectively when the command line
62  *   is retrieved;
63  * @groups: a vector of strings containing groups names;
64  * @is_private: whether this resource should be displayed only by the
65  *   applications that have registered it or not.
66  *
67  * Meta-data to be passed to gtk_recent_manager_add_full() when
68  * registering a recently used resource.
69  **/
70 struct _GtkRecentData
71 {
72   gchar *display_name;
73   gchar *description;
74
75   gchar *mime_type;
76
77   gchar *app_name;
78   gchar *app_exec;
79
80   gchar **groups;
81
82   gboolean is_private;
83 };
84
85 struct _GtkRecentManager
86 {
87   /*< private >*/
88   GObject parent_instance;
89
90   GtkRecentManagerPrivate *priv;
91 };
92
93 struct _GtkRecentManagerClass
94 {
95   /*< private >*/
96   GObjectClass parent_class;
97
98   void (*changed) (GtkRecentManager *manager);
99
100   /* padding for future expansion */
101   void (*_gtk_recent1) (void);
102   void (*_gtk_recent2) (void);
103   void (*_gtk_recent3) (void);
104   void (*_gtk_recent4) (void);
105 };
106
107 /**
108  * GtkRecentManagerError:
109  * @GTK_RECENT_MANAGER_ERROR_NOT_FOUND: the URI specified does not exists in
110  *   the recently used resources list.
111  * @GTK_RECENT_MANAGER_ERROR_INVALID_URI: the URI specified is not valid.
112  * @GTK_RECENT_MANAGER_ERROR_INVALID_ENCODING: the supplied string is not
113  *   UTF-8 encoded.
114  * @GTK_RECENT_MANAGER_ERROR_NOT_REGISTERED: no application has registered
115  *   the specified item.
116  * @GTK_RECENT_MANAGER_ERROR_READ: failure while reading the recently used
117  *   resources file.
118  * @GTK_RECENT_MANAGER_ERROR_WRITE: failure while writing the recently used
119  *   resources file.
120  * @GTK_RECENT_MANAGER_ERROR_UNKNOWN: unspecified error.
121  *
122  * Error codes for GtkRecentManager operations
123  **/
124 typedef enum
125 {
126   GTK_RECENT_MANAGER_ERROR_NOT_FOUND,
127   GTK_RECENT_MANAGER_ERROR_INVALID_URI,
128   GTK_RECENT_MANAGER_ERROR_INVALID_ENCODING,
129   GTK_RECENT_MANAGER_ERROR_NOT_REGISTERED,
130   GTK_RECENT_MANAGER_ERROR_READ,
131   GTK_RECENT_MANAGER_ERROR_WRITE,
132   GTK_RECENT_MANAGER_ERROR_UNKNOWN
133 } GtkRecentManagerError;
134
135 #define GTK_RECENT_MANAGER_ERROR        (gtk_recent_manager_error_quark ())
136 GQuark  gtk_recent_manager_error_quark (void);
137
138
139 GType             gtk_recent_manager_get_type       (void) G_GNUC_CONST;
140
141 GtkRecentManager *gtk_recent_manager_new            (void);
142 GtkRecentManager *gtk_recent_manager_get_default    (void);
143
144 #ifndef GTK_DISABLE_DEPRECATED
145 GtkRecentManager *gtk_recent_manager_get_for_screen (GdkScreen            *screen);
146 void              gtk_recent_manager_set_screen     (GtkRecentManager     *manager,
147                                                      GdkScreen            *screen);
148 #endif
149
150 gboolean          gtk_recent_manager_add_item       (GtkRecentManager     *manager,
151                                                      const gchar          *uri);
152 gboolean          gtk_recent_manager_add_full       (GtkRecentManager     *manager,
153                                                      const gchar          *uri,
154                                                      const GtkRecentData  *recent_data);
155 gboolean          gtk_recent_manager_remove_item    (GtkRecentManager     *manager,
156                                                      const gchar          *uri,
157                                                      GError              **error);
158 GtkRecentInfo *   gtk_recent_manager_lookup_item    (GtkRecentManager     *manager,
159                                                      const gchar          *uri,
160                                                      GError              **error);
161 gboolean          gtk_recent_manager_has_item       (GtkRecentManager     *manager,
162                                                      const gchar          *uri);
163 gboolean          gtk_recent_manager_move_item      (GtkRecentManager     *manager,
164                                                      const gchar          *uri,
165                                                      const gchar          *new_uri,
166                                                      GError              **error);
167 void              gtk_recent_manager_set_limit      (GtkRecentManager     *manager,
168                                                      gint                  limit);
169 gint              gtk_recent_manager_get_limit      (GtkRecentManager     *manager);
170 GList *           gtk_recent_manager_get_items      (GtkRecentManager     *manager);
171 gint              gtk_recent_manager_purge_items    (GtkRecentManager     *manager,
172                                                      GError              **error);
173
174
175 GType                 gtk_recent_info_get_type             (void) G_GNUC_CONST;
176
177 GtkRecentInfo *       gtk_recent_info_ref                  (GtkRecentInfo  *info);
178 void                  gtk_recent_info_unref                (GtkRecentInfo  *info);
179
180 G_CONST_RETURN gchar *gtk_recent_info_get_uri              (GtkRecentInfo  *info);
181 G_CONST_RETURN gchar *gtk_recent_info_get_display_name     (GtkRecentInfo  *info);
182 G_CONST_RETURN gchar *gtk_recent_info_get_description      (GtkRecentInfo  *info);
183 G_CONST_RETURN gchar *gtk_recent_info_get_mime_type        (GtkRecentInfo  *info);
184 time_t                gtk_recent_info_get_added            (GtkRecentInfo  *info);
185 time_t                gtk_recent_info_get_modified         (GtkRecentInfo  *info);
186 time_t                gtk_recent_info_get_visited          (GtkRecentInfo  *info);
187 gboolean              gtk_recent_info_get_private_hint     (GtkRecentInfo  *info);
188 gboolean              gtk_recent_info_get_application_info (GtkRecentInfo  *info,
189                                                             const gchar    *app_name,
190                                                             gchar         **app_exec,
191                                                             guint          *count,
192                                                             time_t         *time_);
193 gchar **              gtk_recent_info_get_applications     (GtkRecentInfo  *info,
194                                                             gsize          *length) G_GNUC_MALLOC;
195 gchar *               gtk_recent_info_last_application     (GtkRecentInfo  *info) G_GNUC_MALLOC;
196 gboolean              gtk_recent_info_has_application      (GtkRecentInfo  *info,
197                                                             const gchar    *app_name);
198 gchar **              gtk_recent_info_get_groups           (GtkRecentInfo  *info,
199                                                             gsize          *length) G_GNUC_MALLOC;
200 gboolean              gtk_recent_info_has_group            (GtkRecentInfo  *info,
201                                                             const gchar    *group_name);
202 GdkPixbuf *           gtk_recent_info_get_icon             (GtkRecentInfo  *info,
203                                                             gint            size);
204 gchar *               gtk_recent_info_get_short_name       (GtkRecentInfo  *info) G_GNUC_MALLOC;
205 gchar *               gtk_recent_info_get_uri_display      (GtkRecentInfo  *info) G_GNUC_MALLOC;
206 gint                  gtk_recent_info_get_age              (GtkRecentInfo  *info);
207 gboolean              gtk_recent_info_is_local             (GtkRecentInfo  *info);
208 gboolean              gtk_recent_info_exists               (GtkRecentInfo  *info);
209 gboolean              gtk_recent_info_match                (GtkRecentInfo  *info_a,
210                                                             GtkRecentInfo  *info_b);
211
212 /* private */
213 void _gtk_recent_manager_sync (void);
214
215 G_END_DECLS
216
217 #endif /* __GTK_RECENT_MANAGER_H__ */