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