Class BookmarkFile

java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.glib.BookmarkFile
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class BookmarkFile extends ProxyInstance

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

Since:
2.12
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new empty GBookmarkFile object.
    Create a BookmarkFile proxy instance for the provided memory address.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addApplication(String uri, @Nullable String name, @Nullable String exec)
    Adds the application with name and exec to the list of applications that have registered a bookmark for uri into bookmark.
    void
    addGroup(String uri, String group)
    Adds group to the list of groups to which the bookmark for uri belongs to.
    Deeply copies a this BookmarkFile GBookmarkFile object to a new one.
    static Quark
     
    void
    Frees a GBookmarkFile.
    long
    Deprecated.
    Use g_bookmark_file_get_added_date_time() instead, as time_t is deprecated due to the year 2038 problem.
    Gets the time the bookmark for uri was added to this BookmarkFile
    boolean
    getAppInfo(String uri, String name, @Nullable Out<String> exec, @Nullable Out<Integer> count, @Nullable Out<Long> stamp)
    Deprecated.
    Use g_bookmark_file_get_application_info() instead, as time_t is deprecated due to the year 2038 problem.
    boolean
    getApplicationInfo(String uri, String name, @Nullable Out<String> exec, @Nullable Out<Integer> count, @Nullable Out<DateTime> stamp)
    Gets the registration information of appName for the bookmark for uri. See g_bookmark_file_set_application_info() for more information about the returned data.
    Retrieves the names of the applications that have registered the bookmark for uri.
    Retrieves the description of the bookmark for uri.
    Retrieves the list of group names of the bookmark for uri.
    boolean
    getIcon(String uri, @Nullable Out<String> href, @Nullable Out<String> mimeType)
    Gets the icon of the bookmark for uri.
    boolean
    Gets whether the private flag of the bookmark for uri is set.
    The memory layout of the native struct.
    Retrieves the MIME type of the resource pointed by uri.
    long
    Deprecated.
    Use g_bookmark_file_get_modified_date_time() instead, as time_t is deprecated due to the year 2038 problem.
    Gets the time when the bookmark for uri was last modified.
    int
    Gets the number of bookmarks inside bookmark.
    getTitle(@Nullable String uri)
    Returns the title of the bookmark for uri.
    static @Nullable Type
    Get the GType of the BookmarkFile class.
    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.
    long
    Deprecated.
    Use g_bookmark_file_get_visited_date_time() instead, as time_t is deprecated due to the year 2038 problem.
    Gets the time the bookmark for uri was last visited.
    boolean
    Checks whether the bookmark for uri inside this BookmarkFile has been registered by application name.
    boolean
    hasGroup(String uri, String group)
    Checks whether group appears in the list of groups to which the bookmark for uri belongs to.
    boolean
    Looks whether the desktop bookmark has an item with its URI set to uri.
    boolean
    loadFromData(@Nullable byte @Nullable [] data)
    Loads a bookmark file from memory into an empty GBookmarkFile structure.
    boolean
    loadFromDataDirs(String file, @Nullable Out<String> fullPath)
    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 this BookmarkFile and returns the file's full path in fullPath. If the file could not be loaded then error is set to either a GFileError or GBookmarkFileError.
    boolean
    loadFromFile(String filename)
    Loads a desktop bookmark file into an empty GBookmarkFile structure.
    boolean
    moveItem(String oldUri, @Nullable String newUri)
    Changes the URI of a bookmark item from oldUri to newUri. Any existing bookmark for newUri will be overwritten.
    boolean
    Removes application registered with name from the list of applications that have registered a bookmark for uri inside bookmark.
    boolean
    removeGroup(String uri, String group)
    Removes group from the list of groups to which the bookmark for uri belongs to.
    boolean
    Removes the bookmark for uri from the bookmark file bookmark.
    void
    setAdded(String uri, long added)
    Deprecated.
    Use g_bookmark_file_set_added_date_time() instead, as time_t is deprecated due to the year 2038 problem.
    void
    Sets the time the bookmark for uri was added into bookmark.
    boolean
    setAppInfo(String uri, String name, String exec, int count, long stamp)
    Deprecated.
    Use g_bookmark_file_set_application_info() instead, as time_t is deprecated due to the year 2038 problem.
    boolean
    setApplicationInfo(String uri, String name, String exec, int count, @Nullable DateTime stamp)
    Sets the meta-data of application name inside the list of applications that have registered a bookmark for uri inside bookmark.
    void
    setDescription(@Nullable String uri, String description)
    Sets description as the description of the bookmark for uri.
    void
    setGroups(String uri, @Nullable String @Nullable [] groups)
    Sets a list of group names for the item with URI uri. Each previously set group name list is removed.
    void
    setIcon(String uri, @Nullable String href, String mimeType)
    Sets the icon for the bookmark for uri. If href is null, unsets the currently set icon.
    void
    setIsPrivate(String uri, boolean isPrivate)
    Sets the private flag of the bookmark for uri.
    void
    setMimeType(String uri, String mimeType)
    Sets mimeType as the MIME type of the bookmark for uri.
    void
    setModified(String uri, long modified)
    Deprecated.
    Use g_bookmark_file_set_modified_date_time() instead, as time_t is deprecated due to the year 2038 problem.
    void
    Sets the last time the bookmark for uri was last modified.
    void
    setTitle(@Nullable String uri, String title)
    Sets title as the title of the bookmark for uri inside the bookmark file bookmark.
    void
    setVisited(String uri, long visited)
    Deprecated.
    Use g_bookmark_file_set_visited_date_time() instead, as time_t is deprecated due to the year 2038 problem.
    void
    Sets the time the bookmark for uri was last visited.
    byte[]
    This function outputs this BookmarkFile as a string.
    boolean
    toFile(String filename)
    This function outputs this BookmarkFile into a file.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BookmarkFile

      public BookmarkFile(MemorySegment address)
      Create a BookmarkFile proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • BookmarkFile

      public BookmarkFile()

      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.

      Since:
      2.12
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the BookmarkFile class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • errorQuark

      public static Quark errorQuark()
    • addApplication

      public void addApplication(String uri, @Nullable String name, @Nullable 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.

      Parameters:
      uri - a valid URI
      name - the name of the application registering the bookmark or null
      exec - command line to be used to launch the bookmark or null
      Since:
      2.12
    • addGroup

      public void addGroup(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.

      Parameters:
      uri - a valid URI
      group - the group name to be added
      Since:
      2.12
    • copy

      public BookmarkFile copy()
      Deeply copies a this BookmarkFile GBookmarkFile object to a new one.
      Returns:
      the copy of bookmark. Use g_bookmark_free() when finished using it.
      Since:
      2.76
    • free

      public void free()
      Frees a GBookmarkFile.
      Since:
      2.12
    • getAdded

      @Deprecated public long getAdded(String uri) throws GErrorException
      Deprecated.
      Use g_bookmark_file_get_added_date_time() instead, as time_t is deprecated due to the year 2038 problem.

      Gets the time the bookmark for uri was added to this BookmarkFile

      In the event the URI cannot be found, -1 is returned and error is set to BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      Returns:
      a timestamp
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getAddedDateTime

      public DateTime getAddedDateTime(String uri) throws GErrorException

      Gets the time the bookmark for uri was added to this BookmarkFile

      In the event the URI cannot be found, null is returned and error is set to BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      Returns:
      a GDateTime
      Throws:
      GErrorException - see GError
      Since:
      2.66
    • getAppInfo

      @Deprecated public boolean getAppInfo(String uri, String name, @Nullable Out<String> exec, @Nullable Out<Integer> count, @Nullable Out<Long> stamp) throws GErrorException
      Deprecated.
      Use g_bookmark_file_get_application_info() instead, as time_t is deprecated due to the year 2038 problem.

      Gets the registration information of appName for the bookmark for uri. See g_bookmark_file_set_application_info() for more information about the returned data.

      The string returned in appExec must be freed.

      In the event the URI cannot be found, false is returned and error is set to BookmarkFileError.URI_NOT_FOUND. In the event that no application with name appName has registered a bookmark for uri, false is returned and error is set to BookmarkFileError.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.

      Parameters:
      uri - a valid URI
      name - an application's name
      exec - return location for the command line of the application, or null
      count - return location for the registration count, or null
      stamp - return location for the last registration time, or null
      Returns:
      true on success.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getApplicationInfo

      public boolean getApplicationInfo(String uri, String name, @Nullable Out<String> exec, @Nullable Out<Integer> count, @Nullable Out<DateTime> stamp) throws GErrorException

      Gets the registration information of appName for the bookmark for uri. See g_bookmark_file_set_application_info() for more information about the returned data.

      The string returned in appExec must be freed.

      In the event the URI cannot be found, false is returned and error is set to BookmarkFileError.URI_NOT_FOUND. In the event that no application with name appName has registered a bookmark for uri, false is returned and error is set to BookmarkFileError.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.

      Parameters:
      uri - a valid URI
      name - an application's name
      exec - return location for the command line of the application, or null
      count - return location for the registration count, or null
      stamp - return location for the last registration time, or null
      Returns:
      true on success.
      Throws:
      GErrorException - see GError
      Since:
      2.66
    • getApplications

      public String[] getApplications(String uri) throws GErrorException

      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 BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      Returns:
      a newly allocated null-terminated array of strings. Use g_strfreev() to free it.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getDescription

      public String getDescription(String uri) throws GErrorException

      Retrieves the description of the bookmark for uri.

      In the event the URI cannot be found, null is returned and error is set to BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      Returns:
      a newly allocated string or null if the specified URI cannot be found.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getGroups

      public String[] getGroups(String uri) throws GErrorException

      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 BookmarkFileError.URI_NOT_FOUND.

      The returned array is null terminated, so length may optionally be null.

      Parameters:
      uri - a valid URI
      Returns:
      a newly allocated null-terminated array of group names. Use g_strfreev() to free it.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getIcon

      public boolean getIcon(String uri, @Nullable Out<String> href, @Nullable Out<String> mimeType) throws GErrorException

      Gets the icon of the bookmark for uri.

      In the event the URI cannot be found, false is returned and error is set to BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      href - return location for the icon's location or null
      mimeType - return location for the icon's MIME type or null
      Returns:
      true if the icon for the bookmark for the URI was found. You should free the returned strings.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getIsPrivate

      public boolean getIsPrivate(String uri) throws GErrorException

      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 BookmarkFileError.URI_NOT_FOUND. In the event that the private flag cannot be found, false is returned and error is set to BookmarkFileError.INVALID_VALUE.

      Parameters:
      uri - a valid URI
      Returns:
      true if the private flag is set, false otherwise.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getMimeType

      public String getMimeType(String uri) throws GErrorException

      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 BookmarkFileError.URI_NOT_FOUND. In the event that the MIME type cannot be found, null is returned and error is set to BookmarkFileError.INVALID_VALUE.

      Parameters:
      uri - a valid URI
      Returns:
      a newly allocated string or null if the specified URI cannot be found.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getModified

      @Deprecated public long getModified(String uri) throws GErrorException
      Deprecated.
      Use g_bookmark_file_get_modified_date_time() instead, as time_t is deprecated due to the year 2038 problem.

      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 BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      Returns:
      a timestamp
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getModifiedDateTime

      public DateTime getModifiedDateTime(String uri) throws GErrorException

      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 BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      Returns:
      a GDateTime
      Throws:
      GErrorException - see GError
      Since:
      2.66
    • getSize

      public int getSize()
      Gets the number of bookmarks inside bookmark.
      Returns:
      the number of bookmarks
      Since:
      2.12
    • getTitle

      public String getTitle(@Nullable String uri) throws GErrorException

      Returns the title of the bookmark for uri.

      If uri is null, the title of this BookmarkFile is returned.

      In the event the URI cannot be found, null is returned and error is set to BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI or null
      Returns:
      a newly allocated string or null if the specified URI cannot be found.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getUris

      public 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.
      Returns:
      a newly allocated null-terminated array of strings. Use g_strfreev() to free it.
      Since:
      2.12
    • getVisited

      @Deprecated public long getVisited(String uri) throws GErrorException
      Deprecated.
      Use g_bookmark_file_get_visited_date_time() instead, as time_t is deprecated due to the year 2038 problem.

      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 BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      Returns:
      a timestamp.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • getVisitedDateTime

      public DateTime getVisitedDateTime(String uri) throws GErrorException

      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 BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      Returns:
      a GDateTime
      Throws:
      GErrorException - see GError
      Since:
      2.66
    • hasApplication

      public boolean hasApplication(String uri, String name) throws GErrorException

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

      In the event the URI cannot be found, false is returned and error is set to BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      name - the name of the application
      Returns:
      true if the application name was found
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • hasGroup

      public boolean hasGroup(String uri, String group) throws GErrorException

      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 BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      uri - a valid URI
      group - the group name to be searched
      Returns:
      true if group was found.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • hasItem

      public boolean hasItem(String uri)
      Looks whether the desktop bookmark has an item with its URI set to uri.
      Parameters:
      uri - a valid URI
      Returns:
      true if uri is inside bookmark, false otherwise
      Since:
      2.12
    • loadFromData

      public boolean loadFromData(@Nullable byte @Nullable [] data) throws GErrorException
      Loads a bookmark file from memory into an empty GBookmarkFile structure. If the object cannot be created then error is set to a GBookmarkFileError.
      Parameters:
      data - desktop bookmarks loaded in memory
      Returns:
      true if a desktop bookmark could be loaded.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • loadFromDataDirs

      public boolean loadFromDataDirs(String file, @Nullable Out<String> fullPath) throws GErrorException
      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 this BookmarkFile and returns the file's full path in fullPath. If the file could not be loaded then error is set to either a GFileError or GBookmarkFileError.
      Parameters:
      file - a relative path to a filename to open and parse
      fullPath - return location for a string containing the full path of the file, or null
      Returns:
      true if a key file could be loaded, false otherwise
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • loadFromFile

      public boolean loadFromFile(String filename) throws GErrorException
      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.
      Parameters:
      filename - the path of a filename to load, in the GLib file name encoding
      Returns:
      true if a desktop bookmark file could be loaded
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • moveItem

      public boolean moveItem(String oldUri, @Nullable String newUri) throws GErrorException

      Changes the URI of a bookmark item from oldUri to newUri. Any existing bookmark for newUri will be overwritten. If newUri is null, then the bookmark is removed.

      In the event the URI cannot be found, false is returned and error is set to BookmarkFileError.URI_NOT_FOUND.

      Parameters:
      oldUri - a valid URI
      newUri - a valid URI, or null
      Returns:
      true if the URI was successfully changed
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • removeApplication

      public boolean removeApplication(String uri, String name) throws GErrorException

      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 BookmarkFileError.URI_NOT_FOUND. In the event that no application with name appName has registered a bookmark for uri, false is returned and error is set to BookmarkFileError.APP_NOT_REGISTERED.

      Parameters:
      uri - a valid URI
      name - the name of the application
      Returns:
      true if the application was successfully removed.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • removeGroup

      public boolean removeGroup(String uri, String group) throws GErrorException

      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 error is set to BookmarkFileError.URI_NOT_FOUND. In the event no group was defined, false is returned and error is set to BookmarkFileError.INVALID_VALUE.

      Parameters:
      uri - a valid URI
      group - the group name to be removed
      Returns:
      true if group was successfully removed.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • removeItem

      public boolean removeItem(String uri) throws GErrorException
      Removes the bookmark for uri from the bookmark file bookmark.
      Parameters:
      uri - a valid URI
      Returns:
      true if the bookmark was removed successfully.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • setAdded

      @Deprecated public void setAdded(String uri, long added)
      Deprecated.
      Use g_bookmark_file_set_added_date_time() instead, as time_t is deprecated due to the year 2038 problem.

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

      If no bookmark for uri is found then it is created.

      Parameters:
      uri - a valid URI
      added - a timestamp or -1 to use the current time
      Since:
      2.12
    • setAddedDateTime

      public void setAddedDateTime(String uri, DateTime added)

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

      If no bookmark for uri is found then it is created.

      Parameters:
      uri - a valid URI
      added - a GDateTime
      Since:
      2.66
    • setAppInfo

      @Deprecated public boolean setAppInfo(String uri, String name, String exec, int count, long stamp) throws GErrorException
      Deprecated.
      Use g_bookmark_file_set_application_info() instead, as time_t is deprecated due to the year 2038 problem.

      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 BookmarkFileError.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 BookmarkFileError.APP_NOT_REGISTERED. Otherwise, if no bookmark for uri is found, one is created.

      Parameters:
      uri - a valid URI
      name - an application's name
      exec - an application's command line
      count - the number of registrations done for this application
      stamp - the time of the last registration for this application
      Returns:
      true if the application's meta-data was successfully changed.
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • setApplicationInfo

      public boolean setApplicationInfo(String uri, String name, String exec, int count, @Nullable DateTime stamp) throws GErrorException

      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 BookmarkFileError.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 BookmarkFileError.APP_NOT_REGISTERED. Otherwise, if no bookmark for uri is found, one is created.

      Parameters:
      uri - a valid URI
      name - an application's name
      exec - an application's command line
      count - the number of registrations done for this application
      stamp - the time of the last registration for this application, which may be null if count is 0
      Returns:
      true if the application's meta-data was successfully changed.
      Throws:
      GErrorException - see GError
      Since:
      2.66
    • setDescription

      public void setDescription(@Nullable String uri, String description)

      Sets description as the description of the bookmark for uri.

      If uri is null, the description of this BookmarkFile is set.

      If a bookmark for uri cannot be found then it is created.

      Parameters:
      uri - a valid URI or null
      description - a string
      Since:
      2.12
    • setGroups

      public void setGroups(String uri, @Nullable String @Nullable [] 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.

      Parameters:
      uri - an item's URI
      groups - an array of group names, or null to remove all groups
      Since:
      2.12
    • setIcon

      public void setIcon(String uri, @Nullable 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.

      If no bookmark for uri is found one is created.

      Parameters:
      uri - a valid URI
      href - the URI of the icon for the bookmark, or null
      mimeType - the MIME type of the icon for the bookmark
      Since:
      2.12
    • setIsPrivate

      public void setIsPrivate(String uri, boolean isPrivate)

      Sets the private flag of the bookmark for uri.

      If a bookmark for uri cannot be found then it is created.

      Parameters:
      uri - a valid URI
      isPrivate - true if the bookmark should be marked as private
      Since:
      2.12
    • setMimeType

      public void setMimeType(String uri, String mimeType)

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

      If a bookmark for uri cannot be found then it is created.

      Parameters:
      uri - a valid URI
      mimeType - a MIME type
      Since:
      2.12
    • setModified

      @Deprecated public void setModified(String uri, long modified)
      Deprecated.
      Use g_bookmark_file_set_modified_date_time() instead, as time_t is deprecated due to the year 2038 problem.

      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().

      Parameters:
      uri - a valid URI
      modified - a timestamp or -1 to use the current time
      Since:
      2.12
    • setModifiedDateTime

      public void setModifiedDateTime(String uri, DateTime 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().

      Parameters:
      uri - a valid URI
      modified - a GDateTime
      Since:
      2.66
    • setTitle

      public void setTitle(@Nullable 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 this BookmarkFile is set.

      If a bookmark for uri cannot be found then it is created.

      Parameters:
      uri - a valid URI or null
      title - a UTF-8 encoded string
      Since:
      2.12
    • setVisited

      @Deprecated public void setVisited(String uri, long visited)
      Deprecated.
      Use g_bookmark_file_set_visited_date_time() instead, as time_t is deprecated due to the year 2038 problem.

      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_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.

      Parameters:
      uri - a valid URI
      visited - a timestamp or -1 to use the current time
      Since:
      2.12
    • setVisitedDateTime

      public void setVisitedDateTime(String uri, DateTime 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_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.

      Parameters:
      uri - a valid URI
      visited - a GDateTime
      Since:
      2.66
    • toData

      public byte[] toData() throws GErrorException
      This function outputs this BookmarkFile as a string.
      Returns:
      a newly allocated string holding the contents of the GBookmarkFile
      Throws:
      GErrorException - see GError
      Since:
      2.12
    • toFile

      public boolean toFile(String filename) throws GErrorException
      This function outputs this BookmarkFile into a file. The write process is guaranteed to be atomic by using g_file_set_contents() internally.
      Parameters:
      filename - path of the output file
      Returns:
      true if the file was successfully written.
      Throws:
      GErrorException - see GError
      Since:
      2.12