Top | ![]() |
![]() |
![]() |
![]() |
The XAppFavorites class allows applications display frequently-used files and provide a safe mechanism for launching them.
A list of XAppFavoriteInfos can be retrieved in full, or only for specific mimetypes.
A favorites uri scheme is also available if the xapp gtk3 module is loaded and this also makes the uri available as a shortcut in file dialogs.
XAppFavorites are new for 2.0
XAppFavorites *
xapp_favorites_get_default (void
);
Returns the XAppFavorites instance.
Since: 2.0
GList * xapp_favorites_get_favorites (XAppFavorites *favorites
,const gchar * const *mimetypes
);
Gets a list of all favorites. If mimetype is not NULL
, the list will
contain only favorites with that mimetype.
favorites |
The XAppFavorites |
|
mimetypes |
The mimetypes to filter by for results. |
[nullable][array zero-terminated=1] |
a list of XAppFavoriteInfos. Free the list with g_list_free, free elements with xapp_favorite_info_free.
[element-type XAppFavoriteInfo][transfer full]
Since: 2.0
gint
xapp_favorites_get_n_favorites (XAppFavorites *favorites
);
Since: 2.0
XAppFavoriteInfo * xapp_favorites_find_by_display_name (XAppFavorites *favorites
,const gchar *display_name
);
Looks for an XAppFavoriteInfo that corresponds to display_name
.
favorites |
The XAppFavorites |
|
display_name |
The display name to lookup info for. |
[not nullable] |
an XAppFavoriteInfo or NULL if one was not found. This is owned by the favorites manager and should not be freed.
[transfer none]
Since: 2.0
XAppFavoriteInfo * xapp_favorites_find_by_uri (XAppFavorites *favorites
,const gchar *uri
);
Looks for an XAppFavoriteInfo that corresponds to uri
.
an XAppFavoriteInfo or NULL if one was not found. This is owned by the favorites manager and should not be freed.
[transfer none]
Since: 2.0
void xapp_favorites_add (XAppFavorites *favorites
,const gchar *uri
);
Adds a new favorite. If the uri already exists, this does nothing.
Since: 2.0
void xapp_favorites_remove (XAppFavorites *favorites
,const gchar *uri
);
Removes a favorite from the list.
Since: 2.0
void xapp_favorites_launch (XAppFavorites *favorites
,const gchar *uri
,guint32 timestamp
);
Opens a favorite in its default app.
favorites |
The XAppFavorites |
|
uri |
The uri for the favorite to launch |
|
timestamp |
The timestamp from an event or 0 |
Since: 2.0
void xapp_favorites_rename (XAppFavorites *favorites
,const gchar *old_uri
,const gchar *new_uri
);
Removes old_uri and adds new_uri. This is mainly for file managers to use as a convenience instead of add/remove, and guarantees the result, without having to worry about multiple dbus calls (gsettings).
Since: 2.0
XAppFavoriteInfo *
xapp_favorite_info_copy (const XAppFavoriteInfo *info
);
Makes an exact copy of an existing XAppFavoriteInfo.
void
xapp_favorite_info_free (XAppFavoriteInfo *info
);
Destroys the XAppFavoriteInfo.
Since 2.0
void (*XAppFavoritesItemSelectedCallback) (XAppFavorites *favorites
,const gchar *uri
,gpointer user_data
);
GtkWidget * xapp_favorites_create_menu (XAppFavorites *favorites
,const gchar **mimetypes
,XAppFavoritesItemSelectedCallback callback
,gpointer user_data
,GDestroyNotify func
);
Generates a GtkMenu widget populated with favorites. The callback will be called when a menu item has been activated, and will include the uri of the respective item.
favorites |
The XAppFavorites instance. |
|
mimetypes |
The mimetypes to filter for, or NULL to include all favorites. |
[nullable] |
callback |
(closure user_data): The callback to use when a menu item has been selected. |
[scope notified] |
user_data |
The data to pass to the callback. |
[closure] |
func |
Destroy function for user_data |
a new GtkMenu populated with a list of favorites, or NULL if there are no favorites.
[transfer full]
Since: 2.0
GList * xapp_favorites_create_actions (XAppFavorites *favorites
,const gchar **mimetypes
);
Generates a list of favorite GtkActions.
favorites |
The XAppFavorites instance. |
|
mimetypes |
The mimetypes to filter for, or NULL to include all favorites. |
[nullable] |
a new GtkActionGroup populated with a list of favorites, or NULL if there are no favorites.
[element-type Gtk.Action][transfer full]
Since: 2.0
struct XAppFavoriteInfo { gchar *uri; gchar *display_name; gchar *cached_mimetype; };
Information related to a single favorite file.
gchar * |
The uri to the favorite file. |
|
gchar * |
The name for use when displaying the item. This may not exactly match the filename if there are files with the same name but in different folders. |
|
gchar * |
The mimetype calculated for the uri when it was added to favorites. |
“changed”
signalvoid user_function (XAppFavorites *xappfavorites, gpointer user_data)
Notifies when the favorites list has changed.
Flags: Action