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