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