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