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 informations of @app_name for the bookmark for 173 * @uri. See g_bookmark_file_set_app_info() for more informations 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 loaded in memory 623 * length = the length of @data in bytes 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, size_t length) 632 { 633 GError* err = null; 634 635 auto p = g_bookmark_file_load_from_data(gBookmarkFile, Str.toStringz(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 an %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 group names, or %NULL to remove all 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 }