1 #ifndef __XAPP_FAVORITES_H__
2 #define __XAPP_FAVORITES_H__
3 
4 #include <stdio.h>
5 #include <gtk/gtk.h>
6 
7 #include <glib-object.h>
8 
9 G_BEGIN_DECLS
10 
11 #define XAPP_TYPE_FAVORITE_INFO (xapp_favorite_info_get_type ())
12 typedef struct _XAppFavoriteInfo XAppFavoriteInfo;
13 
14 #define XAPP_TYPE_FAVORITES           (xapp_favorites_get_type ())
15 
16 G_DECLARE_FINAL_TYPE (XAppFavorites, xapp_favorites, XAPP, FAVORITES, GObject)
17 
18 XAppFavorites        *xapp_favorites_get_default            (void);
19 GList                *xapp_favorites_get_favorites          (XAppFavorites       *favorites,
20                                                              const gchar * const *mimetypes);
21 gint                  xapp_favorites_get_n_favorites        (XAppFavorites *favorites);
22 XAppFavoriteInfo     *xapp_favorites_find_by_display_name   (XAppFavorites *favorites,
23                                                              const gchar   *display_name);
24 XAppFavoriteInfo     *xapp_favorites_find_by_uri            (XAppFavorites *favorites,
25                                                              const gchar   *uri);
26 void                  xapp_favorites_add                    (XAppFavorites *favorites,
27                                                              const gchar   *uri);
28 void                  xapp_favorites_remove                 (XAppFavorites *favorites,
29                                                              const gchar   *uri);
30 void                  xapp_favorites_launch                 (XAppFavorites *favorites,
31                                                              const gchar   *uri,
32                                                              guint32        timestamp);
33 void                  xapp_favorites_rename                 (XAppFavorites *favorites,
34                                                              const gchar   *old_uri,
35                                                              const gchar   *new_uri);
36 
37 /**
38  * XAppFavoriteInfo:
39  * @uri: The uri to the favorite file.
40  * @display_name: The name for use when displaying the item. This may not exactly match
41  * the filename if there are files with the same name but in different folders.
42  * @cached_mimetype: The mimetype calculated for the uri when it was added to favorites.
43  *
44  * Information related to a single favorite file.
45  */
46 struct _XAppFavoriteInfo
47 {
48     gchar *uri;
49     gchar *display_name;
50     gchar *cached_mimetype;
51 };
52 
53 GType             xapp_favorite_info_get_type (void) G_GNUC_CONST;
54 XAppFavoriteInfo *xapp_favorite_info_copy     (const XAppFavoriteInfo *info);
55 void              xapp_favorite_info_free     (XAppFavoriteInfo *info);
56 
57 
58 /*         XAppFavoritesMenu          */
59 
60 /**
61  * FavoritesItemSelectedCallback
62  * @favorites: the #XAppFavorites instance
63  * @uri: the uri of the favorite that was selected
64  * @user_data: Callback data
65  *
66  * Callback when an item has been selected from the favorites
67  * #GtkMenu.
68  */
69 typedef void (* XAppFavoritesItemSelectedCallback) (XAppFavorites  *favorites,
70                                                     const gchar    *uri,
71                                                     gpointer        user_data);
72 
73 GtkWidget       *xapp_favorites_create_menu (XAppFavorites                      *favorites,
74                                              const gchar                       **mimetypes,
75                                              XAppFavoritesItemSelectedCallback   callback,
76                                              gpointer                            user_data,
77                                              GDestroyNotify                      func);
78 GList           *xapp_favorites_create_actions    (XAppFavorites  *favorites,
79                                                    const gchar   **mimetypes);
80 
81 G_END_DECLS
82 
83 #endif  /* __XAPP_FAVORITES_H__ */
84