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 = GAppInfo.html 27 * outPack = gio 28 * outFile = AppInfoT 29 * strct = GAppInfo 30 * realStrct= 31 * ctorStrct= 32 * clss = AppInfoT 33 * interf = AppInfoIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - g_app_info_ 42 * omit structs: 43 * omit prefixes: 44 * - g_app_launch_context_ 45 * omit code: 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - glib.ErrorG 50 * - glib.GException 51 * - glib.ListG 52 * - gio.AppInfoIF 53 * - gio.AppLaunchContext 54 * - gio.Icon 55 * - gio.IconIF 56 * structWrap: 57 * - GAppInfo* -> AppInfoIF 58 * - GAppLaunchContext* -> AppLaunchContext 59 * - GIcon* -> IconIF 60 * - GList* -> ListG 61 * module aliases: 62 * local aliases: 63 * overrides: 64 */ 65 66 module gio.AppInfoT; 67 68 public import gtkc.giotypes; 69 70 public import gtkc.gio; 71 public import glib.ConstructionException; 72 public import gobject.ObjectG; 73 74 public import gobject.Signals; 75 public import gtkc.gdktypes; 76 77 public import glib.Str; 78 public import glib.ErrorG; 79 public import glib.GException; 80 public import glib.ListG; 81 public import gio.AppInfoIF; 82 public import gio.AppLaunchContext; 83 public import gio.Icon; 84 public import gio.IconIF; 85 86 87 88 89 /** 90 * GAppInfo and GAppLaunchContext are used for describing and launching 91 * applications installed on the system. 92 * 93 * As of GLib 2.20, URIs will always be converted to POSIX paths 94 * (using g_file_get_path()) when using g_app_info_launch() even if 95 * the application requested an URI and not a POSIX path. For example 96 * for an desktop-file based application with Exec key totem 97 * %U and a single URI, 98 * sftp://foo/file.avi, then 99 * /home/user/.gvfs/sftp on foo/file.avi will be 100 * passed. This will only work if a set of suitable GIO extensions 101 * (such as gvfs 2.26 compiled with FUSE support), is available and 102 * operational; if this is not the case, the URI will be passed 103 * unmodified to the application. Some URIs, such as 104 * mailto:, of course cannot be mapped to a POSIX 105 * path (in gvfs there's no FUSE mount for it); such URIs will be 106 * passed unmodified to the application. 107 * 108 * Specifically for gvfs 2.26 and later, the POSIX URI will be mapped 109 * back to the GIO URI in the GFile constructors (since gvfs 110 * implements the GVfs extension point). As such, if the application 111 * needs to examine the URI, it needs to use g_file_get_uri() or 112 * similar on GFile. In other words, an application cannot assume 113 * that the URI passed to e.g. g_file_new_for_commandline_arg() is 114 * equal to the result of g_file_get_uri(). The following snippet 115 * illustrates this: 116 * 117 * GFile *f; 118 * char *uri; 119 * 120 * file = g_file_new_for_commandline_arg (uri_from_commandline); 121 * 122 * uri = g_file_get_uri (file); 123 * strcmp (uri, uri_from_commandline) == 0; // FALSE 124 * g_free (uri); 125 * 126 * if (g_file_has_uri_scheme (file, "cdda")) 127 * { 128 * // do something special with uri 129 * } 130 * g_object_unref (file); 131 * 132 * This code will work when both cdda://sr0/Track 133 * 1.wav and /home/user/.gvfs/cdda on sr0/Track 134 * 1.wav is passed to the application. It should be noted 135 * that it's generally not safe for applications to rely on the format 136 * of a particular URIs. Different launcher applications (e.g. file 137 * managers) may have different ideas of what a given URI means. 138 */ 139 public template AppInfoT(TStruct) 140 { 141 142 /** the main Gtk struct */ 143 protected GAppInfo* gAppInfo; 144 145 146 public GAppInfo* getAppInfoTStruct() 147 { 148 return cast(GAppInfo*)getStruct(); 149 } 150 151 152 /** 153 */ 154 int[string] connectedSignals; 155 156 void delegate(string, AppInfoIF)[] _onLaunchFailedListeners; 157 void delegate(string, AppInfoIF)[] onLaunchFailedListeners() 158 { 159 return _onLaunchFailedListeners; 160 } 161 /** 162 */ 163 void addOnLaunchFailed(void delegate(string, AppInfoIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 164 { 165 if ( !("launch-failed" in connectedSignals) ) 166 { 167 Signals.connectData( 168 getStruct(), 169 "launch-failed", 170 cast(GCallback)&callBackLaunchFailed, 171 cast(void*)cast(AppInfoIF)this, 172 null, 173 connectFlags); 174 connectedSignals["launch-failed"] = 1; 175 } 176 _onLaunchFailedListeners ~= dlg; 177 } 178 extern(C) static void callBackLaunchFailed(GAppLaunchContext* gapplaunchcontextStruct, gchar* arg1, AppInfoIF _appInfoIF) 179 { 180 foreach ( void delegate(string, AppInfoIF) dlg ; _appInfoIF.onLaunchFailedListeners ) 181 { 182 dlg(Str.toString(arg1), _appInfoIF); 183 } 184 } 185 186 void delegate(AppInfoIF, GVariant*, AppInfoIF)[] _onLaunchedListeners; 187 void delegate(AppInfoIF, GVariant*, AppInfoIF)[] onLaunchedListeners() 188 { 189 return _onLaunchedListeners; 190 } 191 /** 192 */ 193 void addOnLaunched(void delegate(AppInfoIF, GVariant*, AppInfoIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 194 { 195 if ( !("launched" in connectedSignals) ) 196 { 197 Signals.connectData( 198 getStruct(), 199 "launched", 200 cast(GCallback)&callBackLaunched, 201 cast(void*)cast(AppInfoIF)this, 202 null, 203 connectFlags); 204 connectedSignals["launched"] = 1; 205 } 206 _onLaunchedListeners ~= dlg; 207 } 208 extern(C) static void callBackLaunched(GAppLaunchContext* gapplaunchcontextStruct, GAppInfo* arg1, GVariant* arg2, AppInfoIF _appInfoIF) 209 { 210 foreach ( void delegate(AppInfoIF, GVariant*, AppInfoIF) dlg ; _appInfoIF.onLaunchedListeners ) 211 { 212 dlg(ObjectG.getDObject!(AppInfo, AppInfoIF)(arg1), arg2, _appInfoIF); 213 } 214 } 215 216 217 /** 218 * Creates a new GAppInfo from the given information. 219 * Note that for commandline, the quoting rules of the Exec key of the 220 * freedesktop.org Desktop 221 * Entry Specification are applied. For example, if the commandline contains 222 * percent-encoded URIs, the percent-character must be doubled in order to prevent it from 223 * being swallowed by Exec key unquoting. See the specification for exact quoting rules. 224 * Params: 225 * commandline = the commandline to use 226 * applicationName = the application name, or NULL to use commandline. [allow-none] 227 * flags = flags that can specify details of the created GAppInfo 228 * Returns: new GAppInfo for given command. [transfer full] 229 * Throws: GException on failure. 230 */ 231 public static AppInfoIF createFromCommandline(string commandline, string applicationName, GAppInfoCreateFlags flags) 232 { 233 // GAppInfo * g_app_info_create_from_commandline (const char *commandline, const char *application_name, GAppInfoCreateFlags flags, GError **error); 234 GError* err = null; 235 236 auto p = g_app_info_create_from_commandline(Str.toStringz(commandline), Str.toStringz(applicationName), flags, &err); 237 238 if (err !is null) 239 { 240 throw new GException( new ErrorG(err) ); 241 } 242 243 244 if(p is null) 245 { 246 return null; 247 } 248 249 return ObjectG.getDObject!(AppInfo, AppInfoIF)(cast(GAppInfo*) p); 250 } 251 252 /** 253 * Creates a duplicate of a GAppInfo. 254 * Returns: a duplicate of appinfo. [transfer full] 255 */ 256 public AppInfoIF dup() 257 { 258 // GAppInfo * g_app_info_dup (GAppInfo *appinfo); 259 auto p = g_app_info_dup(getAppInfoTStruct()); 260 261 if(p is null) 262 { 263 return null; 264 } 265 266 return ObjectG.getDObject!(AppInfo, AppInfoIF)(cast(GAppInfo*) p); 267 } 268 269 /** 270 * Checks if two GAppInfos are equal. 271 * Params: 272 * appinfo2 = the second GAppInfo. 273 * Returns: TRUE if appinfo1 is equal to appinfo2. FALSE otherwise. 274 */ 275 public int equal(AppInfoIF appinfo2) 276 { 277 // gboolean g_app_info_equal (GAppInfo *appinfo1, GAppInfo *appinfo2); 278 return g_app_info_equal(getAppInfoTStruct(), (appinfo2 is null) ? null : appinfo2.getAppInfoTStruct()); 279 } 280 281 /** 282 * Gets the ID of an application. An id is a string that 283 * identifies the application. The exact format of the id is 284 * platform dependent. For instance, on Unix this is the 285 * desktop file id from the xdg menu specification. 286 * Note that the returned ID may be NULL, depending on how 287 * the appinfo has been constructed. 288 * Returns: a string containing the application's ID. 289 */ 290 public string getId() 291 { 292 // const char * g_app_info_get_id (GAppInfo *appinfo); 293 return Str.toString(g_app_info_get_id(getAppInfoTStruct())); 294 } 295 296 /** 297 * Gets the installed name of the application. 298 * Returns: the name of the application for appinfo. 299 */ 300 public string getName() 301 { 302 // const char * g_app_info_get_name (GAppInfo *appinfo); 303 return Str.toString(g_app_info_get_name(getAppInfoTStruct())); 304 } 305 306 /** 307 * Gets the display name of the application. The display name is often more 308 * descriptive to the user than the name itself. 309 * Since 2.24 310 * Returns: the display name of the application for appinfo, or the name if no display name is available. 311 */ 312 public string getDisplayName() 313 { 314 // const char * g_app_info_get_display_name (GAppInfo *appinfo); 315 return Str.toString(g_app_info_get_display_name(getAppInfoTStruct())); 316 } 317 318 /** 319 * Gets a human-readable description of an installed application. 320 * Returns: a string containing a description of the application appinfo, or NULL if none. 321 */ 322 public string getDescription() 323 { 324 // const char * g_app_info_get_description (GAppInfo *appinfo); 325 return Str.toString(g_app_info_get_description(getAppInfoTStruct())); 326 } 327 328 /** 329 * Gets the executable's name for the installed application. 330 * Returns: a string containing the appinfo's application binaries name 331 */ 332 public string getExecutable() 333 { 334 // const char * g_app_info_get_executable (GAppInfo *appinfo); 335 return Str.toString(g_app_info_get_executable(getAppInfoTStruct())); 336 } 337 338 /** 339 * Gets the commandline with which the application will be 340 * started. 341 * Since 2.20 342 * Returns: a string containing the appinfo's commandline, or NULL if this information is not available 343 */ 344 public string getCommandline() 345 { 346 // const char * g_app_info_get_commandline (GAppInfo *appinfo); 347 return Str.toString(g_app_info_get_commandline(getAppInfoTStruct())); 348 } 349 350 /** 351 * Gets the icon for the application. 352 * Returns: the default GIcon for appinfo or NULL if there is no default icon. [transfer none] 353 */ 354 public IconIF getIcon() 355 { 356 // GIcon * g_app_info_get_icon (GAppInfo *appinfo); 357 auto p = g_app_info_get_icon(getAppInfoTStruct()); 358 359 if(p is null) 360 { 361 return null; 362 } 363 364 return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p); 365 } 366 367 /** 368 * Launches the application. Passes files to the launched application 369 * as arguments, using the optional launch_context to get information 370 * about the details of the launcher (like what screen it is on). 371 * On error, error will be set accordingly. 372 * To launch the application without arguments pass a NULL files list. 373 * Note that even if the launch is successful the application launched 374 * can fail to start if it runs into problems during startup. There is 375 * no way to detect this. 376 * Some URIs can be changed when passed through a GFile (for instance 377 * unsupported URIs with strange formats like mailto:), so if you have 378 * a textual URI you want to pass in as argument, consider using 379 * g_app_info_launch_uris() instead. 380 * The launched application inherits the environment of the launching 381 * process, but it can be modified with g_app_launch_context_setenv() and 382 * g_app_launch_context_unsetenv(). 383 * On UNIX, this function sets the GIO_LAUNCHED_DESKTOP_FILE 384 * environment variable with the path of the launched desktop file and 385 * GIO_LAUNCHED_DESKTOP_FILE_PID to the process 386 * id of the launched process. This can be used to ignore 387 * GIO_LAUNCHED_DESKTOP_FILE, should it be inherited 388 * by further processes. The DISPLAY and 389 * DESKTOP_STARTUP_ID environment variables are also 390 * set, based on information provided in launch_context. 391 * Params: 392 * files = a GList of GFile objects. [allow-none][element-type GFile] 393 * launchContext = a GAppLaunchContext or NULL. [allow-none] 394 * Returns: TRUE on successful launch, FALSE otherwise. 395 * Throws: GException on failure. 396 */ 397 public int launch(ListG files, AppLaunchContext launchContext) 398 { 399 // gboolean g_app_info_launch (GAppInfo *appinfo, GList *files, GAppLaunchContext *launch_context, GError **error); 400 GError* err = null; 401 402 auto p = g_app_info_launch(getAppInfoTStruct(), (files is null) ? null : files.getListGStruct(), (launchContext is null) ? null : launchContext.getAppLaunchContextStruct(), &err); 403 404 if (err !is null) 405 { 406 throw new GException( new ErrorG(err) ); 407 } 408 409 return p; 410 } 411 412 /** 413 * Checks if the application accepts files as arguments. 414 * Returns: TRUE if the appinfo supports files. 415 */ 416 public int supportsFiles() 417 { 418 // gboolean g_app_info_supports_files (GAppInfo *appinfo); 419 return g_app_info_supports_files(getAppInfoTStruct()); 420 } 421 422 /** 423 * Checks if the application supports reading files and directories from URIs. 424 * Returns: TRUE if the appinfo supports URIs. 425 */ 426 public int supportsUris() 427 { 428 // gboolean g_app_info_supports_uris (GAppInfo *appinfo); 429 return g_app_info_supports_uris(getAppInfoTStruct()); 430 } 431 432 /** 433 * Launches the application. This passes the uris to the launched application 434 * as arguments, using the optional launch_context to get information 435 * about the details of the launcher (like what screen it is on). 436 * On error, error will be set accordingly. 437 * To launch the application without arguments pass a NULL uris list. 438 * Note that even if the launch is successful the application launched 439 * can fail to start if it runs into problems during startup. There is 440 * no way to detect this. 441 * Params: 442 * uris = a GList containing URIs to launch. [allow-none][element-type utf8] 443 * launchContext = a GAppLaunchContext or NULL. [allow-none] 444 * Returns: TRUE on successful launch, FALSE otherwise. 445 * Throws: GException on failure. 446 */ 447 public int launchUris(ListG uris, AppLaunchContext launchContext) 448 { 449 // gboolean g_app_info_launch_uris (GAppInfo *appinfo, GList *uris, GAppLaunchContext *launch_context, GError **error); 450 GError* err = null; 451 452 auto p = g_app_info_launch_uris(getAppInfoTStruct(), (uris is null) ? null : uris.getListGStruct(), (launchContext is null) ? null : launchContext.getAppLaunchContextStruct(), &err); 453 454 if (err !is null) 455 { 456 throw new GException( new ErrorG(err) ); 457 } 458 459 return p; 460 } 461 462 /** 463 * Checks if the application info should be shown in menus that 464 * list available applications. 465 * Returns: TRUE if the appinfo should be shown, FALSE otherwise. 466 */ 467 public int shouldShow() 468 { 469 // gboolean g_app_info_should_show (GAppInfo *appinfo); 470 return g_app_info_should_show(getAppInfoTStruct()); 471 } 472 473 /** 474 * Obtains the information whether the GAppInfo can be deleted. 475 * See g_app_info_delete(). 476 * Since 2.20 477 * Returns: TRUE if appinfo can be deleted 478 */ 479 public int canDelete() 480 { 481 // gboolean g_app_info_can_delete (GAppInfo *appinfo); 482 return g_app_info_can_delete(getAppInfoTStruct()); 483 } 484 485 /** 486 * Tries to delete a GAppInfo. 487 * On some platforms, there may be a difference between user-defined 488 * GAppInfos which can be deleted, and system-wide ones which 489 * cannot. See g_app_info_can_delete(). 490 * Virtual: do_delete 491 * Since 2.20 492 * Returns: TRUE if appinfo has been deleted 493 */ 494 public int delet() 495 { 496 // gboolean g_app_info_delete (GAppInfo *appinfo); 497 return g_app_info_delete(getAppInfoTStruct()); 498 } 499 500 /** 501 * Removes all changes to the type associations done by 502 * g_app_info_set_as_default_for_type(), 503 * g_app_info_set_as_default_for_extension(), 504 * g_app_info_add_supports_type() or 505 * g_app_info_remove_supports_type(). 506 * Since 2.20 507 * Params: 508 * contentType = a content type 509 */ 510 public static void resetTypeAssociations(string contentType) 511 { 512 // void g_app_info_reset_type_associations (const char *content_type); 513 g_app_info_reset_type_associations(Str.toStringz(contentType)); 514 } 515 516 /** 517 * Sets the application as the default handler for a given type. 518 * Params: 519 * contentType = the content type. 520 * Returns: TRUE on success, FALSE on error. 521 * Throws: GException on failure. 522 */ 523 public int setAsDefaultForType(string contentType) 524 { 525 // gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo, const char *content_type, GError **error); 526 GError* err = null; 527 528 auto p = g_app_info_set_as_default_for_type(getAppInfoTStruct(), Str.toStringz(contentType), &err); 529 530 if (err !is null) 531 { 532 throw new GException( new ErrorG(err) ); 533 } 534 535 return p; 536 } 537 538 /** 539 * Sets the application as the default handler for the given file extension. 540 * Params: 541 * extension = a string containing the file extension (without the dot). 542 * Returns: TRUE on success, FALSE on error. 543 * Throws: GException on failure. 544 */ 545 public int setAsDefaultForExtension(string extension) 546 { 547 // gboolean g_app_info_set_as_default_for_extension (GAppInfo *appinfo, const char *extension, GError **error); 548 GError* err = null; 549 550 auto p = g_app_info_set_as_default_for_extension(getAppInfoTStruct(), Str.toStringz(extension), &err); 551 552 if (err !is null) 553 { 554 throw new GException( new ErrorG(err) ); 555 } 556 557 return p; 558 } 559 560 /** 561 * Sets the application as the last used application for a given type. 562 * This will make the application appear as first in the list returned 563 * by g_app_info_get_recommended_for_type(), regardless of the default 564 * application for that content type. 565 * Params: 566 * contentType = the content type. 567 * Returns: TRUE on success, FALSE on error. 568 * Throws: GException on failure. 569 */ 570 public int setAsLastUsedForType(string contentType) 571 { 572 // gboolean g_app_info_set_as_last_used_for_type (GAppInfo *appinfo, const char *content_type, GError **error); 573 GError* err = null; 574 575 auto p = g_app_info_set_as_last_used_for_type(getAppInfoTStruct(), Str.toStringz(contentType), &err); 576 577 if (err !is null) 578 { 579 throw new GException( new ErrorG(err) ); 580 } 581 582 return p; 583 } 584 585 /** 586 * Adds a content type to the application information to indicate the 587 * application is capable of opening files with the given content type. 588 * Params: 589 * contentType = a string. 590 * Returns: TRUE on success, FALSE on error. 591 * Throws: GException on failure. 592 */ 593 public int addSupportsType(string contentType) 594 { 595 // gboolean g_app_info_add_supports_type (GAppInfo *appinfo, const char *content_type, GError **error); 596 GError* err = null; 597 598 auto p = g_app_info_add_supports_type(getAppInfoTStruct(), Str.toStringz(contentType), &err); 599 600 if (err !is null) 601 { 602 throw new GException( new ErrorG(err) ); 603 } 604 605 return p; 606 } 607 608 /** 609 * Checks if a supported content type can be removed from an application. 610 * Returns: TRUE if it is possible to remove supported content types from a given appinfo, FALSE if not. 611 */ 612 public int canRemoveSupportsType() 613 { 614 // gboolean g_app_info_can_remove_supports_type (GAppInfo *appinfo); 615 return g_app_info_can_remove_supports_type(getAppInfoTStruct()); 616 } 617 618 /** 619 * Removes a supported type from an application, if possible. 620 * Params: 621 * contentType = a string. 622 * Returns: TRUE on success, FALSE on error. 623 * Throws: GException on failure. 624 */ 625 public int removeSupportsType(string contentType) 626 { 627 // gboolean g_app_info_remove_supports_type (GAppInfo *appinfo, const char *content_type, GError **error); 628 GError* err = null; 629 630 auto p = g_app_info_remove_supports_type(getAppInfoTStruct(), Str.toStringz(contentType), &err); 631 632 if (err !is null) 633 { 634 throw new GException( new ErrorG(err) ); 635 } 636 637 return p; 638 } 639 640 /** 641 * Retrieves the list of content types that app_info claims to support. 642 * If this information is not provided by the environment, this function 643 * will return NULL. 644 * This function does not take in consideration associations added with 645 * g_app_info_add_supports_type(), but only those exported directly by 646 * the application. 647 * Since 2.34 648 * Returns: a list of content types. [transfer none][array zero-terminated=1][element-type utf8] 649 */ 650 public string[] getSupportedTypes() 651 { 652 // const char ** g_app_info_get_supported_types (GAppInfo *appinfo); 653 return Str.toStringArray(g_app_info_get_supported_types(getAppInfoTStruct())); 654 } 655 656 /** 657 * Gets a list of all of the applications currently registered 658 * on this system. 659 * For desktop files, this includes applications that have 660 * NoDisplay=true set or are excluded from 661 * display by means of OnlyShowIn or 662 * NotShowIn. See g_app_info_should_show(). 663 * The returned list does not include applications which have 664 * the Hidden key set. 665 * Returns: a newly allocated GList of references to GAppInfos. [element-type GAppInfo][transfer full] 666 */ 667 public static ListG getAll() 668 { 669 // GList * g_app_info_get_all (void); 670 auto p = g_app_info_get_all(); 671 672 if(p is null) 673 { 674 return null; 675 } 676 677 return ObjectG.getDObject!(ListG)(cast(GList*) p); 678 } 679 680 /** 681 * Gets a list of all GAppInfos for a given content type, 682 * including the recommended and fallback GAppInfos. See 683 * g_app_info_get_recommended_for_type() and 684 * g_app_info_get_fallback_for_type(). 685 * Params: 686 * contentType = the content type to find a GAppInfo for 687 * Returns: GList of GAppInfos for given content_type or NULL on error. [element-type GAppInfo][transfer full] 688 */ 689 public static ListG getAllForType(string contentType) 690 { 691 // GList * g_app_info_get_all_for_type (const char *content_type); 692 auto p = g_app_info_get_all_for_type(Str.toStringz(contentType)); 693 694 if(p is null) 695 { 696 return null; 697 } 698 699 return ObjectG.getDObject!(ListG)(cast(GList*) p); 700 } 701 702 /** 703 * Gets the default GAppInfo for a given content type. 704 * Params: 705 * contentType = the content type to find a GAppInfo for 706 * mustSupportUris = if TRUE, the GAppInfo is expected to 707 * support URIs 708 * Returns: GAppInfo for given content_type or NULL on error. [transfer full] 709 */ 710 public static AppInfoIF getDefaultForType(string contentType, int mustSupportUris) 711 { 712 // GAppInfo * g_app_info_get_default_for_type (const char *content_type, gboolean must_support_uris); 713 auto p = g_app_info_get_default_for_type(Str.toStringz(contentType), mustSupportUris); 714 715 if(p is null) 716 { 717 return null; 718 } 719 720 return ObjectG.getDObject!(AppInfo, AppInfoIF)(cast(GAppInfo*) p); 721 } 722 723 /** 724 * Gets the default application for handling URIs with 725 * the given URI scheme. A URI scheme is the initial part 726 * of the URI, up to but not including the ':', e.g. "http", 727 * "ftp" or "sip". 728 * Params: 729 * uriScheme = a string containing a URI scheme. 730 * Returns: GAppInfo for given uri_scheme or NULL on error. [transfer full] 731 */ 732 public static AppInfoIF getDefaultForUriScheme(string uriScheme) 733 { 734 // GAppInfo * g_app_info_get_default_for_uri_scheme (const char *uri_scheme); 735 auto p = g_app_info_get_default_for_uri_scheme(Str.toStringz(uriScheme)); 736 737 if(p is null) 738 { 739 return null; 740 } 741 742 return ObjectG.getDObject!(AppInfo, AppInfoIF)(cast(GAppInfo*) p); 743 } 744 745 /** 746 * Gets a list of fallback GAppInfos for a given content type, i.e. 747 * those applications which claim to support the given content type 748 * by MIME type subclassing and not directly. 749 * Since 2.28 750 * Params: 751 * contentType = the content type to find a GAppInfo for 752 * Returns: GList of GAppInfos for given content_type or NULL on error. [element-type GAppInfo][transfer full] 753 */ 754 public static ListG getFallbackForType(string contentType) 755 { 756 // GList * g_app_info_get_fallback_for_type (const gchar *content_type); 757 auto p = g_app_info_get_fallback_for_type(Str.toStringz(contentType)); 758 759 if(p is null) 760 { 761 return null; 762 } 763 764 return ObjectG.getDObject!(ListG)(cast(GList*) p); 765 } 766 767 /** 768 * Gets a list of recommended GAppInfos for a given content type, i.e. 769 * those applications which claim to support the given content type exactly, 770 * and not by MIME type subclassing. 771 * Note that the first application of the list is the last used one, i.e. 772 * the last one for which g_app_info_set_as_last_used_for_type() has been 773 * called. 774 * Since 2.28 775 * Params: 776 * contentType = the content type to find a GAppInfo for 777 * Returns: GList of GAppInfos for given content_type or NULL on error. [element-type GAppInfo][transfer full] 778 */ 779 public static ListG getRecommendedForType(string contentType) 780 { 781 // GList * g_app_info_get_recommended_for_type (const gchar *content_type); 782 auto p = g_app_info_get_recommended_for_type(Str.toStringz(contentType)); 783 784 if(p is null) 785 { 786 return null; 787 } 788 789 return ObjectG.getDObject!(ListG)(cast(GList*) p); 790 } 791 792 /** 793 * Utility function that launches the default application 794 * registered to handle the specified uri. Synchronous I/O 795 * is done on the uri to detect the type of the file if 796 * required. 797 * Params: 798 * uri = the uri to show 799 * launchContext = an optional GAppLaunchContext. [allow-none] 800 * Returns: TRUE on success, FALSE on error. 801 * Throws: GException on failure. 802 */ 803 public static int launchDefaultForUri(string uri, AppLaunchContext launchContext) 804 { 805 // gboolean g_app_info_launch_default_for_uri (const char *uri, GAppLaunchContext *launch_context, GError **error); 806 GError* err = null; 807 808 auto p = g_app_info_launch_default_for_uri(Str.toStringz(uri), (launchContext is null) ? null : launchContext.getAppLaunchContextStruct(), &err); 809 810 if (err !is null) 811 { 812 throw new GException( new ErrorG(err) ); 813 } 814 815 return p; 816 } 817 }