[40:7] extends: object
GBookmarkFile lets you parse, edit or create files containing bookmarks.
Bookmarks refer to a URI, along with some meta-data about the resource
pointed by the URI like its MIME type, the application that is registering
the bookmark and the icon that should be used to represent the bookmark. The
data is stored using the Desktop Bookmark
Specification.
The syntax of the bookmark files is described in detail inside the Desktop
Bookmark Specification, here is a quick summary: bookmark files use a
sub-class of the XML Bookmark Exchange Language specification, consisting of
valid UTF-8 encoded XML, under the <xbel> root element; each bookmark is
stored inside a <bookmark> element, using its URI: no relative paths can be
used inside a bookmark file. The bookmark may have a user defined title and
description, to be used instead of the URI. Under the <metadata> element,
with its owner attribute set to http://freedesktop.org, is stored the
meta-data about a resource pointed by its URI. The meta-data consists of the
resource's MIME type; the applications that have registered a bookmark; the
groups to which a bookmark belongs to; a visibility flag, used to set the
bookmark as "private" to the applications and groups that has it registered;
the URI and MIME type of an icon, to be used when displaying the bookmark
inside a GUI. Here is an example of a bookmark file:
bookmarks.xbel
A bookmark file might contain more than one bookmark; each bookmark is
accessed through its URI. The important caveat of bookmark files is that when
you add a new bookmark you must also add the application that is registering
it, using [method@GLib.BookmarkFile.add_application] or
[method@GLib.BookmarkFile.set_application_info]. If a bookmark has no
applications then it won't be dumped when creating the on disk
representation, using [method@GLib.BookmarkFile.to_data] or
[method@GLib.BookmarkFile.to_file].
GBookmarkFile (Handle = null)
Creates a new empty #GBookmarkFile object. Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data() or g_bookmark_file_load_from_data_dirs() to read an existing bookmark file.
Handle is an optional native handle or wrapper whose handle to adopt; when the native constructor is called.toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.add_application (string uri, string name, string 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.
uri is a valid URI.name is the name of the application registering the bookmark or %NULL.exec is command line to be used to launch the bookmark or %NULL.None.add_group (string uri, string 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.
uri is a valid URI.group is the group name to be added.None.copy ()
Deeply copies a @bookmark #GBookmarkFile object to a new one.
the copy of @bookmark. Use g_bookmark_free() when finished using it..free ()
Frees a #GBookmarkFile.
None.get_added (string uri)
Gets the time the bookmark for @uri was added to @bookmark In the event the URI cannot be found, -1 is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
uri is a valid URI.a timestamp.get_added_date_time (string uri)
Gets the time the bookmark for @uri was added to @bookmark In the event the URI cannot be found, %NULL is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
uri is a valid URI.a #GDateTime.get_app_info (string uri, string name)
Gets the registration information of @app_name for the bookmark for @uri. See g_bookmark_file_set_application_info() for more information about the returned data. The string returned in @app_exec must be freed. In the event the URI cannot be found, %FALSE is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the event that no application with name @app_name has registered a bookmark for @uri, %FALSE is returned and error is set to %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting the command line fails, an error of the %G_SHELL_ERROR domain is set and %FALSE is returned.
uri is a valid URI.name is an application's name.exec is return location for the command line of the application, or %NULL.count is return location for the registration count, or %NULL.stamp is return location for the last registration time, or %NULL.%TRUE on success..get_application_info (string uri, string name)
Gets the registration information of @app_name for the bookmark for @uri. See g_bookmark_file_set_application_info() for more information about the returned data. The string returned in @app_exec must be freed. In the event the URI cannot be found, %FALSE is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the event that no application with name @app_name has registered a bookmark for @uri, %FALSE is returned and error is set to %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting the command line fails, an error of the %G_SHELL_ERROR domain is set and %FALSE is returned.
uri is a valid URI.name is an application's name.exec is return location for the command line of the application, or %NULL.count is return location for the registration count, or %NULL.stamp is return location for the last registration time, or %NULL.%TRUE on success..get_applications (string uri)
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
is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.uri is a valid URI.length is return location of the length of the returned list, or %NULL.a newly allocated %NULL-terminated array of strings. Use g_strfreev() to free it..get_description (string uri)
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.
uri is a valid URI.a newly allocated string or %NULL if the specified URI cannot be found..get_groups (string uri)
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.
uri is a valid URI.length is return location for the length of the returned string, or %NULL.a newly allocated %NULL-terminated array of group names. Use g_strfreev() to free it..get_icon (string uri)
Gets the icon of the bookmark for @uri. In the event the URI cannot be found, %FALSE is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
uri is a valid URI.href is return location for the icon's location or %NULL.mime_type is return location for the icon's MIME type or %NULL.%TRUE if the icon for the bookmark for the URI was found. You should free the returned strings..get_is_private (string uri)
Gets whether the private flag of the bookmark for @uri is set. In the event the URI cannot be found, %FALSE is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the event that the private flag cannot be found, %FALSE is returned and @error is set to %G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
uri is a valid URI.%TRUE if the private flag is set, %FALSE otherwise..get_mime_type (string uri)
Retrieves the MIME type of the resource pointed by @uri. In the event the URI cannot be found, %NULL is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the event that the MIME type cannot be found, %NULL is returned and @error is set to %G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
uri is a valid URI.a newly allocated string or %NULL if the specified URI cannot be found..get_modified (string uri)
Gets the time when the bookmark for @uri was last modified. In the event the URI cannot be found, -1 is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
uri is a valid URI.a timestamp.get_modified_date_time (string uri)
Gets the time when the bookmark for @uri was last modified. In the event the URI cannot be found, %NULL is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
uri is a valid URI.a #GDateTime.get_size ()
Gets the number of bookmarks inside @bookmark.
the number of bookmarks.get_title (string uri)
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.
uri is a valid URI or %NULL.a newly allocated string or %NULL if the specified URI cannot be found..get_uris ()
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.
length is return location for the number of returned URIs, or %NULL.a newly allocated %NULL-terminated array of strings. Use g_strfreev() to free it..get_visited (string uri)
Gets the time the bookmark for @uri was last visited. In the event the URI cannot be found, -1 is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
uri is a valid URI.a timestamp..get_visited_date_time (string uri)
Gets the time the bookmark for @uri was last visited. In the event the URI cannot be found, %NULL is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
uri is a valid URI.a #GDateTime.has_application (string uri, string name)
Checks whether the bookmark for @uri inside @bookmark has been registered by application @name. In the event the URI cannot be found, %FALSE is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
uri is a valid URI.name is the name of the application.%TRUE if the application @name was found.has_group (string uri, string group)
Checks whether @group appears in the list of groups to which the bookmark for @uri belongs to. In the event the URI cannot be found, %FALSE is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
uri is a valid URI.group is the group name to be searched.%TRUE if @group was found..has_item (string uri)
Looks whether the desktop bookmark has an item with its URI set to @uri.
uri is a valid URI.%TRUE if @uri is inside @bookmark, %FALSE otherwise.load_from_data (list data)
Loads a bookmark file from memory into an empty #GBookmarkFile structure. If the object cannot be created then @error is set to a #GBookmarkFileError.
data is desktop bookmarks loaded in memory.length is the length of @data in bytes.%TRUE if a desktop bookmark could be loaded..load_from_data_dirs (string file)
This function looks for a desktop bookmark file named @file in the paths returned from g_get_user_data_dir() and g_get_system_data_dirs(), loads the file into @bookmark and returns the file's full path in @full_path. If the file could not be loaded then @error is set to either a #GFileError or #GBookmarkFileError.
file is a relative path to a filename to open and parse.full_path is return location for a string containing the full path of the file, or %NULL.%TRUE if a key file could be loaded, %FALSE otherwise.load_from_file (string filename)
Loads a desktop bookmark file into an empty #GBookmarkFile structure. If the file could not be loaded then @error is set to either a #GFileError or #GBookmarkFileError.
filename is the path of a filename to load, in the GLib file name encoding.%TRUE if a desktop bookmark file could be loaded.move_item (string old_uri, string new_uri)
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.
old_uri is a valid URI.new_uri is a valid URI, or %NULL.%TRUE if the URI was successfully changed.remove_application (string uri, string name)
Removes application registered with @name from the list of applications that have registered a bookmark for @uri inside @bookmark. In the event the URI cannot be found, %FALSE is returned and @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the event that no application with name @app_name has registered a bookmark for @uri, %FALSE is returned and error is set to %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
uri is a valid URI.name is the name of the application.%TRUE if the application was successfully removed..remove_group (string uri, string group)
Removes @group from the list of groups to which the bookmark for @uri belongs to. In the event the URI cannot be found, %FALSE is returned and
is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the event no group was defined, %FALSE is returned and @error is set to %G_BOOKMARK_FILE_ERROR_INVALID_VALUE.uri is a valid URI.group is the group name to be removed.%TRUE if @group was successfully removed..remove_item (string uri)
Removes the bookmark for @uri from the bookmark file @bookmark.
uri is a valid URI.%TRUE if the bookmark was removed successfully..set_added (string uri, int added)
Sets the time the bookmark for @uri was added into @bookmark. If no bookmark for @uri is found then it is created.
uri is a valid URI.added is a timestamp or -1 to use the current time.None.set_added_date_time (string uri, object added)
Sets the time the bookmark for @uri was added into @bookmark. If no bookmark for @uri is found then it is created.
uri is a valid URI.added is a #GDateTime.None.set_app_info (string uri, string name, string exec, int count, int stamp)
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_application_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.
uri is a valid URI.name is an application's name.exec is an application's command line.count is the number of registrations done for this application.stamp is the time of the last registration for this application.%TRUE if the application's meta-data was successfully changed..set_application_info (string uri, string name, string exec, int count, object stamp)
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_application_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 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
is found, one is created.uri is a valid URI.name is an application's name.exec is an application's command line.count is the number of registrations done for this application.stamp is the time of the last registration for this application, which may be %NULL if @count is 0.%TRUE if the application's meta-data was successfully changed..set_description (string uri, string 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.
uri is a valid URI or %NULL.description is a string.None.set_groups (string uri, list groups)
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.
uri is an item's URI.groups is an array of group names, or %NULL to remove all groups.length is number of group name values in @groups.None.set_icon (string uri, string href, string 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
is found one is created.uri is a valid URI.href is the URI of the icon for the bookmark, or %NULL.mime_type is the MIME type of the icon for the bookmark.None.set_is_private (string uri, bool is_private)
Sets the private flag of the bookmark for @uri. If a bookmark for @uri cannot be found then it is created.
uri is a valid URI.is_private is %TRUE if the bookmark should be marked as private.None.set_mime_type (string uri, string 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.
uri is a valid URI.mime_type is a MIME type.None.set_modified (string uri, int 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_date_time().
uri is a valid URI.modified is a timestamp or -1 to use the current time.None.set_modified_date_time (string uri, object 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_date_time().
uri is a valid URI.modified is a #GDateTime.None.set_title (string uri, string 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.
uri is a valid URI or %NULL.title is a UTF-8 encoded string.None.set_visited (string uri, int visited)
Sets the time the bookmark for @uri was last visited. If no bookmark for
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_application_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.uri is a valid URI.visited is a timestamp or -1 to use the current time.None.set_visited_date_time (string uri, object visited)
Sets the time the bookmark for @uri was last visited. If no bookmark for
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_application_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.uri is a valid URI.visited is a #GDateTime.None.to_data ()
This function outputs @bookmark as a string.
length is return location for the length of the returned string, or %NULL.a newly allocated string holding the contents of the #GBookmarkFile.to_file (string filename)
This function outputs @bookmark into a file. The write process is guaranteed to be atomic by using g_file_set_contents() internally.
filename is path of the output file.%TRUE if the file was successfully written..