Glib
view release on metacpan or search on metacpan
GBookmarkFile.xs view on Meta::CPAN
#include "gperl.h"
SV *
newSVGBookmarkFile (GBookmarkFile * bookmark_file)
{
HV * bookmark = newHV ();
SV * sv;
HV * stash;
/* tie the key_file to our hash using some magic */
_gperl_attach_mg ((SV *) bookmark, bookmark_file);
/* wrap it, bless it, ship it. */
sv = newRV_noinc ((SV *) bookmark);
stash = gv_stashpv ("Glib::BookmarkFile", TRUE);
sv_bless (sv, stash);
return sv;
}
GBookmarkFile *
SvGBookmarkFile (SV * sv)
{
MAGIC * mg;
if (!gperl_sv_is_ref (sv) || !(mg = _gperl_find_mg (SvRV (sv))))
return NULL;
return (GBookmarkFile *) mg->mg_ptr;
}
MODULE = Glib::BookmarkFile PACKAGE = Glib::BookmarkFile PREFIX = g_bookmark_file_
=for object Glib::BookmarkFile Parser for bookmark files
=cut
=for position SYNOPSIS
=head1 SYNOPSIS
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>
=for position DESCRIPTION
=head1 DESCRIPTION
B<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 is a quick summary: 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.
=cut
void
DESTROY (GBookmarkFile *bookmark_file)
CODE:
g_bookmark_file_free (bookmark_file);
GBookmarkFile *
g_bookmark_file_new (class)
C_ARGS:
/* void */
# unneeded
# void g_bookmark_file_free (GBookmarkFile *bookmark);
=for apidoc __gerror__
Parses a bookmark file.
=cut
void
g_bookmark_file_load_from_file (bookmark_file, file)
GBookmarkFile *bookmark_file
GPerlFilename_const file
PREINIT:
GError *err = NULL;
CODE:
g_bookmark_file_load_from_file (bookmark_file, file, &err);
if (err)
gperl_croak_gerror (NULL, err);
=for apidoc __gerror__
Parses a string containing a bookmark file structure.
=cut
void
( run in 1.634 second using v1.01-cache-2.11-cpan-39bf76dae61 )