Functions
g_bookmark_file_to_data ()
gchar *
g_bookmark_file_to_data (GBookmarkFile *bookmark,
gsize *length,
GError **error);
This function outputs bookmark
as a string.
Returns
a newly allocated string holding the contents of the GBookmarkFile.
[array length=length][element-type guint8]
Since: 2.12
g_bookmark_file_to_file ()
gboolean
g_bookmark_file_to_file (GBookmarkFile *bookmark,
const gchar *filename,
GError **error);
This function outputs bookmark
into a file. The write process is
guaranteed to be atomic by using g_file_set_contents() internally.
Returns
TRUE if the file was successfully written.
Since: 2.12
g_bookmark_file_has_item ()
gboolean
g_bookmark_file_has_item (GBookmarkFile *bookmark,
const gchar *uri);
Looks whether the desktop bookmark has an item with its URI set to uri
.
Returns
TRUE if uri
is inside bookmark
, FALSE otherwise
Since: 2.12
g_bookmark_file_get_size ()
gint
g_bookmark_file_get_size (GBookmarkFile *bookmark);
Gets the number of bookmarks inside bookmark
.
Returns
the number of bookmarks
Since: 2.12
g_bookmark_file_get_uris ()
gchar **
g_bookmark_file_get_uris (GBookmarkFile *bookmark,
gsize *length);
Returns all URIs of the bookmarks in the bookmark file bookmark
.
The array of returned URIs will be NULL-terminated, so length
may
optionally be NULL.
Returns
a newly allocated NULL-terminated array of strings.
Use g_strfreev() to free it.
[array length=length][transfer full]
Since: 2.12
g_bookmark_file_get_title ()
gchar *
g_bookmark_file_get_title (GBookmarkFile *bookmark,
const gchar *uri,
GError **error);
Returns the title of the bookmark for uri
.
If uri
is NULL, the title of bookmark
is returned.
In the event the URI cannot be found, NULL is returned and
error
is set to G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
Returns
a newly allocated string or NULL if the specified
URI cannot be found.
Since: 2.12
g_bookmark_file_get_description ()
gchar *
g_bookmark_file_get_description (GBookmarkFile *bookmark,
const gchar *uri,
GError **error);
Retrieves the description of the bookmark for uri
.
In the event the URI cannot be found, NULL is returned and
error
is set to G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
Returns
a newly allocated string or NULL if the specified
URI cannot be found.
Since: 2.12
g_bookmark_file_get_groups ()
gchar **
g_bookmark_file_get_groups (GBookmarkFile *bookmark,
const gchar *uri,
gsize *length,
GError **error);
Retrieves the list of group names of the bookmark for uri
.
In the event the URI cannot be found, NULL is returned and
error
is set to G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
The returned array is NULL terminated, so length
may optionally
be NULL.
Returns
a newly allocated NULL-terminated array of group names.
Use g_strfreev() to free it.
[array length=length][transfer full]
Since: 2.12
g_bookmark_file_get_applications ()
gchar **
g_bookmark_file_get_applications (GBookmarkFile *bookmark,
const gchar *uri,
gsize *length,
GError **error);
Retrieves the names of the applications that have registered the
bookmark for uri
.
In the event the URI cannot be found, NULL is returned and
error
is set to G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
Returns
a newly allocated NULL-terminated array of strings.
Use g_strfreev() to free it.
[array length=length][transfer full]
Since: 2.12
g_bookmark_file_set_title ()
void
g_bookmark_file_set_title (GBookmarkFile *bookmark,
const gchar *uri,
const gchar *title);
Sets title
as the title of the bookmark for uri
inside the
bookmark file bookmark
.
If uri
is NULL, the title of bookmark
is set.
If a bookmark for uri
cannot be found then it is created.
Since: 2.12
g_bookmark_file_set_description ()
void
g_bookmark_file_set_description (GBookmarkFile *bookmark,
const gchar *uri,
const gchar *description);
Sets description
as the description of the bookmark for uri
.
If uri
is NULL, the description of bookmark
is set.
If a bookmark for uri
cannot be found then it is created.
Since: 2.12
g_bookmark_file_set_mime_type ()
void
g_bookmark_file_set_mime_type (GBookmarkFile *bookmark,
const gchar *uri,
const gchar *mime_type);
Sets mime_type
as the MIME type of the bookmark for uri
.
If a bookmark for uri
cannot be found then it is created.
Since: 2.12
g_bookmark_file_set_is_private ()
void
g_bookmark_file_set_is_private (GBookmarkFile *bookmark,
const gchar *uri,
gboolean is_private);
Sets the private flag of the bookmark for uri
.
If a bookmark for uri
cannot be found then it is created.
Since: 2.12
g_bookmark_file_set_icon ()
void
g_bookmark_file_set_icon (GBookmarkFile *bookmark,
const gchar *uri,
const gchar *href,
const gchar *mime_type);
Sets the icon for the bookmark for uri
. If href
is NULL, unsets
the currently set icon. href
can either be a full URL for the icon
file or the icon name following the Icon Naming specification.
If no bookmark for uri
is found one is created.
Since: 2.12
g_bookmark_file_set_added ()
void
g_bookmark_file_set_added (GBookmarkFile *bookmark,
const gchar *uri,
time_t added);
Sets the time the bookmark for uri
was added into bookmark
.
If no bookmark for uri
is found then it is created.
Since: 2.12
g_bookmark_file_set_groups ()
void
g_bookmark_file_set_groups (GBookmarkFile *bookmark,
const gchar *uri,
const gchar **groups,
gsize length);
Sets a list of group names for the item with URI uri
. Each previously
set group name list is removed.
If uri
cannot be found then an item for it is created.
Since: 2.12
g_bookmark_file_set_modified ()
void
g_bookmark_file_set_modified (GBookmarkFile *bookmark,
const gchar *uri,
time_t modified);
Sets the last time the bookmark for uri
was last modified.
If no bookmark for uri
is found then it is created.
The "modified" time should only be set when the bookmark's meta-data
was actually changed. Every function of GBookmarkFile that
modifies a bookmark also changes the modification time, except for
g_bookmark_file_set_visited().
Since: 2.12
g_bookmark_file_set_visited ()
void
g_bookmark_file_set_visited (GBookmarkFile *bookmark,
const gchar *uri,
time_t visited);
Sets the time the bookmark for uri
was last visited.
If no bookmark for uri
is found then it is created.
The "visited" time should only be set if the bookmark was launched,
either using the command line retrieved by g_bookmark_file_get_app_info()
or by the default application for the bookmark's MIME type, retrieved
using g_bookmark_file_get_mime_type(). Changing the "visited" time
does not affect the "modified" time.
Since: 2.12
g_bookmark_file_set_app_info ()
gboolean
g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
const gchar *exec,
gint count,
time_t stamp,
GError **error);
Sets the meta-data of application name
inside the list of
applications that have registered a bookmark for uri
inside
bookmark
.
You should rarely use this function; use g_bookmark_file_add_application()
and g_bookmark_file_remove_application() instead.
name
can be any UTF-8 encoded string used to identify an
application.
exec
can have one of these two modifiers: "%f", which will
be expanded as the local file name retrieved from the bookmark's
URI; "%u", which will be expanded as the bookmark's URI.
The expansion is done automatically when retrieving the stored
command line using the g_bookmark_file_get_app_info() function.
count
is the number of times the application has registered the
bookmark; if is < 0, the current registration count will be increased
by one, if is 0, the application with name
will be removed from
the list of registered applications.
stamp
is the Unix time of the last registration; if it is -1, the
current time will be used.
If you try to remove an application by setting its registration count to
zero, and no bookmark for uri
is found, FALSE is returned and
error
is set to G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
in the event that no application name
has registered a bookmark
for uri
, FALSE is returned and error is set to
G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark
for uri
is found, one is created.
Returns
TRUE if the application's meta-data was successfully
changed.
Since: 2.12
g_bookmark_file_add_group ()
void
g_bookmark_file_add_group (GBookmarkFile *bookmark,
const gchar *uri,
const gchar *group);
Adds group
to the list of groups to which the bookmark for uri
belongs to.
If no bookmark for uri
is found then it is created.
Since: 2.12
g_bookmark_file_add_application ()
void
g_bookmark_file_add_application (GBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
const gchar *exec);
Adds the application with name
and exec
to the list of
applications that have registered a bookmark for uri
into
bookmark
.
Every bookmark inside a GBookmarkFile must have at least an
application registered. Each application must provide a name, a
command line useful for launching the bookmark, the number of times
the bookmark has been registered by the application and the last
time the application registered this bookmark.
If name
is NULL, the name of the application will be the
same returned by g_get_application_name(); if exec
is NULL, the
command line will be a composition of the program name as
returned by g_get_prgname() and the "%u" modifier, which will be
expanded to the bookmark's URI.
This function will automatically take care of updating the
registrations count and timestamping in case an application
with the same name
had already registered a bookmark for
uri
inside bookmark
.
If no bookmark for uri
is found, one is created.
Since: 2.12
g_bookmark_file_remove_item ()
gboolean
g_bookmark_file_remove_item (GBookmarkFile *bookmark,
const gchar *uri,
GError **error);
Removes the bookmark for uri
from the bookmark file bookmark
.
Returns
TRUE if the bookmark was removed successfully.
Since: 2.12
g_bookmark_file_move_item ()
gboolean
g_bookmark_file_move_item (GBookmarkFile *bookmark,
const gchar *old_uri,
const gchar *new_uri,
GError **error);
Changes the URI of a bookmark item from old_uri
to new_uri
. Any
existing bookmark for new_uri
will be overwritten. If new_uri
is
NULL, then the bookmark is removed.
In the event the URI cannot be found, FALSE is returned and
error
is set to G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
Returns
TRUE if the URI was successfully changed
Since: 2.12