1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module glib.BookmarkFile; 26 27 private import glib.ConstructionException; 28 private import glib.ErrorG; 29 private import glib.GException; 30 private import glib.Str; 31 private import gtkc.glib; 32 public import gtkc.glibtypes; 33 34 35 /** 36 * The `GBookmarkFile` structure contains only 37 * private data and should not be directly accessed. 38 */ 39 public class BookmarkFile 40 { 41 /** the main Gtk struct */ 42 protected GBookmarkFile* gBookmarkFile; 43 44 /** Get the main Gtk struct */ 45 public GBookmarkFile* getBookmarkFileStruct() 46 { 47 return gBookmarkFile; 48 } 49 50 /** the main Gtk struct as a void* */ 51 protected void* getStruct() 52 { 53 return cast(void*)gBookmarkFile; 54 } 55 56 /** 57 * Sets our main struct and passes it to the parent class. 58 */ 59 public this (GBookmarkFile* gBookmarkFile) 60 { 61 this.gBookmarkFile = gBookmarkFile; 62 } 63 64 /** 65 */ 66 67 /** 68 * Adds the application with @name and @exec to the list of 69 * applications that have registered a bookmark for @uri into 70 * @bookmark. 71 * 72 * Every bookmark inside a #GBookmarkFile must have at least an 73 * application registered. Each application must provide a name, a 74 * command line useful for launching the bookmark, the number of times 75 * the bookmark has been registered by the application and the last 76 * time the application registered this bookmark. 77 * 78 * If @name is %NULL, the name of the application will be the 79 * same returned by g_get_application_name(); if @exec is %NULL, the 80 * command line will be a composition of the program name as 81 * returned by g_get_prgname() and the "\%u" modifier, which will be 82 * expanded to the bookmark's URI. 83 * 84 * This function will automatically take care of updating the 85 * registrations count and timestamping in case an application 86 * with the same @name had already registered a bookmark for 87 * @uri inside @bookmark. 88 * 89 * If no bookmark for @uri is found, one is created. 90 * 91 * Params: 92 * uri = a valid URI 93 * name = the name of the application registering the bookmark 94 * or %NULL 95 * exec = command line to be used to launch the bookmark or %NULL 96 * 97 * Since: 2.12 98 */ 99 public void addApplication(string uri, string name, string exec) 100 { 101 g_bookmark_file_add_application(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), Str.toStringz(exec)); 102 } 103 104 /** 105 * Adds @group to the list of groups to which the bookmark for @uri 106 * belongs to. 107 * 108 * If no bookmark for @uri is found then it is created. 109 * 110 * Params: 111 * uri = a valid URI 112 * group = the group name to be added 113 * 114 * Since: 2.12 115 */ 116 public void addGroup(string uri, string group) 117 { 118 g_bookmark_file_add_group(gBookmarkFile, Str.toStringz(uri), Str.toStringz(group)); 119 } 120 121 /** 122 * Frees a #GBookmarkFile. 123 * 124 * Since: 2.12 125 */ 126 public void free() 127 { 128 g_bookmark_file_free(gBookmarkFile); 129 } 130 131 /** 132 * Gets the time the bookmark for @uri was added to @bookmark 133 * 134 * In the event the URI cannot be found, -1 is returned and 135 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 136 * 137 * Params: 138 * uri = a valid URI 139 * 140 * Return: a timestamp 141 * 142 * Since: 2.12 143 * 144 * Throws: GException on failure. 145 */ 146 public uint getAdded(string uri) 147 { 148 GError* err = null; 149 150 auto p = g_bookmark_file_get_added(gBookmarkFile, Str.toStringz(uri), &err); 151 152 if (err !is null) 153 { 154 throw new GException( new ErrorG(err) ); 155 } 156 157 return p; 158 } 159 160 /** 161 * Gets the registration informations of @app_name for the bookmark for 162 * @uri. See g_bookmark_file_set_app_info() for more informations about 163 * the returned data. 164 * 165 * The string returned in @app_exec must be freed. 166 * 167 * In the event the URI cannot be found, %FALSE is returned and 168 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 169 * event that no application with name @app_name has registered a bookmark 170 * for @uri, %FALSE is returned and error is set to 171 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting 172 * the command line fails, an error of the #G_SHELL_ERROR domain is 173 * set and %FALSE is returned. 174 * 175 * Params: 176 * uri = a valid URI 177 * name = an application's name 178 * exec = return location for the command line of the application, or %NULL 179 * count = return location for the registration count, or %NULL 180 * stamp = return location for the last registration time, or %NULL 181 * 182 * Return: %TRUE on success. 183 * 184 * Since: 2.12 185 * 186 * Throws: GException on failure. 187 */ 188 public bool getAppInfo(string uri, string name, out string exec, out uint count, out uint stamp) 189 { 190 char* outexec = null; 191 GError* err = null; 192 193 auto p = g_bookmark_file_get_app_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &outexec, &count, &stamp, &err) != 0; 194 195 if (err !is null) 196 { 197 throw new GException( new ErrorG(err) ); 198 } 199 200 exec = Str.toString(outexec); 201 202 return p; 203 } 204 205 /** 206 * Retrieves the names of the applications that have registered the 207 * bookmark for @uri. 208 * 209 * In the event the URI cannot be found, %NULL is returned and 210 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 211 * 212 * Params: 213 * uri = a valid URI 214 * length = return location of the length of the returned list, or %NULL 215 * 216 * Return: a newly allocated %NULL-terminated array of strings. 217 * Use g_strfreev() to free it. 218 * 219 * Since: 2.12 220 * 221 * Throws: GException on failure. 222 */ 223 public string[] getApplications(string uri) 224 { 225 size_t length; 226 GError* err = null; 227 228 auto p = g_bookmark_file_get_applications(gBookmarkFile, Str.toStringz(uri), &length, &err); 229 230 if (err !is null) 231 { 232 throw new GException( new ErrorG(err) ); 233 } 234 235 return Str.toStringArray(p, length); 236 } 237 238 /** 239 * Retrieves the description of the bookmark for @uri. 240 * 241 * In the event the URI cannot be found, %NULL is returned and 242 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 243 * 244 * Params: 245 * uri = a valid URI 246 * 247 * Return: a newly allocated string or %NULL if the specified 248 * URI cannot be found. 249 * 250 * Since: 2.12 251 * 252 * Throws: GException on failure. 253 */ 254 public string getDescription(string uri) 255 { 256 GError* err = null; 257 258 auto p = g_bookmark_file_get_description(gBookmarkFile, Str.toStringz(uri), &err); 259 260 if (err !is null) 261 { 262 throw new GException( new ErrorG(err) ); 263 } 264 265 return Str.toString(p); 266 } 267 268 /** 269 * Retrieves the list of group names of the bookmark for @uri. 270 * 271 * In the event the URI cannot be found, %NULL is returned and 272 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 273 * 274 * The returned array is %NULL terminated, so @length may optionally 275 * be %NULL. 276 * 277 * Params: 278 * uri = a valid URI 279 * length = return location for the length of the returned string, or %NULL 280 * 281 * Return: a newly allocated %NULL-terminated array of group names. 282 * Use g_strfreev() to free it. 283 * 284 * Since: 2.12 285 * 286 * Throws: GException on failure. 287 */ 288 public string[] getGroups(string uri) 289 { 290 size_t length; 291 GError* err = null; 292 293 auto p = g_bookmark_file_get_groups(gBookmarkFile, Str.toStringz(uri), &length, &err); 294 295 if (err !is null) 296 { 297 throw new GException( new ErrorG(err) ); 298 } 299 300 return Str.toStringArray(p, length); 301 } 302 303 /** 304 * Gets the icon of the bookmark for @uri. 305 * 306 * In the event the URI cannot be found, %FALSE is returned and 307 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 308 * 309 * Params: 310 * uri = a valid URI 311 * href = return location for the icon's location or %NULL 312 * mimeType = return location for the icon's MIME type or %NULL 313 * 314 * Return: %TRUE if the icon for the bookmark for the URI was found. 315 * You should free the returned strings. 316 * 317 * Since: 2.12 318 * 319 * Throws: GException on failure. 320 */ 321 public bool getIcon(string uri, out string href, out string mimeType) 322 { 323 char* outhref = null; 324 char* outmimeType = null; 325 GError* err = null; 326 327 auto p = g_bookmark_file_get_icon(gBookmarkFile, Str.toStringz(uri), &outhref, &outmimeType, &err) != 0; 328 329 if (err !is null) 330 { 331 throw new GException( new ErrorG(err) ); 332 } 333 334 href = Str.toString(outhref); 335 mimeType = Str.toString(outmimeType); 336 337 return p; 338 } 339 340 /** 341 * Gets whether the private flag of the bookmark for @uri is set. 342 * 343 * In the event the URI cannot be found, %FALSE is returned and 344 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 345 * event that the private flag cannot be found, %FALSE is returned and 346 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE. 347 * 348 * Params: 349 * uri = a valid URI 350 * 351 * Return: %TRUE if the private flag is set, %FALSE otherwise. 352 * 353 * Since: 2.12 354 * 355 * Throws: GException on failure. 356 */ 357 public bool getIsPrivate(string uri) 358 { 359 GError* err = null; 360 361 auto p = g_bookmark_file_get_is_private(gBookmarkFile, Str.toStringz(uri), &err) != 0; 362 363 if (err !is null) 364 { 365 throw new GException( new ErrorG(err) ); 366 } 367 368 return p; 369 } 370 371 /** 372 * Retrieves the MIME type of the resource pointed by @uri. 373 * 374 * In the event the URI cannot be found, %NULL is returned and 375 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 376 * event that the MIME type cannot be found, %NULL is returned and 377 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE. 378 * 379 * Params: 380 * uri = a valid URI 381 * 382 * Return: a newly allocated string or %NULL if the specified 383 * URI cannot be found. 384 * 385 * Since: 2.12 386 * 387 * Throws: GException on failure. 388 */ 389 public string getMimeType(string uri) 390 { 391 GError* err = null; 392 393 auto p = g_bookmark_file_get_mime_type(gBookmarkFile, Str.toStringz(uri), &err); 394 395 if (err !is null) 396 { 397 throw new GException( new ErrorG(err) ); 398 } 399 400 return Str.toString(p); 401 } 402 403 /** 404 * Gets the time when the bookmark for @uri was last modified. 405 * 406 * In the event the URI cannot be found, -1 is returned and 407 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 408 * 409 * Params: 410 * uri = a valid URI 411 * 412 * Return: a timestamp 413 * 414 * Since: 2.12 415 * 416 * Throws: GException on failure. 417 */ 418 public uint getModified(string uri) 419 { 420 GError* err = null; 421 422 auto p = g_bookmark_file_get_modified(gBookmarkFile, Str.toStringz(uri), &err); 423 424 if (err !is null) 425 { 426 throw new GException( new ErrorG(err) ); 427 } 428 429 return p; 430 } 431 432 /** 433 * Gets the number of bookmarks inside @bookmark. 434 * 435 * Return: the number of bookmarks 436 * 437 * Since: 2.12 438 */ 439 public int getSize() 440 { 441 return g_bookmark_file_get_size(gBookmarkFile); 442 } 443 444 /** 445 * Returns the title of the bookmark for @uri. 446 * 447 * If @uri is %NULL, the title of @bookmark is returned. 448 * 449 * In the event the URI cannot be found, %NULL is returned and 450 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 451 * 452 * Params: 453 * uri = a valid URI or %NULL 454 * 455 * Return: a newly allocated string or %NULL if the specified 456 * URI cannot be found. 457 * 458 * Since: 2.12 459 * 460 * Throws: GException on failure. 461 */ 462 public string getTitle(string uri) 463 { 464 GError* err = null; 465 466 auto p = g_bookmark_file_get_title(gBookmarkFile, Str.toStringz(uri), &err); 467 468 if (err !is null) 469 { 470 throw new GException( new ErrorG(err) ); 471 } 472 473 return Str.toString(p); 474 } 475 476 /** 477 * Returns all URIs of the bookmarks in the bookmark file @bookmark. 478 * The array of returned URIs will be %NULL-terminated, so @length may 479 * optionally be %NULL. 480 * 481 * Params: 482 * length = return location for the number of returned URIs, or %NULL 483 * 484 * Return: a newly allocated %NULL-terminated array of strings. 485 * Use g_strfreev() to free it. 486 * 487 * Since: 2.12 488 */ 489 public string[] getUris() 490 { 491 size_t length; 492 493 return Str.toStringArray(g_bookmark_file_get_uris(gBookmarkFile, &length)); 494 } 495 496 /** 497 * Gets the time the bookmark for @uri was last visited. 498 * 499 * In the event the URI cannot be found, -1 is returned and 500 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 501 * 502 * Params: 503 * uri = a valid URI 504 * 505 * Return: a timestamp. 506 * 507 * Since: 2.12 508 * 509 * Throws: GException on failure. 510 */ 511 public uint getVisited(string uri) 512 { 513 GError* err = null; 514 515 auto p = g_bookmark_file_get_visited(gBookmarkFile, Str.toStringz(uri), &err); 516 517 if (err !is null) 518 { 519 throw new GException( new ErrorG(err) ); 520 } 521 522 return p; 523 } 524 525 /** 526 * Checks whether the bookmark for @uri inside @bookmark has been 527 * registered by application @name. 528 * 529 * In the event the URI cannot be found, %FALSE is returned and 530 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 531 * 532 * Params: 533 * uri = a valid URI 534 * name = the name of the application 535 * 536 * Return: %TRUE if the application @name was found 537 * 538 * Since: 2.12 539 * 540 * Throws: GException on failure. 541 */ 542 public bool hasApplication(string uri, string name) 543 { 544 GError* err = null; 545 546 auto p = g_bookmark_file_has_application(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &err) != 0; 547 548 if (err !is null) 549 { 550 throw new GException( new ErrorG(err) ); 551 } 552 553 return p; 554 } 555 556 /** 557 * Checks whether @group appears in the list of groups to which 558 * the bookmark for @uri belongs to. 559 * 560 * In the event the URI cannot be found, %FALSE is returned and 561 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 562 * 563 * Params: 564 * uri = a valid URI 565 * group = the group name to be searched 566 * 567 * Return: %TRUE if @group was found. 568 * 569 * Since: 2.12 570 * 571 * Throws: GException on failure. 572 */ 573 public bool hasGroup(string uri, string group) 574 { 575 GError* err = null; 576 577 auto p = g_bookmark_file_has_group(gBookmarkFile, Str.toStringz(uri), Str.toStringz(group), &err) != 0; 578 579 if (err !is null) 580 { 581 throw new GException( new ErrorG(err) ); 582 } 583 584 return p; 585 } 586 587 /** 588 * Looks whether the desktop bookmark has an item with its URI set to @uri. 589 * 590 * Params: 591 * uri = a valid URI 592 * 593 * Return: %TRUE if @uri is inside @bookmark, %FALSE otherwise 594 * 595 * Since: 2.12 596 */ 597 public bool hasItem(string uri) 598 { 599 return g_bookmark_file_has_item(gBookmarkFile, Str.toStringz(uri)) != 0; 600 } 601 602 /** 603 * Loads a bookmark file from memory into an empty #GBookmarkFile 604 * structure. If the object cannot be created then @error is set to a 605 * #GBookmarkFileError. 606 * 607 * Params: 608 * data = desktop bookmarks loaded in memory 609 * length = the length of @data in bytes 610 * 611 * Return: %TRUE if a desktop bookmark could be loaded. 612 * 613 * Since: 2.12 614 * 615 * Throws: GException on failure. 616 */ 617 public bool loadFromData(string data, size_t length) 618 { 619 GError* err = null; 620 621 auto p = g_bookmark_file_load_from_data(gBookmarkFile, Str.toStringz(data), length, &err) != 0; 622 623 if (err !is null) 624 { 625 throw new GException( new ErrorG(err) ); 626 } 627 628 return p; 629 } 630 631 /** 632 * This function looks for a desktop bookmark file named @file in the 633 * paths returned from g_get_user_data_dir() and g_get_system_data_dirs(), 634 * loads the file into @bookmark and returns the file's full path in 635 * @full_path. If the file could not be loaded then an %error is 636 * set to either a #GFileError or #GBookmarkFileError. 637 * 638 * Params: 639 * file = a relative path to a filename to open and parse 640 * fullPath = return location for a string containing the full path 641 * of the file, or %NULL 642 * 643 * Return: %TRUE if a key file could be loaded, %FALSE otherwise 644 * 645 * Since: 2.12 646 * 647 * Throws: GException on failure. 648 */ 649 public bool loadFromDataDirs(string file, out string fullPath) 650 { 651 char* outfullPath = null; 652 GError* err = null; 653 654 auto p = g_bookmark_file_load_from_data_dirs(gBookmarkFile, Str.toStringz(file), &outfullPath, &err) != 0; 655 656 if (err !is null) 657 { 658 throw new GException( new ErrorG(err) ); 659 } 660 661 fullPath = Str.toString(outfullPath); 662 663 return p; 664 } 665 666 /** 667 * Loads a desktop bookmark file into an empty #GBookmarkFile structure. 668 * If the file could not be loaded then @error is set to either a #GFileError 669 * or #GBookmarkFileError. 670 * 671 * Params: 672 * filename = the path of a filename to load, in the GLib file name encoding 673 * 674 * Return: %TRUE if a desktop bookmark file could be loaded 675 * 676 * Since: 2.12 677 * 678 * Throws: GException on failure. 679 */ 680 public bool loadFromFile(string filename) 681 { 682 GError* err = null; 683 684 auto p = g_bookmark_file_load_from_file(gBookmarkFile, Str.toStringz(filename), &err) != 0; 685 686 if (err !is null) 687 { 688 throw new GException( new ErrorG(err) ); 689 } 690 691 return p; 692 } 693 694 /** 695 * Changes the URI of a bookmark item from @old_uri to @new_uri. Any 696 * existing bookmark for @new_uri will be overwritten. If @new_uri is 697 * %NULL, then the bookmark is removed. 698 * 699 * In the event the URI cannot be found, %FALSE is returned and 700 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 701 * 702 * Params: 703 * oldUri = a valid URI 704 * newUri = a valid URI, or %NULL 705 * 706 * Return: %TRUE if the URI was successfully changed 707 * 708 * Since: 2.12 709 * 710 * Throws: GException on failure. 711 */ 712 public bool moveItem(string oldUri, string newUri) 713 { 714 GError* err = null; 715 716 auto p = g_bookmark_file_move_item(gBookmarkFile, Str.toStringz(oldUri), Str.toStringz(newUri), &err) != 0; 717 718 if (err !is null) 719 { 720 throw new GException( new ErrorG(err) ); 721 } 722 723 return p; 724 } 725 726 /** 727 * Removes application registered with @name from the list of applications 728 * that have registered a bookmark for @uri inside @bookmark. 729 * 730 * In the event the URI cannot be found, %FALSE is returned and 731 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 732 * In the event that no application with name @app_name has registered 733 * a bookmark for @uri, %FALSE is returned and error is set to 734 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. 735 * 736 * Params: 737 * uri = a valid URI 738 * name = the name of the application 739 * 740 * Return: %TRUE if the application was successfully removed. 741 * 742 * Since: 2.12 743 * 744 * Throws: GException on failure. 745 */ 746 public bool removeApplication(string uri, string name) 747 { 748 GError* err = null; 749 750 auto p = g_bookmark_file_remove_application(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &err) != 0; 751 752 if (err !is null) 753 { 754 throw new GException( new ErrorG(err) ); 755 } 756 757 return p; 758 } 759 760 /** 761 * Removes @group from the list of groups to which the bookmark 762 * for @uri belongs to. 763 * 764 * In the event the URI cannot be found, %FALSE is returned and 765 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 766 * In the event no group was defined, %FALSE is returned and 767 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE. 768 * 769 * Params: 770 * uri = a valid URI 771 * group = the group name to be removed 772 * 773 * Return: %TRUE if @group was successfully removed. 774 * 775 * Since: 2.12 776 * 777 * Throws: GException on failure. 778 */ 779 public bool removeGroup(string uri, string group) 780 { 781 GError* err = null; 782 783 auto p = g_bookmark_file_remove_group(gBookmarkFile, Str.toStringz(uri), Str.toStringz(group), &err) != 0; 784 785 if (err !is null) 786 { 787 throw new GException( new ErrorG(err) ); 788 } 789 790 return p; 791 } 792 793 /** 794 * Removes the bookmark for @uri from the bookmark file @bookmark. 795 * 796 * Params: 797 * uri = a valid URI 798 * 799 * Return: %TRUE if the bookmark was removed successfully. 800 * 801 * Since: 2.12 802 * 803 * Throws: GException on failure. 804 */ 805 public bool removeItem(string uri) 806 { 807 GError* err = null; 808 809 auto p = g_bookmark_file_remove_item(gBookmarkFile, Str.toStringz(uri), &err) != 0; 810 811 if (err !is null) 812 { 813 throw new GException( new ErrorG(err) ); 814 } 815 816 return p; 817 } 818 819 /** 820 * Sets the time the bookmark for @uri was added into @bookmark. 821 * 822 * If no bookmark for @uri is found then it is created. 823 * 824 * Params: 825 * uri = a valid URI 826 * added = a timestamp or -1 to use the current time 827 * 828 * Since: 2.12 829 */ 830 public void setAdded(string uri, uint added) 831 { 832 g_bookmark_file_set_added(gBookmarkFile, Str.toStringz(uri), added); 833 } 834 835 /** 836 * Sets the meta-data of application @name inside the list of 837 * applications that have registered a bookmark for @uri inside 838 * @bookmark. 839 * 840 * You should rarely use this function; use g_bookmark_file_add_application() 841 * and g_bookmark_file_remove_application() instead. 842 * 843 * @name can be any UTF-8 encoded string used to identify an 844 * application. 845 * @exec can have one of these two modifiers: "\%f", which will 846 * be expanded as the local file name retrieved from the bookmark's 847 * URI; "\%u", which will be expanded as the bookmark's URI. 848 * The expansion is done automatically when retrieving the stored 849 * command line using the g_bookmark_file_get_app_info() function. 850 * @count is the number of times the application has registered the 851 * bookmark; if is < 0, the current registration count will be increased 852 * by one, if is 0, the application with @name will be removed from 853 * the list of registered applications. 854 * @stamp is the Unix time of the last registration; if it is -1, the 855 * current time will be used. 856 * 857 * If you try to remove an application by setting its registration count to 858 * zero, and no bookmark for @uri is found, %FALSE is returned and 859 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly, 860 * in the event that no application @name has registered a bookmark 861 * for @uri, %FALSE is returned and error is set to 862 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark 863 * for @uri is found, one is created. 864 * 865 * Params: 866 * uri = a valid URI 867 * name = an application's name 868 * exec = an application's command line 869 * count = the number of registrations done for this application 870 * stamp = the time of the last registration for this application 871 * 872 * Return: %TRUE if the application's meta-data was successfully 873 * changed. 874 * 875 * Since: 2.12 876 * 877 * Throws: GException on failure. 878 */ 879 public bool setAppInfo(string uri, string name, string exec, int count, uint stamp) 880 { 881 GError* err = null; 882 883 auto p = g_bookmark_file_set_app_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), Str.toStringz(exec), count, stamp, &err) != 0; 884 885 if (err !is null) 886 { 887 throw new GException( new ErrorG(err) ); 888 } 889 890 return p; 891 } 892 893 /** 894 * Sets @description as the description of the bookmark for @uri. 895 * 896 * If @uri is %NULL, the description of @bookmark is set. 897 * 898 * If a bookmark for @uri cannot be found then it is created. 899 * 900 * Params: 901 * uri = a valid URI or %NULL 902 * description = a string 903 * 904 * Since: 2.12 905 */ 906 public void setDescription(string uri, string description) 907 { 908 g_bookmark_file_set_description(gBookmarkFile, Str.toStringz(uri), Str.toStringz(description)); 909 } 910 911 /** 912 * Sets a list of group names for the item with URI @uri. Each previously 913 * set group name list is removed. 914 * 915 * If @uri cannot be found then an item for it is created. 916 * 917 * Params: 918 * uri = an item's URI 919 * groups = an array of group names, or %NULL to remove all groups 920 * length = number of group name values in @groups 921 * 922 * Since: 2.12 923 */ 924 public void setGroups(string uri, string[] groups) 925 { 926 g_bookmark_file_set_groups(gBookmarkFile, Str.toStringz(uri), Str.toStringzArray(groups), cast(size_t)groups.length); 927 } 928 929 /** 930 * Sets the icon for the bookmark for @uri. If @href is %NULL, unsets 931 * the currently set icon. @href can either be a full URL for the icon 932 * file or the icon name following the Icon Naming specification. 933 * 934 * If no bookmark for @uri is found one is created. 935 * 936 * Params: 937 * uri = a valid URI 938 * href = the URI of the icon for the bookmark, or %NULL 939 * mimeType = the MIME type of the icon for the bookmark 940 * 941 * Since: 2.12 942 */ 943 public void setIcon(string uri, string href, string mimeType) 944 { 945 g_bookmark_file_set_icon(gBookmarkFile, Str.toStringz(uri), Str.toStringz(href), Str.toStringz(mimeType)); 946 } 947 948 /** 949 * Sets the private flag of the bookmark for @uri. 950 * 951 * If a bookmark for @uri cannot be found then it is created. 952 * 953 * Params: 954 * uri = a valid URI 955 * isPrivate = %TRUE if the bookmark should be marked as private 956 * 957 * Since: 2.12 958 */ 959 public void setIsPrivate(string uri, bool isPrivate) 960 { 961 g_bookmark_file_set_is_private(gBookmarkFile, Str.toStringz(uri), isPrivate); 962 } 963 964 /** 965 * Sets @mime_type as the MIME type of the bookmark for @uri. 966 * 967 * If a bookmark for @uri cannot be found then it is created. 968 * 969 * Params: 970 * uri = a valid URI 971 * mimeType = a MIME type 972 * 973 * Since: 2.12 974 */ 975 public void setMimeType(string uri, string mimeType) 976 { 977 g_bookmark_file_set_mime_type(gBookmarkFile, Str.toStringz(uri), Str.toStringz(mimeType)); 978 } 979 980 /** 981 * Sets the last time the bookmark for @uri was last modified. 982 * 983 * If no bookmark for @uri is found then it is created. 984 * 985 * The "modified" time should only be set when the bookmark's meta-data 986 * was actually changed. Every function of #GBookmarkFile that 987 * modifies a bookmark also changes the modification time, except for 988 * g_bookmark_file_set_visited(). 989 * 990 * Params: 991 * uri = a valid URI 992 * modified = a timestamp or -1 to use the current time 993 * 994 * Since: 2.12 995 */ 996 public void setModified(string uri, uint modified) 997 { 998 g_bookmark_file_set_modified(gBookmarkFile, Str.toStringz(uri), modified); 999 } 1000 1001 /** 1002 * Sets @title as the title of the bookmark for @uri inside the 1003 * bookmark file @bookmark. 1004 * 1005 * If @uri is %NULL, the title of @bookmark is set. 1006 * 1007 * If a bookmark for @uri cannot be found then it is created. 1008 * 1009 * Params: 1010 * uri = a valid URI or %NULL 1011 * title = a UTF-8 encoded string 1012 * 1013 * Since: 2.12 1014 */ 1015 public void setTitle(string uri, string title) 1016 { 1017 g_bookmark_file_set_title(gBookmarkFile, Str.toStringz(uri), Str.toStringz(title)); 1018 } 1019 1020 /** 1021 * Sets the time the bookmark for @uri was last visited. 1022 * 1023 * If no bookmark for @uri is found then it is created. 1024 * 1025 * The "visited" time should only be set if the bookmark was launched, 1026 * either using the command line retrieved by g_bookmark_file_get_app_info() 1027 * or by the default application for the bookmark's MIME type, retrieved 1028 * using g_bookmark_file_get_mime_type(). Changing the "visited" time 1029 * does not affect the "modified" time. 1030 * 1031 * Params: 1032 * uri = a valid URI 1033 * visited = a timestamp or -1 to use the current time 1034 * 1035 * Since: 2.12 1036 */ 1037 public void setVisited(string uri, uint visited) 1038 { 1039 g_bookmark_file_set_visited(gBookmarkFile, Str.toStringz(uri), visited); 1040 } 1041 1042 /** 1043 * This function outputs @bookmark as a string. 1044 * 1045 * Params: 1046 * length = return location for the length of the returned string, or %NULL 1047 * 1048 * Return: a newly allocated string holding 1049 * the contents of the #GBookmarkFile 1050 * 1051 * Since: 2.12 1052 * 1053 * Throws: GException on failure. 1054 */ 1055 public string toData(out size_t length) 1056 { 1057 GError* err = null; 1058 1059 auto p = g_bookmark_file_to_data(gBookmarkFile, &length, &err); 1060 1061 if (err !is null) 1062 { 1063 throw new GException( new ErrorG(err) ); 1064 } 1065 1066 return Str.toString(p); 1067 } 1068 1069 /** 1070 * This function outputs @bookmark into a file. The write process is 1071 * guaranteed to be atomic by using g_file_set_contents() internally. 1072 * 1073 * Params: 1074 * filename = path of the output file 1075 * 1076 * Return: %TRUE if the file was successfully written. 1077 * 1078 * Since: 2.12 1079 * 1080 * Throws: GException on failure. 1081 */ 1082 public bool toFile(string filename) 1083 { 1084 GError* err = null; 1085 1086 auto p = g_bookmark_file_to_file(gBookmarkFile, Str.toStringz(filename), &err) != 0; 1087 1088 if (err !is null) 1089 { 1090 throw new GException( new ErrorG(err) ); 1091 } 1092 1093 return p; 1094 } 1095 1096 public static GQuark errorQuark() 1097 { 1098 return g_bookmark_file_error_quark(); 1099 } 1100 1101 /** 1102 * Creates a new empty #GBookmarkFile object. 1103 * 1104 * Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data() 1105 * or g_bookmark_file_load_from_data_dirs() to read an existing bookmark 1106 * file. 1107 * 1108 * Return: an empty #GBookmarkFile 1109 * 1110 * Since: 2.12 1111 * 1112 * Throws: ConstructionException GTK+ fails to create the object. 1113 */ 1114 public this() 1115 { 1116 auto p = g_bookmark_file_new(); 1117 1118 if(p is null) 1119 { 1120 throw new ConstructionException("null returned by new"); 1121 } 1122 1123 this(cast(GBookmarkFile*) p); 1124 } 1125 }