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