home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / perl5 / Glib / BookmarkFile.pod next >
Encoding:
Text File  |  2007-03-05  |  13.1 KB  |  754 lines

  1. =head1 NAME
  2.  
  3. Glib::BookmarkFile -  Parser for bookmark files
  4.  
  5. =for position SYNOPSIS
  6.  
  7. =head1 SYNOPSIS
  8.  
  9.   use Glib;
  10.  
  11.   $date .= $_ while (<DATA>);
  12.  
  13.   $b = Glib::BookmarkFile->new;
  14.   $b->load_from_data($data);
  15.   $uri = 'file:///some/path/to/a/file.txt';
  16.   if ($b->has_item($uri)) {
  17.       $title = $b->get_title($uri);
  18.     $desc  = $b->get_description($uri);
  19.     
  20.     print "Bookmark for `$uri' ($title):\n";
  21.     print "  $desc\n";
  22.   }
  23.   0;
  24.  
  25.   __DATA__
  26.   <?xml version="1.0" encoding="UTF-8"?>
  27.   <xbel version="1.0"
  28.         xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"
  29.         xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info"
  30. >
  31.     <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">
  32.       <title>Test File</title>
  33.       <desc>Some test file</desc>
  34.       <info>
  35.         <metadata owner="http://freedesktop.org">
  36.           <mime:mime-type type="text/plain"/>
  37.           <bookmark:applications>
  38.             <bookmark:application name="Gedit" exec="gedit %u" timestamp="1143053640" count="1"/>
  39.           </bookmark:applications>
  40.         </metadata>
  41.       </info>
  42.     </bookmark>
  43.   </xbel>
  44.   
  45. =for position DESCRIPTION
  46.  
  47. =head1 DESCRIPTION
  48.  
  49. B<Glib::BookmarkFile> lets you parse, edit or create files containing lists
  50. of bookmarks to resources pointed to by URIs, with some meta-data bound to
  51. them, following the Desktop Bookmark Specification.  The recent files support
  52. inside GTK+ uses this type of files to store the list of recently used
  53. files.
  54.  
  55. The syntax of bookmark files is described in detail in the Desktop Bookmarks
  56. Specification, here is a quick summary: bookmark files use a subclass of the
  57. XML Bookmark Exchange Language (XBEL) document format, defining meta-data
  58. such as the MIME type of the resource pointed by a bookmark, the list of
  59. applications that have registered the same URI and the visibility of the
  60. bookmark.
  61.  
  62. =cut
  63.  
  64.  
  65.  
  66. =for object Glib::BookmarkFile Parser for bookmark files
  67. =cut
  68.  
  69.  
  70.  
  71.  
  72. =head1 METHODS
  73.  
  74. =head2 bookmarkfile = Glib::BookmarkFile-E<gt>B<new> 
  75.  
  76. =over
  77.  
  78. =back
  79.  
  80. =head2 $bookmark_file-E<gt>B<add_application> ($uri, $name, $exec)
  81.  
  82. =over
  83.  
  84. =over
  85.  
  86. =item * $uri (string) 
  87.  
  88. =item * $name (string or undef) 
  89.  
  90. =item * $exec (string or undef) 
  91.  
  92. =back
  93.  
  94. Adds the application with $name and $exec to the list of
  95. applications that have registered a bookmark for $uri into
  96. $bookmark_file.
  97.  
  98. Every bookmark inside a C<Glib::BookmarkFile> must have at least an
  99. application registered.  Each application must provide a name, a
  100. command line useful for launching the bookmark, the number of times
  101. the bookmark has been registered by the application and the last
  102. time the application registered this bookmark.
  103.  
  104. If $name is undef, the name of the application will be the
  105. same returned by Glib::get_application_name(); if $exec is undef,
  106. the command line will be a composition of the program name as
  107. returned by Glib::get_prgname() and the "%u" modifier, which will
  108. be expanded to the bookmark's URI.
  109.  
  110. This function will automatically take care of updating the
  111. registrations count and timestamping in case an application
  112. with the same $name had already registered a bookmark for
  113. $uri inside the bookmark file.  If no bookmark for $uri is found
  114. one is created.
  115.  
  116. =back
  117.  
  118. =head2 $bookmark_file-E<gt>B<add_group> ($uri, $group)
  119.  
  120. =over
  121.  
  122. =over
  123.  
  124. =item * $uri (string) 
  125.  
  126. =item * $group (string) 
  127.  
  128. =back
  129.  
  130. Adds $group to the list of groups to which the bookmark for $uri
  131. belongs to.  If no bookmark for $uri is found one is created.
  132.  
  133. =back
  134.  
  135. =head2 unix timestamp = $bookmark_file-E<gt>B<get_added> ($uri)
  136.  
  137. =over
  138.  
  139. =over
  140.  
  141. =item * $uri (string) 
  142.  
  143. =back
  144.  
  145. =for apidoc __gerror__
  146. Gets the time the bookmark for $uri was added to $bookmark_file.
  147.  
  148. =back
  149.  
  150. =head2 Glib::BookmarkFile::set_added ($bookmark_file, $uri, $value)
  151.  
  152. =over
  153.  
  154. =over
  155.  
  156. =item * $bookmark_file (Glib::BookmarkFile) 
  157.  
  158. =item * $uri (string) 
  159.  
  160. =item * $value (unix timestamp) 
  161.  
  162. =back
  163.  
  164. Sets the time the bookmark for $uri was added.
  165. If no bookmark for $uri is found one is created.
  166.  
  167. =back
  168.  
  169. =head2 ($exec, $count, $stamp) = $bookmark_file->B<get_app_info> ($uri, $name)
  170.  
  171. =over
  172.  
  173. =over
  174.  
  175. =item * $uri (string) 
  176.  
  177. =item * $name (string) 
  178.  
  179. =back
  180.  
  181. Gets the registration informations of $name for the bookmark for
  182. $uri.  See Glib::BookmarkFile::set_app_info() for more informations about
  183. the returned data.
  184.  
  185. May croak with a L<Glib::Error> in $@ on failure.
  186.  
  187. =back
  188.  
  189. =head2 $bookmark_file-E<gt>B<set_app_info> ($uri, $name, $exec, $count, $stamp)
  190.  
  191. =over
  192.  
  193. =over
  194.  
  195. =item * $uri (string) 
  196.  
  197. =item * $name (string) 
  198.  
  199. =item * $exec (string) 
  200.  
  201. =item * $count (integer) 
  202.  
  203. =item * $stamp (unix timestamp) 
  204.  
  205. =back
  206.  
  207. Sets the meta-data of application $name inside the list of
  208. applications that have registered a bookmark for $uri inside
  209. $bookmark_file.
  210.  
  211. You should rarely use this method; use Glib::BookmarkFile::add_application()
  212. and Glib::BookmarkFile::remove_application() instead.
  213.  
  214. $name can be any UTF-8 encoded string used to identify an application.
  215. $exec can have one of these two modifiers: "%f", which will be expanded
  216. as the local file name retrieved from the bookmark's URI; "%u", which
  217. will be expanded as the bookmark's URI. The expansion is done automatically
  218. when retrieving the stored command line using the
  219. Glib::BookmarkFile::get_app_info() method.
  220. $count is the number of times the application has registered the
  221. bookmark; if it is < 0, the current registration count will be increased
  222. by one, if it is 0, the application with $name will be removed from
  223. the list of registered applications.
  224. $stamp is the Unix time of the last registration, as returned by time(); if
  225. it is -1, the current time will be used.
  226.  
  227. If you try to remove an application by setting its registration count to
  228. zero, and no bookmark for $uri is found, %FALSE is returned and an
  229. exception is fired.
  230.  
  231. May croak with a L<Glib::Error> in $@ on failure.
  232.  
  233. =back
  234.  
  235. =head2 list = $bookmark_file->B<get_applications> ($uri)
  236.  
  237. =over
  238.  
  239. =over
  240.  
  241. =item * $uri (string) 
  242.  
  243. =back
  244.  
  245. Retrieves the names of the applications that have registered the
  246. bookmark for $uri.
  247.  
  248. May croak with a L<Glib::Error> in $@ on failure.
  249.  
  250. =back
  251.  
  252. =head2 $bookmark_file->B<get_description> ($uri)
  253.  
  254. =over
  255.  
  256. =over
  257.  
  258. =item * $uri (string) 
  259.  
  260. =back
  261.  
  262. Gets the description of the bookmark for $uri.
  263.  
  264. May croak with a L<Glib::Error> in $@ on failure.
  265.  
  266. =back
  267.  
  268. =head2 $bookmark_file-E<gt>B<set_description> ($uri, $description)
  269.  
  270. =over
  271.  
  272. =over
  273.  
  274. =item * $uri (string) 
  275.  
  276. =item * $description (string) 
  277.  
  278. =back
  279.  
  280. Sets the description of the bookmark for $uri.  If no bookmark for $uri
  281. is found one is created.
  282.  
  283. =back
  284.  
  285. =head2 list = $bookmark_file-E<gt>B<get_groups> ($uri)
  286.  
  287. =over
  288.  
  289. =over
  290.  
  291. =item * $uri (string) 
  292.  
  293. =back
  294.  
  295. Retrieves the list of group names of the bookmark for $uri.
  296.  
  297. May croak with a L<Glib::Error> in $@ on failure.
  298.  
  299. =back
  300.  
  301. =head2 $bookmark_file-E<gt>B<set_groups> ($uri, ...)
  302.  
  303. =over
  304.  
  305. =over
  306.  
  307. =item * $uri (string) 
  308.  
  309. =item * ... (list) one or more group names
  310.  
  311. =back
  312.  
  313. Sets a list of group names for the item with URI $uri.  Each previously
  314. set group name list is removed.  If no bookmark for $uri is found one
  315. is created.
  316.  
  317. =back
  318.  
  319. =head2 boolean = $bookmark_file-E<gt>B<has_application> ($uri, $name)
  320.  
  321. =over
  322.  
  323. =over
  324.  
  325. =item * $uri (string) 
  326.  
  327. =item * $name (string) 
  328.  
  329. =back
  330.  
  331. Checks whether the bookmark for $uri inside $bookmark_file has
  332. been registered by application $name.
  333.  
  334. May croak with a L<Glib::Error> in $@ on failure.
  335.  
  336. =back
  337.  
  338. =head2 boolean = $bookmark_file-E<gt>B<has_group> ($uri, $group)
  339.  
  340. =over
  341.  
  342. =over
  343.  
  344. =item * $uri (string) 
  345.  
  346. =item * $group (string) 
  347.  
  348. =back
  349.  
  350. Checks whether $group appears in the list of groups to which
  351. the bookmark for $uri belongs to.
  352.  
  353. May croak with a L<Glib::Error> in $@ on failure.
  354.  
  355. =back
  356.  
  357. =head2 boolean = $bookmark_file-E<gt>B<has_item> ($uri)
  358.  
  359. =over
  360.  
  361. =over
  362.  
  363. =item * $uri (string) 
  364.  
  365. =back
  366.  
  367. Looks whether the bookmark file has a bookmark for $uri.
  368.  
  369. =back
  370.  
  371. =head2 ($href, $mime_type) = $bookmark_file->B<get_icon> ($uri)
  372.  
  373. =over
  374.  
  375. =over
  376.  
  377. =item * $uri (string) 
  378.  
  379. =back
  380.  
  381. Gets the icon of the bookmark for $uri.
  382.  
  383. May croak with a L<Glib::Error> in $@ on failure.
  384.  
  385. =back
  386.  
  387. =head2 $bookmark_file-E<gt>B<set_icon> ($uri, $href, $mime_type)
  388.  
  389. =over
  390.  
  391. =over
  392.  
  393. =item * $uri (string) 
  394.  
  395. =item * $href (string or undef) 
  396.  
  397. =item * $mime_type (string or undef) 
  398.  
  399. =back
  400.  
  401. Sets the icon for the bookmark for $uri.  If $href is undef, unsets
  402. the currently set icon.
  403.  
  404. =back
  405.  
  406. =head2 boolean = $bookmark_file-E<gt>B<get_is_private> ($uri)
  407.  
  408. =over
  409.  
  410. =over
  411.  
  412. =item * $uri (string) 
  413.  
  414. =back
  415.  
  416.  
  417.  
  418. May croak with a L<Glib::Error> in $@ on failure.
  419.  
  420. =back
  421.  
  422. =head2 $bookmark_file-E<gt>B<set_is_private> ($uri, $is_private)
  423.  
  424. =over
  425.  
  426. =over
  427.  
  428. =item * $uri (string) 
  429.  
  430. =item * $is_private (boolean) 
  431.  
  432. =back
  433.  
  434.  
  435.  
  436. =back
  437.  
  438. =head2 $bookmark_file-E<gt>B<load_from_data> ($buf)
  439.  
  440. =over
  441.  
  442. =over
  443.  
  444. =item * $buf (scalar) 
  445.  
  446. =back
  447.  
  448. Parses a string containing a bookmark file structure.
  449.  
  450. May croak with a L<Glib::Error> in $@ on failure.
  451.  
  452. =back
  453.  
  454. =head2 ($full_path) = $bookmark_file->B<load_from_data_dirs> ($file)
  455.  
  456. =over
  457.  
  458. =over
  459.  
  460. =item * $file (localized file name) 
  461.  
  462. =back
  463.  
  464.  
  465. Parses a bookmark file, searching for it inside the data directories.
  466. If a file is found, it returns the full path.
  467.  
  468. May croak with a L<Glib::Error> in $@ on failure.
  469.  
  470. =back
  471.  
  472. =head2 $bookmark_file-E<gt>B<load_from_file> ($file)
  473.  
  474. =over
  475.  
  476. =over
  477.  
  478. =item * $file (localized file name) 
  479.  
  480. =back
  481.  
  482. Parses a bookmark file.
  483.  
  484. May croak with a L<Glib::Error> in $@ on failure.
  485.  
  486. =back
  487.  
  488. =head2 string = $bookmark_file-E<gt>B<get_mime_type> ($uri)
  489.  
  490. =over
  491.  
  492. =over
  493.  
  494. =item * $uri (string) 
  495.  
  496. =back
  497.  
  498. Gets the MIME type of the bookmark for $uri.
  499.  
  500. May croak with a L<Glib::Error> in $@ on failure.
  501.  
  502. =back
  503.  
  504. =head2 $bookmark_file-E<gt>B<set_mime_type> ($uri, $mime_type)
  505.  
  506. =over
  507.  
  508. =over
  509.  
  510. =item * $uri (string) 
  511.  
  512. =item * $mime_type (string) 
  513.  
  514. =back
  515.  
  516. Sets the MIME type of the bookmark for $uri.  If no bookmark for $uri
  517. is found one is created.
  518.  
  519. =back
  520.  
  521. =head2 unix timestamp = $bookmark_file-E<gt>B<get_modified> ($uri)
  522.  
  523. =over
  524.  
  525. =over
  526.  
  527. =item * $uri (string) 
  528.  
  529. =back
  530.  
  531. =for apidoc __gerror__
  532. Gets the time the bookmark for $uri was last modified.
  533.  
  534. =back
  535.  
  536. =head2 Glib::BookmarkFile::set_modified ($bookmark_file, $uri, $value)
  537.  
  538. =over
  539.  
  540. =over
  541.  
  542. =item * $bookmark_file (Glib::BookmarkFile) 
  543.  
  544. =item * $uri (string) 
  545.  
  546. =item * $value (unix timestamp) 
  547.  
  548. =back
  549.  
  550. Sets the time the bookmark for $uri was last modified.
  551. If no bookmark for $uri is found one is created.
  552.  
  553. =back
  554.  
  555. =head2 $bookmark_file-E<gt>B<move_item> ($old_uri, $new_uri)
  556.  
  557. =over
  558.  
  559. =over
  560.  
  561. =item * $old_uri (string) 
  562.  
  563. =item * $new_uri (string or undef) 
  564.  
  565. =back
  566.  
  567. Changes the URI of a bookmark item from $old_uri to $new_uri.  Any
  568. existing bookmark for $new_uri will be overwritten.  If $new_uri is
  569. undef, then the bookmark is removed.
  570.  
  571. May croak with a L<Glib::Error> in $@ on failure.
  572.  
  573. =back
  574.  
  575. =head2 $bookmark_file-E<gt>B<remove_application> ($uri, $name)
  576.  
  577. =over
  578.  
  579. =over
  580.  
  581. =item * $uri (string) 
  582.  
  583. =item * $name (string) 
  584.  
  585. =back
  586.  
  587. Removes application registered with $name from the list of applications
  588. that have registered a bookmark for $uri inside $bookmark_file.
  589.  
  590. May croak with a L<Glib::Error> in $@ on failure.
  591.  
  592. =back
  593.  
  594. =head2 $bookmark_file-E<gt>B<remove_group> ($uri, $group)
  595.  
  596. =over
  597.  
  598. =over
  599.  
  600. =item * $uri (string) 
  601.  
  602. =item * $group (string) 
  603.  
  604. =back
  605.  
  606. Removes $group from the list of groups to which the bookmark
  607. for $uri belongs to.
  608.  
  609. May croak with a L<Glib::Error> in $@ on failure.
  610.  
  611. =back
  612.  
  613. =head2 boolean = $bookmark_file->B<remove_item> ($uri)
  614.  
  615. =over
  616.  
  617. =over
  618.  
  619. =item * $uri (string) 
  620.  
  621. =back
  622.  
  623. Removes the bookmark for $uri from the bookmark file.
  624.  
  625. May croak with a L<Glib::Error> in $@ on failure.
  626.  
  627. =back
  628.  
  629. =head2 integer = $bookmark_file-E<gt>B<get_size> 
  630.  
  631. =over
  632.  
  633. Gets the number of bookmarks inside the bookmark file.
  634.  
  635. =back
  636.  
  637. =head2 $bookmark_file->B<get_title> ($uri, $title)
  638.  
  639. =over
  640.  
  641. =over
  642.  
  643. =item * $uri (string) 
  644.  
  645. =back
  646.  
  647. Gets the title of the bookmark for $uri.
  648.  
  649. May croak with a L<Glib::Error> in $@ on failure.
  650.  
  651. =back
  652.  
  653. =head2 $bookmark_file-E<gt>B<set_title> ($uri, $title)
  654.  
  655. =over
  656.  
  657. =over
  658.  
  659. =item * $uri (string) 
  660.  
  661. =item * $title (string) 
  662.  
  663. =back
  664.  
  665. Sets the title of the bookmark for $uri.  If no bookmark for $uri is found
  666. one is created.
  667.  
  668. =back
  669.  
  670. =head2 string = $bookmark_file-E<gt>B<to_data> 
  671.  
  672. =over
  673.  
  674. Returns the bookmark file as a string.
  675.  
  676. May croak with a L<Glib::Error> in $@ on failure.
  677.  
  678. =back
  679.  
  680. =head2 $bookmark_file-E<gt>B<to_file> ($file)
  681.  
  682. =over
  683.  
  684. =over
  685.  
  686. =item * $file (localized file name) 
  687.  
  688. =back
  689.  
  690. Saves the contents of a bookmark file into a file.  The write operation
  691. is guaranteed to be atomical by writing the contents of the bookmark file
  692. to a temporary file and then moving the file to the target file.
  693.  
  694. May croak with a L<Glib::Error> in $@ on failure.
  695.  
  696. =back
  697.  
  698. =head2 list = $bookmark_file->B<get_uris>
  699.  
  700. =over
  701.  
  702. Returns the URI of all the bookmarks in the bookmark file.
  703.  
  704. =back
  705.  
  706. =head2 unix timestamp = $bookmark_file-E<gt>B<get_visited> ($uri)
  707.  
  708. =over
  709.  
  710. =over
  711.  
  712. =item * $uri (string) 
  713.  
  714. =back
  715.  
  716. =for apidoc __gerror__
  717. Gets the time the bookmark for $uri was last visited.
  718.  
  719. =back
  720.  
  721. =head2 Glib::BookmarkFile::set_visited ($bookmark_file, $uri, $value)
  722.  
  723. =over
  724.  
  725. =over
  726.  
  727. =item * $bookmark_file (Glib::BookmarkFile) 
  728.  
  729. =item * $uri (string) 
  730.  
  731. =item * $value (unix timestamp) 
  732.  
  733. =back
  734.  
  735. Sets the time the bookmark for $uri was last visited.
  736. If no bookmark for $uri is found one is created.
  737.  
  738. =back
  739.  
  740.  
  741. =head1 SEE ALSO
  742.  
  743. L<Glib>
  744.  
  745. =head1 COPYRIGHT
  746.  
  747. Copyright (C) 2003-2006 by the gtk2-perl team.
  748.  
  749. This software is licensed under the LGPL.  See L<Glib> for a full notice.
  750.  
  751.  
  752. =cut
  753.  
  754.