BookmarkFile
Object Hierarchy:
GLib.BookmarkFile
GLib.BookmarkFile
GLib.BookmarkFile
Description:
[ Compact ] [ Version ( since = "2.12" ) ] [ CCode ( copy_function = "g_bookmark_file_copy" , free_function = "g_bookmark_file_free" , type_id = "G_TYPE_BOOKMARK_FILE" ) ]public class BookmarkFile
`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].
Content:
Creation methods:
Methods:
public void 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 this .
public void add_group (string uri, string group)
Adds group
to the list of groups to which the bookmark for
uri
belongs to.
public BookmarkFile copy ()
Deeply copies a this
BookmarkFile object to a new one.
public time_t get_added (string uri) throws BookmarkFileError
Gets the time the bookmark for uri
was added to
this
public unowned DateTime get_added_date_time (string uri) throws BookmarkFileError
Gets the time the bookmark for uri
was added to
this
public bool get_app_info (string uri, string name, out string exec, out uint count, out time_t stamp) throws BookmarkFileError
Gets the registration information of app_name
for the bookmark
for uri
.
public bool get_application_info (string uri, string name, out string exec, out uint count, out unowned DateTime ? stamp) throws BookmarkFileError
Gets the registration information of app_name
for the bookmark
for uri
.
public string [] get_applications (string uri) throws BookmarkFileError
Retrieves the names of the applications that have registered the bookmark
for uri
.
public string get_description (string uri) throws BookmarkFileError
Retrieves the description of the bookmark for uri
.
public string [] get_groups (string uri) throws BookmarkFileError
Retrieves the list of group names of the bookmark for uri
.
public bool get_icon (string uri, out string href, out string mime_type) throws BookmarkFileError
Gets the icon of the bookmark for uri
.
public bool get_is_private (string uri) throws BookmarkFileError
Gets whether the private flag of the bookmark for uri
is set.
public string get_mime_type (string uri) throws BookmarkFileError
Retrieves the MIME type of the resource pointed by uri
.
public time_t get_modified (string uri) throws BookmarkFileError
Gets the time when the bookmark for uri
was last modified.
public unowned DateTime get_modified_date_time (string uri) throws BookmarkFileError
Gets the time when the bookmark for uri
was last modified.
public int get_size ()
Gets the number of bookmarks inside this .
public string get_title (string uri) throws BookmarkFileError
Returns the title of the bookmark for uri
.
public string [] get_uris ()
Returns all URIs of the bookmarks in the bookmark file
this .
public time_t get_visited (string uri) throws BookmarkFileError
Gets the time the bookmark for uri
was last visited.
public unowned DateTime get_visited_date_time (string uri) throws BookmarkFileError
Gets the time the bookmark for uri
was last visited.
public bool has_application (string uri, string name) throws BookmarkFileError
Checks whether the bookmark for uri
inside
this has been registered by application name
.
public bool has_group (string uri, string group) throws BookmarkFileError
Checks whether group
appears in the list of groups to which the
bookmark for uri
belongs to.
public bool has_item (string uri)
Looks whether the desktop bookmark has an item with its URI set to uri
.
public bool load_from_data (string data, size_t length) throws BookmarkFileError
Loads a bookmark file from memory into an empty
BookmarkFile structure.
public bool load_from_data_dirs (string file, out string full_path) throws BookmarkFileError , FileError
This function looks for a desktop bookmark file named file
in
the paths returned from get_user_data_dir and
get_system_data_dirs , loads the file into
this and returns the file's full path in full_path
.
public bool load_from_file (string file) throws BookmarkFileError , FileError
Loads a desktop bookmark file into an empty BookmarkFile
structure.
public bool move_item (string old_uri, string new_uri) throws BookmarkFileError
Changes the URI of a bookmark item from old_uri
to
new_uri
.
public bool remove_application (string uri, string name) throws BookmarkFileError
Removes application registered with name
from the list of
applications that have registered a bookmark for uri
inside this .
public bool remove_group (string uri, string group) throws BookmarkFileError
Removes group
from the list of groups to which the bookmark for
uri
belongs to.
public bool remove_item (string uri) throws BookmarkFileError
Removes the bookmark for uri
from the bookmark file
this .
public void set_added (string uri, time_t added)
Sets the time the bookmark for uri
was added into
this .
public void set_added_date_time (string uri, DateTime added)
Sets the time the bookmark for uri
was added into
this .
public bool set_app_info (string uri, string name, string exec, int count, time_t stamp) throws BookmarkFileError
Sets the meta-data of application name
inside the list of
applications that have registered a bookmark for uri
inside this .
public bool set_application_info (string uri, string name, string exec, int count, DateTime ? stamp) throws BookmarkFileError
Sets the meta-data of application name
inside the list of
applications that have registered a bookmark for uri
inside this .
public void set_description (string uri, string description)
Sets description
as the description of the bookmark for
uri
.
public void set_groups (string uri, string [] groups)
Sets a list of group names for the item with URI uri
.
public void set_icon (string uri, string href, string mime_type)
Sets the icon for the bookmark for uri
.
public void set_is_private (string uri, bool is_private)
Sets the private flag of the bookmark for uri
.
public void set_mime_type (string uri, string mime_type)
Sets mime_type
as the MIME type of the bookmark for uri
.
public void set_modified (string uri, time_t modified)
Sets the last time the bookmark for uri
was last modified.
public void set_modified_date_time (string uri, DateTime modified)
Sets the last time the bookmark for uri
was last modified.
public void set_title (string uri, string title)
Sets title
as the title of the bookmark for uri
inside the bookmark file this .
public void set_visited (string uri, time_t visited)
Sets the time the bookmark for uri
was last visited.
public void set_visited_date_time (string uri, DateTime visited)
Sets the time the bookmark for uri
was last visited.
public string to_data (out size_t length) throws BookmarkFileError
This function outputs this as a string.
public bool to_file (string filename) throws BookmarkFileError , FileError
This function outputs this into a file.