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