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.DateTime; 29 private import glib.ErrorG; 30 private import glib.GException; 31 private import glib.Str; 32 private import glib.c.functions; 33 public import glib.c.types; 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 * Deprecated: Use g_bookmark_file_get_added_date_time() instead, as 149 * `time_t` is deprecated due to the year 2038 problem. 150 * 151 * Params: 152 * uri = a valid URI 153 * 154 * Returns: a timestamp 155 * 156 * Since: 2.12 157 * 158 * Throws: GException on failure. 159 */ 160 public uint getAdded(string uri) 161 { 162 GError* err = null; 163 164 auto __p = g_bookmark_file_get_added(gBookmarkFile, Str.toStringz(uri), &err); 165 166 if (err !is null) 167 { 168 throw new GException( new ErrorG(err) ); 169 } 170 171 return __p; 172 } 173 174 /** 175 * Gets the time the bookmark for @uri was added to @bookmark 176 * 177 * In the event the URI cannot be found, %NULL is returned and 178 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 179 * 180 * Params: 181 * uri = a valid URI 182 * 183 * Returns: a #GDateTime 184 * 185 * Since: 2.66 186 * 187 * Throws: GException on failure. 188 */ 189 public DateTime getAddedDateTime(string uri) 190 { 191 GError* err = null; 192 193 auto __p = g_bookmark_file_get_added_date_time(gBookmarkFile, Str.toStringz(uri), &err); 194 195 if (err !is null) 196 { 197 throw new GException( new ErrorG(err) ); 198 } 199 200 if(__p is null) 201 { 202 return null; 203 } 204 205 return new DateTime(cast(GDateTime*) __p); 206 } 207 208 /** 209 * Gets the registration information of @app_name for the bookmark for 210 * @uri. See g_bookmark_file_set_application_info() for more information about 211 * the returned data. 212 * 213 * The string returned in @app_exec must be freed. 214 * 215 * In the event the URI cannot be found, %FALSE is returned and 216 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 217 * event that no application with name @app_name has registered a bookmark 218 * for @uri, %FALSE is returned and error is set to 219 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting 220 * the command line fails, an error of the #G_SHELL_ERROR domain is 221 * set and %FALSE is returned. 222 * 223 * Deprecated: Use g_bookmark_file_get_application_info() instead, as 224 * `time_t` is deprecated due to the year 2038 problem. 225 * 226 * Params: 227 * uri = a valid URI 228 * name = an application's name 229 * exec = return location for the command line of the application, or %NULL 230 * count = return location for the registration count, or %NULL 231 * stamp = return location for the last registration time, or %NULL 232 * 233 * Returns: %TRUE on success. 234 * 235 * Since: 2.12 236 * 237 * Throws: GException on failure. 238 */ 239 public bool getAppInfo(string uri, string name, out string exec, out uint count, out uint stamp) 240 { 241 char* outexec = null; 242 GError* err = null; 243 244 auto __p = g_bookmark_file_get_app_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &outexec, &count, &stamp, &err) != 0; 245 246 if (err !is null) 247 { 248 throw new GException( new ErrorG(err) ); 249 } 250 251 exec = Str.toString(outexec); 252 253 return __p; 254 } 255 256 /** 257 * Gets the registration information of @app_name for the bookmark for 258 * @uri. See g_bookmark_file_set_application_info() for more information about 259 * the returned data. 260 * 261 * The string returned in @app_exec must be freed. 262 * 263 * In the event the URI cannot be found, %FALSE is returned and 264 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 265 * event that no application with name @app_name has registered a bookmark 266 * for @uri, %FALSE is returned and error is set to 267 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting 268 * the command line fails, an error of the #G_SHELL_ERROR domain is 269 * set and %FALSE is returned. 270 * 271 * Params: 272 * uri = a valid URI 273 * name = an application's name 274 * exec = return location for the command line of the application, or %NULL 275 * count = return location for the registration count, or %NULL 276 * stamp = return location for the last registration time, or %NULL 277 * 278 * Returns: %TRUE on success. 279 * 280 * Since: 2.66 281 * 282 * Throws: GException on failure. 283 */ 284 public bool getApplicationInfo(string uri, string name, out string exec, out uint count, out DateTime stamp) 285 { 286 char* outexec = null; 287 GDateTime* outstamp = null; 288 GError* err = null; 289 290 auto __p = g_bookmark_file_get_application_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &outexec, &count, &outstamp, &err) != 0; 291 292 if (err !is null) 293 { 294 throw new GException( new ErrorG(err) ); 295 } 296 297 exec = Str.toString(outexec); 298 stamp = new DateTime(outstamp); 299 300 return __p; 301 } 302 303 /** 304 * Retrieves the names of the applications that have registered the 305 * bookmark for @uri. 306 * 307 * In the event the URI cannot be found, %NULL is returned and 308 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 309 * 310 * Params: 311 * uri = a valid URI 312 * 313 * Returns: a newly allocated %NULL-terminated array of strings. 314 * Use g_strfreev() to free it. 315 * 316 * Since: 2.12 317 * 318 * Throws: GException on failure. 319 */ 320 public string[] getApplications(string uri) 321 { 322 size_t length; 323 GError* err = null; 324 325 auto retStr = g_bookmark_file_get_applications(gBookmarkFile, Str.toStringz(uri), &length, &err); 326 327 if (err !is null) 328 { 329 throw new GException( new ErrorG(err) ); 330 } 331 332 scope(exit) Str.freeStringArray(retStr); 333 return Str.toStringArray(retStr, length); 334 } 335 336 /** 337 * Retrieves the description of the bookmark for @uri. 338 * 339 * In the event the URI cannot be found, %NULL is returned and 340 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 341 * 342 * Params: 343 * uri = a valid URI 344 * 345 * Returns: a newly allocated string or %NULL if the specified 346 * URI cannot be found. 347 * 348 * Since: 2.12 349 * 350 * Throws: GException on failure. 351 */ 352 public string getDescription(string uri) 353 { 354 GError* err = null; 355 356 auto retStr = g_bookmark_file_get_description(gBookmarkFile, Str.toStringz(uri), &err); 357 358 if (err !is null) 359 { 360 throw new GException( new ErrorG(err) ); 361 } 362 363 scope(exit) Str.freeString(retStr); 364 return Str.toString(retStr); 365 } 366 367 /** 368 * Retrieves the list of group names of the bookmark for @uri. 369 * 370 * In the event the URI cannot be found, %NULL is returned and 371 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 372 * 373 * The returned array is %NULL terminated, so @length may optionally 374 * be %NULL. 375 * 376 * Params: 377 * uri = a valid URI 378 * 379 * Returns: a newly allocated %NULL-terminated array of group names. 380 * Use g_strfreev() to free it. 381 * 382 * Since: 2.12 383 * 384 * Throws: GException on failure. 385 */ 386 public string[] getGroups(string uri) 387 { 388 size_t length; 389 GError* err = null; 390 391 auto retStr = g_bookmark_file_get_groups(gBookmarkFile, Str.toStringz(uri), &length, &err); 392 393 if (err !is null) 394 { 395 throw new GException( new ErrorG(err) ); 396 } 397 398 scope(exit) Str.freeStringArray(retStr); 399 return Str.toStringArray(retStr, length); 400 } 401 402 /** 403 * Gets the icon of the bookmark for @uri. 404 * 405 * In the event the URI cannot be found, %FALSE is returned and 406 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 407 * 408 * Params: 409 * uri = a valid URI 410 * href = return location for the icon's location or %NULL 411 * mimeType = return location for the icon's MIME type or %NULL 412 * 413 * Returns: %TRUE if the icon for the bookmark for the URI was found. 414 * You should free the returned strings. 415 * 416 * Since: 2.12 417 * 418 * Throws: GException on failure. 419 */ 420 public bool getIcon(string uri, out string href, out string mimeType) 421 { 422 char* outhref = null; 423 char* outmimeType = null; 424 GError* err = null; 425 426 auto __p = g_bookmark_file_get_icon(gBookmarkFile, Str.toStringz(uri), &outhref, &outmimeType, &err) != 0; 427 428 if (err !is null) 429 { 430 throw new GException( new ErrorG(err) ); 431 } 432 433 href = Str.toString(outhref); 434 mimeType = Str.toString(outmimeType); 435 436 return __p; 437 } 438 439 /** 440 * Gets whether the private flag of the bookmark for @uri is set. 441 * 442 * In the event the URI cannot be found, %FALSE is returned and 443 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 444 * event that the private flag cannot be found, %FALSE is returned and 445 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE. 446 * 447 * Params: 448 * uri = a valid URI 449 * 450 * Returns: %TRUE if the private flag is set, %FALSE otherwise. 451 * 452 * Since: 2.12 453 * 454 * Throws: GException on failure. 455 */ 456 public bool getIsPrivate(string uri) 457 { 458 GError* err = null; 459 460 auto __p = g_bookmark_file_get_is_private(gBookmarkFile, Str.toStringz(uri), &err) != 0; 461 462 if (err !is null) 463 { 464 throw new GException( new ErrorG(err) ); 465 } 466 467 return __p; 468 } 469 470 /** 471 * Retrieves the MIME type of the resource pointed by @uri. 472 * 473 * In the event the URI cannot be found, %NULL is returned and 474 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 475 * event that the MIME type cannot be found, %NULL is returned and 476 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE. 477 * 478 * Params: 479 * uri = a valid URI 480 * 481 * Returns: a newly allocated string or %NULL if the specified 482 * URI cannot be found. 483 * 484 * Since: 2.12 485 * 486 * Throws: GException on failure. 487 */ 488 public string getMimeType(string uri) 489 { 490 GError* err = null; 491 492 auto retStr = g_bookmark_file_get_mime_type(gBookmarkFile, Str.toStringz(uri), &err); 493 494 if (err !is null) 495 { 496 throw new GException( new ErrorG(err) ); 497 } 498 499 scope(exit) Str.freeString(retStr); 500 return Str.toString(retStr); 501 } 502 503 /** 504 * Gets the time when the bookmark for @uri was last modified. 505 * 506 * In the event the URI cannot be found, -1 is returned and 507 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 508 * 509 * Deprecated: Use g_bookmark_file_get_modified_date_time() instead, as 510 * `time_t` is deprecated due to the year 2038 problem. 511 * 512 * Params: 513 * uri = a valid URI 514 * 515 * Returns: a timestamp 516 * 517 * Since: 2.12 518 * 519 * Throws: GException on failure. 520 */ 521 public uint getModified(string uri) 522 { 523 GError* err = null; 524 525 auto __p = g_bookmark_file_get_modified(gBookmarkFile, Str.toStringz(uri), &err); 526 527 if (err !is null) 528 { 529 throw new GException( new ErrorG(err) ); 530 } 531 532 return __p; 533 } 534 535 /** 536 * Gets the time when the bookmark for @uri was last modified. 537 * 538 * In the event the URI cannot be found, %NULL is returned and 539 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 540 * 541 * Params: 542 * uri = a valid URI 543 * 544 * Returns: a #GDateTime 545 * 546 * Since: 2.66 547 * 548 * Throws: GException on failure. 549 */ 550 public DateTime getModifiedDateTime(string uri) 551 { 552 GError* err = null; 553 554 auto __p = g_bookmark_file_get_modified_date_time(gBookmarkFile, Str.toStringz(uri), &err); 555 556 if (err !is null) 557 { 558 throw new GException( new ErrorG(err) ); 559 } 560 561 if(__p is null) 562 { 563 return null; 564 } 565 566 return new DateTime(cast(GDateTime*) __p); 567 } 568 569 /** 570 * Gets the number of bookmarks inside @bookmark. 571 * 572 * Returns: the number of bookmarks 573 * 574 * Since: 2.12 575 */ 576 public int getSize() 577 { 578 return g_bookmark_file_get_size(gBookmarkFile); 579 } 580 581 /** 582 * Returns the title of the bookmark for @uri. 583 * 584 * If @uri is %NULL, the title of @bookmark is returned. 585 * 586 * In the event the URI cannot be found, %NULL is returned and 587 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 588 * 589 * Params: 590 * uri = a valid URI or %NULL 591 * 592 * Returns: a newly allocated string or %NULL if the specified 593 * URI cannot be found. 594 * 595 * Since: 2.12 596 * 597 * Throws: GException on failure. 598 */ 599 public string getTitle(string uri) 600 { 601 GError* err = null; 602 603 auto retStr = g_bookmark_file_get_title(gBookmarkFile, Str.toStringz(uri), &err); 604 605 if (err !is null) 606 { 607 throw new GException( new ErrorG(err) ); 608 } 609 610 scope(exit) Str.freeString(retStr); 611 return Str.toString(retStr); 612 } 613 614 /** 615 * Returns all URIs of the bookmarks in the bookmark file @bookmark. 616 * The array of returned URIs will be %NULL-terminated, so @length may 617 * optionally be %NULL. 618 * 619 * Returns: a newly allocated %NULL-terminated array of strings. 620 * Use g_strfreev() to free it. 621 * 622 * Since: 2.12 623 */ 624 public string[] getUris() 625 { 626 size_t length; 627 628 auto retStr = g_bookmark_file_get_uris(gBookmarkFile, &length); 629 630 scope(exit) Str.freeStringArray(retStr); 631 return Str.toStringArray(retStr, length); 632 } 633 634 /** 635 * Gets the time the bookmark for @uri was last visited. 636 * 637 * In the event the URI cannot be found, -1 is returned and 638 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 639 * 640 * Deprecated: Use g_bookmark_file_get_visited_date_time() instead, as 641 * `time_t` is deprecated due to the year 2038 problem. 642 * 643 * Params: 644 * uri = a valid URI 645 * 646 * Returns: a timestamp. 647 * 648 * Since: 2.12 649 * 650 * Throws: GException on failure. 651 */ 652 public uint getVisited(string uri) 653 { 654 GError* err = null; 655 656 auto __p = g_bookmark_file_get_visited(gBookmarkFile, Str.toStringz(uri), &err); 657 658 if (err !is null) 659 { 660 throw new GException( new ErrorG(err) ); 661 } 662 663 return __p; 664 } 665 666 /** 667 * Gets the time the bookmark for @uri was last visited. 668 * 669 * In the event the URI cannot be found, %NULL is returned and 670 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 671 * 672 * Params: 673 * uri = a valid URI 674 * 675 * Returns: a #GDateTime 676 * 677 * Since: 2.66 678 * 679 * Throws: GException on failure. 680 */ 681 public DateTime getVisitedDateTime(string uri) 682 { 683 GError* err = null; 684 685 auto __p = g_bookmark_file_get_visited_date_time(gBookmarkFile, Str.toStringz(uri), &err); 686 687 if (err !is null) 688 { 689 throw new GException( new ErrorG(err) ); 690 } 691 692 if(__p is null) 693 { 694 return null; 695 } 696 697 return new DateTime(cast(GDateTime*) __p); 698 } 699 700 /** 701 * Checks whether the bookmark for @uri inside @bookmark has been 702 * registered by application @name. 703 * 704 * In the event the URI cannot be found, %FALSE is returned and 705 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 706 * 707 * Params: 708 * uri = a valid URI 709 * name = the name of the application 710 * 711 * Returns: %TRUE if the application @name was found 712 * 713 * Since: 2.12 714 * 715 * Throws: GException on failure. 716 */ 717 public bool hasApplication(string uri, string name) 718 { 719 GError* err = null; 720 721 auto __p = g_bookmark_file_has_application(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &err) != 0; 722 723 if (err !is null) 724 { 725 throw new GException( new ErrorG(err) ); 726 } 727 728 return __p; 729 } 730 731 /** 732 * Checks whether @group appears in the list of groups to which 733 * the bookmark for @uri belongs to. 734 * 735 * In the event the URI cannot be found, %FALSE is returned and 736 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 737 * 738 * Params: 739 * uri = a valid URI 740 * group = the group name to be searched 741 * 742 * Returns: %TRUE if @group was found. 743 * 744 * Since: 2.12 745 * 746 * Throws: GException on failure. 747 */ 748 public bool hasGroup(string uri, string group) 749 { 750 GError* err = null; 751 752 auto __p = g_bookmark_file_has_group(gBookmarkFile, Str.toStringz(uri), Str.toStringz(group), &err) != 0; 753 754 if (err !is null) 755 { 756 throw new GException( new ErrorG(err) ); 757 } 758 759 return __p; 760 } 761 762 /** 763 * Looks whether the desktop bookmark has an item with its URI set to @uri. 764 * 765 * Params: 766 * uri = a valid URI 767 * 768 * Returns: %TRUE if @uri is inside @bookmark, %FALSE otherwise 769 * 770 * Since: 2.12 771 */ 772 public bool hasItem(string uri) 773 { 774 return g_bookmark_file_has_item(gBookmarkFile, Str.toStringz(uri)) != 0; 775 } 776 777 /** 778 * Loads a bookmark file from memory into an empty #GBookmarkFile 779 * structure. If the object cannot be created then @error is set to a 780 * #GBookmarkFileError. 781 * 782 * Params: 783 * data = desktop bookmarks 784 * loaded in memory 785 * 786 * Returns: %TRUE if a desktop bookmark could be loaded. 787 * 788 * Since: 2.12 789 * 790 * Throws: GException on failure. 791 */ 792 public bool loadFromData(string data) 793 { 794 GError* err = null; 795 796 auto __p = g_bookmark_file_load_from_data(gBookmarkFile, Str.toStringz(data), cast(size_t)data.length, &err) != 0; 797 798 if (err !is null) 799 { 800 throw new GException( new ErrorG(err) ); 801 } 802 803 return __p; 804 } 805 806 /** 807 * This function looks for a desktop bookmark file named @file in the 808 * paths returned from g_get_user_data_dir() and g_get_system_data_dirs(), 809 * loads the file into @bookmark and returns the file's full path in 810 * @full_path. If the file could not be loaded then @error is 811 * set to either a #GFileError or #GBookmarkFileError. 812 * 813 * Params: 814 * file = a relative path to a filename to open and parse 815 * fullPath = return location for a string 816 * containing the full path of the file, or %NULL 817 * 818 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise 819 * 820 * Since: 2.12 821 * 822 * Throws: GException on failure. 823 */ 824 public bool loadFromDataDirs(string file, out string fullPath) 825 { 826 char* outfullPath = null; 827 GError* err = null; 828 829 auto __p = g_bookmark_file_load_from_data_dirs(gBookmarkFile, Str.toStringz(file), &outfullPath, &err) != 0; 830 831 if (err !is null) 832 { 833 throw new GException( new ErrorG(err) ); 834 } 835 836 fullPath = Str.toString(outfullPath); 837 838 return __p; 839 } 840 841 /** 842 * Loads a desktop bookmark file into an empty #GBookmarkFile structure. 843 * If the file could not be loaded then @error is set to either a #GFileError 844 * or #GBookmarkFileError. 845 * 846 * Params: 847 * filename = the path of a filename to load, in the 848 * GLib file name encoding 849 * 850 * Returns: %TRUE if a desktop bookmark file could be loaded 851 * 852 * Since: 2.12 853 * 854 * Throws: GException on failure. 855 */ 856 public bool loadFromFile(string filename) 857 { 858 GError* err = null; 859 860 auto __p = g_bookmark_file_load_from_file(gBookmarkFile, Str.toStringz(filename), &err) != 0; 861 862 if (err !is null) 863 { 864 throw new GException( new ErrorG(err) ); 865 } 866 867 return __p; 868 } 869 870 /** 871 * Changes the URI of a bookmark item from @old_uri to @new_uri. Any 872 * existing bookmark for @new_uri will be overwritten. If @new_uri is 873 * %NULL, then the bookmark is removed. 874 * 875 * In the event the URI cannot be found, %FALSE is returned and 876 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 877 * 878 * Params: 879 * oldUri = a valid URI 880 * newUri = a valid URI, or %NULL 881 * 882 * Returns: %TRUE if the URI was successfully changed 883 * 884 * Since: 2.12 885 * 886 * Throws: GException on failure. 887 */ 888 public bool moveItem(string oldUri, string newUri) 889 { 890 GError* err = null; 891 892 auto __p = g_bookmark_file_move_item(gBookmarkFile, Str.toStringz(oldUri), Str.toStringz(newUri), &err) != 0; 893 894 if (err !is null) 895 { 896 throw new GException( new ErrorG(err) ); 897 } 898 899 return __p; 900 } 901 902 /** 903 * Removes application registered with @name from the list of applications 904 * that have registered a bookmark for @uri inside @bookmark. 905 * 906 * In the event the URI cannot be found, %FALSE is returned and 907 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 908 * In the event that no application with name @app_name has registered 909 * a bookmark for @uri, %FALSE is returned and error is set to 910 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. 911 * 912 * Params: 913 * uri = a valid URI 914 * name = the name of the application 915 * 916 * Returns: %TRUE if the application was successfully removed. 917 * 918 * Since: 2.12 919 * 920 * Throws: GException on failure. 921 */ 922 public bool removeApplication(string uri, string name) 923 { 924 GError* err = null; 925 926 auto __p = g_bookmark_file_remove_application(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &err) != 0; 927 928 if (err !is null) 929 { 930 throw new GException( new ErrorG(err) ); 931 } 932 933 return __p; 934 } 935 936 /** 937 * Removes @group from the list of groups to which the bookmark 938 * for @uri belongs to. 939 * 940 * In the event the URI cannot be found, %FALSE is returned and 941 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 942 * In the event no group was defined, %FALSE is returned and 943 * @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE. 944 * 945 * Params: 946 * uri = a valid URI 947 * group = the group name to be removed 948 * 949 * Returns: %TRUE if @group was successfully removed. 950 * 951 * Since: 2.12 952 * 953 * Throws: GException on failure. 954 */ 955 public bool removeGroup(string uri, string group) 956 { 957 GError* err = null; 958 959 auto __p = g_bookmark_file_remove_group(gBookmarkFile, Str.toStringz(uri), Str.toStringz(group), &err) != 0; 960 961 if (err !is null) 962 { 963 throw new GException( new ErrorG(err) ); 964 } 965 966 return __p; 967 } 968 969 /** 970 * Removes the bookmark for @uri from the bookmark file @bookmark. 971 * 972 * Params: 973 * uri = a valid URI 974 * 975 * Returns: %TRUE if the bookmark was removed successfully. 976 * 977 * Since: 2.12 978 * 979 * Throws: GException on failure. 980 */ 981 public bool removeItem(string uri) 982 { 983 GError* err = null; 984 985 auto __p = g_bookmark_file_remove_item(gBookmarkFile, Str.toStringz(uri), &err) != 0; 986 987 if (err !is null) 988 { 989 throw new GException( new ErrorG(err) ); 990 } 991 992 return __p; 993 } 994 995 /** 996 * Sets the time the bookmark for @uri was added into @bookmark. 997 * 998 * If no bookmark for @uri is found then it is created. 999 * 1000 * Deprecated: Use g_bookmark_file_set_added_date_time() instead, as 1001 * `time_t` is deprecated due to the year 2038 problem. 1002 * 1003 * Params: 1004 * uri = a valid URI 1005 * added = a timestamp or -1 to use the current time 1006 * 1007 * Since: 2.12 1008 */ 1009 public void setAdded(string uri, uint added) 1010 { 1011 g_bookmark_file_set_added(gBookmarkFile, Str.toStringz(uri), added); 1012 } 1013 1014 /** 1015 * Sets the time the bookmark for @uri was added into @bookmark. 1016 * 1017 * If no bookmark for @uri is found then it is created. 1018 * 1019 * Params: 1020 * uri = a valid URI 1021 * added = a #GDateTime 1022 * 1023 * Since: 2.66 1024 */ 1025 public void setAddedDateTime(string uri, DateTime added) 1026 { 1027 g_bookmark_file_set_added_date_time(gBookmarkFile, Str.toStringz(uri), (added is null) ? null : added.getDateTimeStruct()); 1028 } 1029 1030 /** 1031 * Sets the meta-data of application @name inside the list of 1032 * applications that have registered a bookmark for @uri inside 1033 * @bookmark. 1034 * 1035 * You should rarely use this function; use g_bookmark_file_add_application() 1036 * and g_bookmark_file_remove_application() instead. 1037 * 1038 * @name can be any UTF-8 encoded string used to identify an 1039 * application. 1040 * @exec can have one of these two modifiers: "\%f", which will 1041 * be expanded as the local file name retrieved from the bookmark's 1042 * URI; "\%u", which will be expanded as the bookmark's URI. 1043 * The expansion is done automatically when retrieving the stored 1044 * command line using the g_bookmark_file_get_application_info() function. 1045 * @count is the number of times the application has registered the 1046 * bookmark; if is < 0, the current registration count will be increased 1047 * by one, if is 0, the application with @name will be removed from 1048 * the list of registered applications. 1049 * @stamp is the Unix time of the last registration; if it is -1, the 1050 * current time will be used. 1051 * 1052 * If you try to remove an application by setting its registration count to 1053 * zero, and no bookmark for @uri is found, %FALSE is returned and 1054 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly, 1055 * in the event that no application @name has registered a bookmark 1056 * for @uri, %FALSE is returned and error is set to 1057 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark 1058 * for @uri is found, one is created. 1059 * 1060 * Deprecated: Use g_bookmark_file_set_application_info() instead, as 1061 * `time_t` is deprecated due to the year 2038 problem. 1062 * 1063 * Params: 1064 * uri = a valid URI 1065 * name = an application's name 1066 * exec = an application's command line 1067 * count = the number of registrations done for this application 1068 * stamp = the time of the last registration for this application 1069 * 1070 * Returns: %TRUE if the application's meta-data was successfully 1071 * changed. 1072 * 1073 * Since: 2.12 1074 * 1075 * Throws: GException on failure. 1076 */ 1077 public bool setAppInfo(string uri, string name, string exec, int count, uint stamp) 1078 { 1079 GError* err = null; 1080 1081 auto __p = g_bookmark_file_set_app_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), Str.toStringz(exec), count, stamp, &err) != 0; 1082 1083 if (err !is null) 1084 { 1085 throw new GException( new ErrorG(err) ); 1086 } 1087 1088 return __p; 1089 } 1090 1091 /** 1092 * Sets the meta-data of application @name inside the list of 1093 * applications that have registered a bookmark for @uri inside 1094 * @bookmark. 1095 * 1096 * You should rarely use this function; use g_bookmark_file_add_application() 1097 * and g_bookmark_file_remove_application() instead. 1098 * 1099 * @name can be any UTF-8 encoded string used to identify an 1100 * application. 1101 * @exec can have one of these two modifiers: "\%f", which will 1102 * be expanded as the local file name retrieved from the bookmark's 1103 * URI; "\%u", which will be expanded as the bookmark's URI. 1104 * The expansion is done automatically when retrieving the stored 1105 * command line using the g_bookmark_file_get_application_info() function. 1106 * @count is the number of times the application has registered the 1107 * bookmark; if is < 0, the current registration count will be increased 1108 * by one, if is 0, the application with @name will be removed from 1109 * the list of registered applications. 1110 * @stamp is the Unix time of the last registration. 1111 * 1112 * If you try to remove an application by setting its registration count to 1113 * zero, and no bookmark for @uri is found, %FALSE is returned and 1114 * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly, 1115 * in the event that no application @name has registered a bookmark 1116 * for @uri, %FALSE is returned and error is set to 1117 * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark 1118 * for @uri is found, one is created. 1119 * 1120 * Params: 1121 * uri = a valid URI 1122 * name = an application's name 1123 * exec = an application's command line 1124 * count = the number of registrations done for this application 1125 * stamp = the time of the last registration for this application, 1126 * which may be %NULL if @count is 0 1127 * 1128 * Returns: %TRUE if the application's meta-data was successfully 1129 * changed. 1130 * 1131 * Since: 2.66 1132 * 1133 * Throws: GException on failure. 1134 */ 1135 public bool setApplicationInfo(string uri, string name, string exec, int count, DateTime stamp) 1136 { 1137 GError* err = null; 1138 1139 auto __p = g_bookmark_file_set_application_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), Str.toStringz(exec), count, (stamp is null) ? null : stamp.getDateTimeStruct(), &err) != 0; 1140 1141 if (err !is null) 1142 { 1143 throw new GException( new ErrorG(err) ); 1144 } 1145 1146 return __p; 1147 } 1148 1149 /** 1150 * Sets @description as the description of the bookmark for @uri. 1151 * 1152 * If @uri is %NULL, the description of @bookmark is set. 1153 * 1154 * If a bookmark for @uri cannot be found then it is created. 1155 * 1156 * Params: 1157 * uri = a valid URI or %NULL 1158 * description = a string 1159 * 1160 * Since: 2.12 1161 */ 1162 public void setDescription(string uri, string description) 1163 { 1164 g_bookmark_file_set_description(gBookmarkFile, Str.toStringz(uri), Str.toStringz(description)); 1165 } 1166 1167 /** 1168 * Sets a list of group names for the item with URI @uri. Each previously 1169 * set group name list is removed. 1170 * 1171 * If @uri cannot be found then an item for it is created. 1172 * 1173 * Params: 1174 * uri = an item's URI 1175 * groups = an array of 1176 * group names, or %NULL to remove all groups 1177 * 1178 * Since: 2.12 1179 */ 1180 public void setGroups(string uri, string[] groups) 1181 { 1182 g_bookmark_file_set_groups(gBookmarkFile, Str.toStringz(uri), Str.toStringzArray(groups), cast(size_t)groups.length); 1183 } 1184 1185 /** 1186 * Sets the icon for the bookmark for @uri. If @href is %NULL, unsets 1187 * the currently set icon. @href can either be a full URL for the icon 1188 * file or the icon name following the Icon Naming specification. 1189 * 1190 * If no bookmark for @uri is found one is created. 1191 * 1192 * Params: 1193 * uri = a valid URI 1194 * href = the URI of the icon for the bookmark, or %NULL 1195 * mimeType = the MIME type of the icon for the bookmark 1196 * 1197 * Since: 2.12 1198 */ 1199 public void setIcon(string uri, string href, string mimeType) 1200 { 1201 g_bookmark_file_set_icon(gBookmarkFile, Str.toStringz(uri), Str.toStringz(href), Str.toStringz(mimeType)); 1202 } 1203 1204 /** 1205 * Sets the private flag of the bookmark for @uri. 1206 * 1207 * If a bookmark for @uri cannot be found then it is created. 1208 * 1209 * Params: 1210 * uri = a valid URI 1211 * isPrivate = %TRUE if the bookmark should be marked as private 1212 * 1213 * Since: 2.12 1214 */ 1215 public void setIsPrivate(string uri, bool isPrivate) 1216 { 1217 g_bookmark_file_set_is_private(gBookmarkFile, Str.toStringz(uri), isPrivate); 1218 } 1219 1220 /** 1221 * Sets @mime_type as the MIME type of the bookmark for @uri. 1222 * 1223 * If a bookmark for @uri cannot be found then it is created. 1224 * 1225 * Params: 1226 * uri = a valid URI 1227 * mimeType = a MIME type 1228 * 1229 * Since: 2.12 1230 */ 1231 public void setMimeType(string uri, string mimeType) 1232 { 1233 g_bookmark_file_set_mime_type(gBookmarkFile, Str.toStringz(uri), Str.toStringz(mimeType)); 1234 } 1235 1236 /** 1237 * Sets the last time the bookmark for @uri was last modified. 1238 * 1239 * If no bookmark for @uri is found then it is created. 1240 * 1241 * The "modified" time should only be set when the bookmark's meta-data 1242 * was actually changed. Every function of #GBookmarkFile that 1243 * modifies a bookmark also changes the modification time, except for 1244 * g_bookmark_file_set_visited_date_time(). 1245 * 1246 * Deprecated: Use g_bookmark_file_set_modified_date_time() instead, as 1247 * `time_t` is deprecated due to the year 2038 problem. 1248 * 1249 * Params: 1250 * uri = a valid URI 1251 * modified = a timestamp or -1 to use the current time 1252 * 1253 * Since: 2.12 1254 */ 1255 public void setModified(string uri, uint modified) 1256 { 1257 g_bookmark_file_set_modified(gBookmarkFile, Str.toStringz(uri), modified); 1258 } 1259 1260 /** 1261 * Sets the last time the bookmark for @uri was last modified. 1262 * 1263 * If no bookmark for @uri is found then it is created. 1264 * 1265 * The "modified" time should only be set when the bookmark's meta-data 1266 * was actually changed. Every function of #GBookmarkFile that 1267 * modifies a bookmark also changes the modification time, except for 1268 * g_bookmark_file_set_visited_date_time(). 1269 * 1270 * Params: 1271 * uri = a valid URI 1272 * modified = a #GDateTime 1273 * 1274 * Since: 2.66 1275 */ 1276 public void setModifiedDateTime(string uri, DateTime modified) 1277 { 1278 g_bookmark_file_set_modified_date_time(gBookmarkFile, Str.toStringz(uri), (modified is null) ? null : modified.getDateTimeStruct()); 1279 } 1280 1281 /** 1282 * Sets @title as the title of the bookmark for @uri inside the 1283 * bookmark file @bookmark. 1284 * 1285 * If @uri is %NULL, the title of @bookmark is set. 1286 * 1287 * If a bookmark for @uri cannot be found then it is created. 1288 * 1289 * Params: 1290 * uri = a valid URI or %NULL 1291 * title = a UTF-8 encoded string 1292 * 1293 * Since: 2.12 1294 */ 1295 public void setTitle(string uri, string title) 1296 { 1297 g_bookmark_file_set_title(gBookmarkFile, Str.toStringz(uri), Str.toStringz(title)); 1298 } 1299 1300 /** 1301 * Sets the time the bookmark for @uri was last visited. 1302 * 1303 * If no bookmark for @uri is found then it is created. 1304 * 1305 * The "visited" time should only be set if the bookmark was launched, 1306 * either using the command line retrieved by g_bookmark_file_get_application_info() 1307 * or by the default application for the bookmark's MIME type, retrieved 1308 * using g_bookmark_file_get_mime_type(). Changing the "visited" time 1309 * does not affect the "modified" time. 1310 * 1311 * Deprecated: Use g_bookmark_file_set_visited_date_time() instead, as 1312 * `time_t` is deprecated due to the year 2038 problem. 1313 * 1314 * Params: 1315 * uri = a valid URI 1316 * visited = a timestamp or -1 to use the current time 1317 * 1318 * Since: 2.12 1319 */ 1320 public void setVisited(string uri, uint visited) 1321 { 1322 g_bookmark_file_set_visited(gBookmarkFile, Str.toStringz(uri), visited); 1323 } 1324 1325 /** 1326 * Sets the time the bookmark for @uri was last visited. 1327 * 1328 * If no bookmark for @uri is found then it is created. 1329 * 1330 * The "visited" time should only be set if the bookmark was launched, 1331 * either using the command line retrieved by g_bookmark_file_get_application_info() 1332 * or by the default application for the bookmark's MIME type, retrieved 1333 * using g_bookmark_file_get_mime_type(). Changing the "visited" time 1334 * does not affect the "modified" time. 1335 * 1336 * Params: 1337 * uri = a valid URI 1338 * visited = a #GDateTime 1339 * 1340 * Since: 2.66 1341 */ 1342 public void setVisitedDateTime(string uri, DateTime visited) 1343 { 1344 g_bookmark_file_set_visited_date_time(gBookmarkFile, Str.toStringz(uri), (visited is null) ? null : visited.getDateTimeStruct()); 1345 } 1346 1347 /** 1348 * This function outputs @bookmark as a string. 1349 * 1350 * Returns: a newly allocated string holding the contents of the #GBookmarkFile 1351 * 1352 * Since: 2.12 1353 * 1354 * Throws: GException on failure. 1355 */ 1356 public string toData() 1357 { 1358 size_t length; 1359 GError* err = null; 1360 1361 auto retStr = g_bookmark_file_to_data(gBookmarkFile, &length, &err); 1362 1363 if (err !is null) 1364 { 1365 throw new GException( new ErrorG(err) ); 1366 } 1367 1368 scope(exit) Str.freeString(retStr); 1369 return Str.toString(retStr, length); 1370 } 1371 1372 /** 1373 * This function outputs @bookmark into a file. The write process is 1374 * guaranteed to be atomic by using g_file_set_contents() internally. 1375 * 1376 * Params: 1377 * filename = path of the output file 1378 * 1379 * Returns: %TRUE if the file was successfully written. 1380 * 1381 * Since: 2.12 1382 * 1383 * Throws: GException on failure. 1384 */ 1385 public bool toFile(string filename) 1386 { 1387 GError* err = null; 1388 1389 auto __p = g_bookmark_file_to_file(gBookmarkFile, Str.toStringz(filename), &err) != 0; 1390 1391 if (err !is null) 1392 { 1393 throw new GException( new ErrorG(err) ); 1394 } 1395 1396 return __p; 1397 } 1398 1399 /** */ 1400 public static GQuark errorQuark() 1401 { 1402 return g_bookmark_file_error_quark(); 1403 } 1404 1405 /** 1406 * Creates a new empty #GBookmarkFile object. 1407 * 1408 * Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data() 1409 * or g_bookmark_file_load_from_data_dirs() to read an existing bookmark 1410 * file. 1411 * 1412 * Returns: an empty #GBookmarkFile 1413 * 1414 * Since: 2.12 1415 * 1416 * Throws: ConstructionException GTK+ fails to create the object. 1417 */ 1418 public this() 1419 { 1420 auto __p = g_bookmark_file_new(); 1421 1422 if(__p is null) 1423 { 1424 throw new ConstructionException("null returned by new"); 1425 } 1426 1427 this(cast(GBookmarkFile*) __p); 1428 } 1429 }