Glib::BookmarkFile(3)
π¦ Glib::BookmarkFile(3) π¦
okay so this is part 1 of the Glib::BookmarkFile(3) page from the User Contributed Perl Documentation, and it's giving parser-for-bookmark-files excellence. iykyk π
πΈ NAME πΈ
Glib::BookmarkFile β a parser for bookmark files. periodt. π
β¨ SYNOPSIS β¨
bestie, this synopsis is doing the most and honestly? slay. copy it exactly:
use Glib;
$date .= $_ while (<DATA>);
$b = Glib::BookmarkFile->new;
$b->load_from_data($data);
$uri = 'file:///some/path/to/a/file.txt';
if ($b->has_item($uri)) {
$title = $b->get_title($uri);
$desc = $b->get_description($uri);
print "Bookmark for `$uri' ($title):\n";
print " $desc\n";
}
0;
__DATA__
<?xml version="1.0" encoding="UTF-8"?>
<xbel version="1.0"
xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"
xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info">
<bookmark href="file:///tmp/test-file.txt" added="2006-03-22T18:54:00Z" modified="2006-03-22T18:54:00Z" visited="2006-03-22T18:54:00Z">
<title>Test File</title>
<desc>Some test file</desc>
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="text/plain"/>
<bookmark:applications>
<bookmark:application name="Gedit" exec="gedit %u" timestamp="1143053640" count="1"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
</xbel>
π DESCRIPTION π
okay so Glib::BookmarkFile lets you parse, edit or create files containing lists of bookmarks to resources pointed to by URIs, with some meta-data bound to them, following the Desktop Bookmark Specification. the recent files support inside GTK+ uses this type of files to store the list of recently used files. π«Ά
The syntax of bookmark files is described in detail in the Desktop Bookmarks Specification. here's the quick summary, bestie: bookmark files use a subclass of the XML Bookmark Exchange Language (XBEL) document format, defining meta-data such as the MIME type of the resource pointed by a bookmark, the list of applications that have registered the same URI and the visibility of the bookmark. πβ¨
β¨ METHODS β¨
Okay bestie, this is the method buffet. Every bookmark inside a Glib::BookmarkFile is doing main character stuff, and these are the calls that make it happen. π
π bookmarkfile = Glib::BookmarkFile->new π
Fresh new Glib::BookmarkFile, ready for business. No extra args listed. Slay. β¨
π $bookmark_file->add_application ($uri, $name, $exec) π
$uri(string) β the bookmark URI.$name(string or undef) β the app name, or undef for the default.$exec(string or undef) β the launch command, or undef for the default.
Adds the application with $name and $exec to the list of applications that have registered a bookmark for $uri into $bookmark_file.
Every bookmark inside a Glib::BookmarkFile 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 undef, the name of the application will be the same returned by Glib::get_application_name(); if $exec is undef, the command line will be a composition of the program name as returned by Glib::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 the bookmark file. If no bookmark for $uri is found one is created. π«Ά
π $bookmark_file->add_group ($uri, $group) π
$uri(string) β the bookmark URI.$group(string) β the group name to add.
Adds $group to the list of groups to which the bookmark for $uri belongs to. If no bookmark for $uri is found one is created. π
π unix timestamp = $bookmark_file->get_added ($uri) π
$uri(string) β the bookmark URI.
No extra prose on this one β it gives you the added timestamp. β°
π $bookmark_file->set_added ($uri, $value) π
$uri(string) β the bookmark URI.$value(unix timestamp) β the time to set.
Sets the time the bookmark for $uri was added. If no bookmark for $uri is found one is created. β¨
π ($exec, $count, $stamp) = $bookmark_file->get_app_info ($uri, $name) π
$uri(string) β the bookmark URI.$name(string) β the application name.
Gets the registration information of $name for the bookmark for $uri. See Glib::BookmarkFile::set_app_info() for more information about the returned data.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->set_app_info ($uri, $name, $exec, $count, $stamp) π
$uri(string) β the bookmark URI.$name(string) β the application name.$exec(string) β the launch command.$count(integer) β the registration count.$stamp(unix timestamp) β the last registration time.
Sets the meta-data of application $name inside the list of applications that have registered a bookmark for $uri inside $bookmark_file.
You should rarely use this method; use Glib::BookmarkFile::add_application() and Glib::BookmarkFile::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 Glib::BookmarkFile::get_app_info() method. $count is the number of times the application has registered the bookmark; if it is < 0, the current registration count will be increased by one, if it is 0, the application with $name will be removed from the list of registered applications. $stamp is the Unix time of the last registration, as returned by time(); 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 an exception is fired. π
May croak with aGlib::Errorin$@on failure. π
π list = $bookmark_file->get_applications ($uri) π
$uri(string) β the bookmark URI.
Retrieves the names of the applications that have registered the bookmark for $uri.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->get_description ($uri) π
$uri(string) β the bookmark URI.
Gets the description of the bookmark for $uri.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->set_description ($uri, $description) π
$uri(string) β the bookmark URI.$description(string) β the description text.
Sets the description of the bookmark for $uri. If no bookmark for $uri is found one is created. πΈ
π list = $bookmark_file->get_groups ($uri) π
$uri(string) β the bookmark URI.
Retrieves the list of group names of the bookmark for $uri.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->set_groups ($uri, ...) π
$uri(string) β the bookmark URI....(list) β one or more group names.
Sets a list of group names for the item with URI $uri. Each previously set group name list is removed. If no bookmark for $uri is found one is created. π
π boolean = $bookmark_file->has_application ($uri, $name) π
$uri(string) β the bookmark URI.$name(string) β the application name.
Checks whether the bookmark for $uri inside $bookmark_file has been registered by application $name.
May croak with aGlib::Errorin$@on failure. π
π boolean = $bookmark_file->has_group ($uri, $group) π
$uri(string) β the bookmark URI.$group(string) β the group name.
Checks whether $group appears in the list of groups to which the bookmark for $uri belongs to.
May croak with aGlib::Errorin$@on failure. π
π boolean = $bookmark_file->has_item ($uri) π
$uri(string) β the bookmark URI.
Looks whether the bookmark file has a bookmark for $uri. π
π ($href, $mime_type) = $bookmark_file->get_icon ($uri) π
$uri(string) β the bookmark URI.
Gets the icon of the bookmark for $uri.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->set_icon ($uri, $href, $mime_type) π
$uri(string) β the bookmark URI.$href(string or undef) β the icon href, or undef.$mime_type(string or undef) β the icon MIME type, or undef.
Sets the icon for the bookmark for $uri. If $href is undef, unsets the currently set icon. πΌοΈ
π boolean = $bookmark_file->get_is_private ($uri) π
$uri(string) β the bookmark URI.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->set_is_private ($uri, $is_private) π
$uri(string) β the bookmark URI.$is_private(boolean) β private or not.
No extra prose β just sets the private flag. π
π $bookmark_file->load_from_data ($buf) π
$buf(scalar) β the bookmark file data.
Parses a string containing a bookmark file structure.
May croak with aGlib::Errorin$@on failure. π
π ($full_path) = $bookmark_file->load_from_data_dirs ($file) π
$file(localized file name) β the file to find.
Parses a bookmark file, searching for it inside the data directories. If a file is found, it returns the full path.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->load_from_file ($file) π
$file(localized file name) β the file to parse.
Parses a bookmark file.
May croak with aGlib::Errorin$@on failure. π
π string = $bookmark_file->get_mime_type ($uri) π
$uri(string) β the bookmark URI.
Gets the MIME type of the bookmark for $uri.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->set_mime_type ($uri, $mime_type) π
$uri(string) β the bookmark URI.$mime_type(string) β the MIME type.
Sets the MIME type of the bookmark for $uri. If no bookmark for $uri is found one is created. π§
π unix timestamp = $bookmark_file->get_modified ($uri) π
$uri(string) β the bookmark URI.
No extra prose β it gives you the modified timestamp. β³
π $bookmark_file->set_modified ($uri, $value) π
$uri(string) β the bookmark URI.$value(unix timestamp) β the time to set.
Sets the time the bookmark for $uri was last modified. If no bookmark for $uri is found one is created. β¨
π $bookmark_file->move_item ($old_uri, $new_uri) π
$old_uri(string) β the current URI.$new_uri(string or undef) β the new URI, or undef.
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 undef, then the bookmark is removed. π
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->remove_application ($uri, $name) π
$uri(string) β the bookmark URI.$name(string) β the application name.
Removes application registered with $name from the list of applications that have registered a bookmark for $uri inside $bookmark_file.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->remove_group ($uri, $group) π
$uri(string) β the bookmark URI.$group(string) β the group name.
Removes $group from the list of groups to which the bookmark for $uri belongs to.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->remove_item ($uri) π
$uri(string) β the bookmark URI.
Removes the bookmark for $uri from the bookmark file.
May croak with aGlib::Errorin$@on failure. π
π integer = $bookmark_file->get_size π
Gets the number of bookmarks inside the bookmark file. No args, just count vibes. π’
π $bookmark_file->get_title ($uri, $title) π
$uri(string) β the bookmark URI.
Gets the title of the bookmark for $uri.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->set_title ($uri, $title) π
$uri(string) β the bookmark URI.$title(string) β the title text.
Sets the title of the bookmark for $uri. If no bookmark for $uri is found one is created. π
π string = $bookmark_file->to_data π
Returns the bookmark file as a string.
May croak with aGlib::Errorin$@on failure. π
π $bookmark_file->to_file ($file) π
$file(localized file name) β where to save it.
Saves the contents of a bookmark file into a file. The write operation is guaranteed to be atomic by writing the contents of the bookmark file to a temporary file and then moving the file to the target file.
May croak with aGlib::Errorin$@on failure. π
π list = $bookmark_file->get_uris π
Returns the URI of all the bookmarks in the bookmark file. All the URIs, all the vibes. π
π unix timestamp = $bookmark_file->get_visited ($uri) π
$uri(string) β the bookmark URI.
No extra prose β it gives you the visited timestamp. β±οΈ
π $bookmark_file->set_visited ($uri, $value) π
$uri(string) β the bookmark URI.$value(unix timestamp) β the time to set.
Sets the time the bookmark for $uri was last visited. If no bookmark for $uri is found one is created. π
π SEE ALSO π
Glib β that's the whole SEE ALSO, bestie. Go read it. π«Ά
π COPYRIGHT π
Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Glib for a full notice.
And that's the whole vibe check, bestie. This page is from perl v5.42.0, dated 2023-09-05 β kiss it goodbye, mwah. π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms