BookmarkFile

glib.bookmark_file.BookmarkFile 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 glib.bookmark_file.BookmarkFile.addApplication or glib.bookmark_file.BookmarkFile.setApplicationInfo. If a bookmark has no applications then it won't be dumped when creating the on disk representation, using glib.bookmark_file.BookmarkFile.toData or glib.bookmark_file.BookmarkFile.toFile.

class BookmarkFile : Boxed {}

Constructors

this
this()

Creates a new empty #GBookmarkFile object.

Members

Functions

addApplication
void addApplication(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.

addGroup
void addGroup(string uri, string group)

Adds group to the list of groups to which the bookmark for uri belongs to.

copy
glib.bookmark_file.BookmarkFile copy()

Deeply copies a bookmark #GBookmarkFile object to a new one.

getAdded
long getAdded(string uri)

Gets the time the bookmark for uri was added to bookmark

getAddedDateTime
glib.date_time.DateTime getAddedDateTime(string uri)

Gets the time the bookmark for uri was added to bookmark

getAppInfo
bool getAppInfo(string uri, string name, string exec, uint count, long stamp)

Gets the registration information of app_name for the bookmark for uri. See glib.bookmark_file.BookmarkFile.setApplicationInfo for more information about the returned data.

getApplicationInfo
bool getApplicationInfo(string uri, string name, string exec, uint count, glib.date_time.DateTime stamp)

Gets the registration information of app_name for the bookmark for uri. See glib.bookmark_file.BookmarkFile.setApplicationInfo for more information about the returned data.

getApplications
string[] getApplications(string uri)

Retrieves the names of the applications that have registered the bookmark for uri.

getDescription
string getDescription(string uri)

Retrieves the description of the bookmark for uri.

getGroups
string[] getGroups(string uri)

Retrieves the list of group names of the bookmark for uri.

getIcon
bool getIcon(string uri, string href, string mimeType)

Gets the icon of the bookmark for uri.

getIsPrivate
bool getIsPrivate(string uri)

Gets whether the private flag of the bookmark for uri is set.

getMimeType
string getMimeType(string uri)

Retrieves the MIME type of the resource pointed by uri.

getModified
long getModified(string uri)

Gets the time when the bookmark for uri was last modified.

getModifiedDateTime
glib.date_time.DateTime getModifiedDateTime(string uri)

Gets the time when the bookmark for uri was last modified.

getSize
int getSize()

Gets the number of bookmarks inside bookmark.

getTitle
string getTitle(string uri)

Returns the title of the bookmark for uri.

getUris
string[] getUris()

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.

getVisited
long getVisited(string uri)

Gets the time the bookmark for uri was last visited.

getVisitedDateTime
glib.date_time.DateTime getVisitedDateTime(string uri)

Gets the time the bookmark for uri was last visited.

hasApplication
bool hasApplication(string uri, string name)

Checks whether the bookmark for uri inside bookmark has been registered by application name.

hasGroup
bool hasGroup(string uri, string group)

Checks whether group appears in the list of groups to which the bookmark for uri belongs to.

hasItem
bool hasItem(string uri)

Looks whether the desktop bookmark has an item with its URI set to uri.

loadFromData
bool loadFromData(ubyte[] 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.

loadFromDataDirs
bool loadFromDataDirs(string file, string fullPath)

This function looks for a desktop bookmark file named file in the paths returned from glib.global.getUserDataDir and glib.global.getSystemDataDirs, 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.

loadFromFile
bool loadFromFile(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.

moveItem
bool moveItem(string oldUri, string newUri)

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.

removeApplication
bool removeApplication(string uri, string name)

Removes application registered with name from the list of applications that have registered a bookmark for uri inside bookmark.

removeGroup
bool removeGroup(string uri, string group)

Removes group from the list of groups to which the bookmark for uri belongs to.

removeItem
bool removeItem(string uri)

Removes the bookmark for uri from the bookmark file bookmark.

setAdded
void setAdded(string uri, long added)

Sets the time the bookmark for uri was added into bookmark.

setAddedDateTime
void setAddedDateTime(string uri, glib.date_time.DateTime added)

Sets the time the bookmark for uri was added into bookmark.

setAppInfo
bool setAppInfo(string uri, string name, string exec, int count, long stamp)

Sets the meta-data of application name inside the list of applications that have registered a bookmark for uri inside bookmark.

setApplicationInfo
bool setApplicationInfo(string uri, string name, string exec, int count, glib.date_time.DateTime stamp)

Sets the meta-data of application name inside the list of applications that have registered a bookmark for uri inside bookmark.

setDescription
void setDescription(string uri, string description)

Sets description as the description of the bookmark for uri.

setGroups
void setGroups(string uri, string[] groups)

Sets a list of group names for the item with URI uri. Each previously set group name list is removed.

setIcon
void setIcon(string uri, string href, string mimeType)

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.

setIsPrivate
void setIsPrivate(string uri, bool isPrivate)

Sets the private flag of the bookmark for uri.

setMimeType
void setMimeType(string uri, string mimeType)

Sets mime_type as the MIME type of the bookmark for uri.

setModified
void setModified(string uri, long modified)

Sets the last time the bookmark for uri was last modified.

setModifiedDateTime
void setModifiedDateTime(string uri, glib.date_time.DateTime modified)

Sets the last time the bookmark for uri was last modified.

setTitle
void setTitle(string uri, string title)

Sets title as the title of the bookmark for uri inside the bookmark file bookmark.

setVisited
void setVisited(string uri, long visited)

Sets the time the bookmark for uri was last visited.

setVisitedDateTime
void setVisitedDateTime(string uri, glib.date_time.DateTime visited)

Sets the time the bookmark for uri was last visited.

toData
ubyte[] toData()

This function outputs bookmark as a string.

toFile
bool toFile(string filename)

This function outputs bookmark into a file. The write process is guaranteed to be atomic by using glib.global.fileSetContents internally.

Static functions

errorQuark
glib.types.Quark errorQuark()

Inherited Members

From Boxed

cInstancePtr
void* cInstancePtr;

Pointer to the C boxed value

getType
GType getType()

Get the GType of this boxed type.

gType
GType gType [@property getter]

Boxed GType property.

self
Boxed self()

Convenience method to return this cast to a type. For use in D with statements.

copy_
void* copy_()

Make a copy of the wrapped C boxed data.

boxedCopy
void* boxedCopy(void* cBoxed)

Copy a C boxed value using g_boxed_copy.

boxedFree
void boxedFree(void* cBoxed)

Free a C boxed value using g_boxed_free.