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 = AppInfoIF 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 * extend = 38 * implements: 39 * prefixes: 40 * - g_app_info_ 41 * omit structs: 42 * omit prefixes: 43 * - g_app_launch_context_ 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ErrorG 49 * - glib.GException 50 * - glib.ListG 51 * - gio.AppInfoIF 52 * - gio.AppLaunchContext 53 * - gio.Icon 54 * - gio.IconIF 55 * structWrap: 56 * - GAppInfo* -> AppInfoIF 57 * - GAppLaunchContext* -> AppLaunchContext 58 * - GIcon* -> IconIF 59 * - GList* -> ListG 60 * module aliases: 61 * local aliases: 62 * overrides: 63 */ 64 65 module gio.AppInfoIF; 66 67 public import gtkc.giotypes; 68 69 private import gtkc.gio; 70 private import glib.ConstructionException; 71 private import gobject.ObjectG; 72 73 private import gobject.Signals; 74 public import gtkc.gdktypes; 75 private import glib.Str; 76 private import glib.ErrorG; 77 private import glib.GException; 78 private import glib.ListG; 79 private import gio.AppInfoIF; 80 private import gio.AppLaunchContext; 81 private import gio.Icon; 82 private import gio.IconIF; 83 84 85 86 /** 87 * GAppInfo and GAppLaunchContext are used for describing and launching 88 * applications installed on the system. 89 * 90 * As of GLib 2.20, URIs will always be converted to POSIX paths 91 * (using g_file_get_path()) when using g_app_info_launch() even if 92 * the application requested an URI and not a POSIX path. For example 93 * for an desktop-file based application with Exec key totem 94 * %U and a single URI, 95 * sftp://foo/file.avi, then 96 * /home/user/.gvfs/sftp on foo/file.avi will be 97 * passed. This will only work if a set of suitable GIO extensions 98 * (such as gvfs 2.26 compiled with FUSE support), is available and 99 * operational; if this is not the case, the URI will be passed 100 * unmodified to the application. Some URIs, such as 101 * mailto:, of course cannot be mapped to a POSIX 102 * path (in gvfs there's no FUSE mount for it); such URIs will be 103 * passed unmodified to the application. 104 * 105 * Specifically for gvfs 2.26 and later, the POSIX URI will be mapped 106 * back to the GIO URI in the GFile constructors (since gvfs 107 * implements the GVfs extension point). As such, if the application 108 * needs to examine the URI, it needs to use g_file_get_uri() or 109 * similar on GFile. In other words, an application cannot assume 110 * that the URI passed to e.g. g_file_new_for_commandline_arg() is 111 * equal to the result of g_file_get_uri(). The following snippet 112 * illustrates this: 113 * 114 * GFile *f; 115 * char *uri; 116 * 117 * file = g_file_new_for_commandline_arg (uri_from_commandline); 118 * 119 * uri = g_file_get_uri (file); 120 * strcmp (uri, uri_from_commandline) == 0; // FALSE 121 * g_free (uri); 122 * 123 * if (g_file_has_uri_scheme (file, "cdda")) 124 * { 125 * // do something special with uri 126 * } 127 * g_object_unref (file); 128 * 129 * This code will work when both cdda://sr0/Track 130 * 1.wav and /home/user/.gvfs/cdda on sr0/Track 131 * 1.wav is passed to the application. It should be noted 132 * that it's generally not safe for applications to rely on the format 133 * of a particular URIs. Different launcher applications (e.g. file 134 * managers) may have different ideas of what a given URI means. 135 */ 136 public interface AppInfoIF 137 { 138 139 140 /** Get the main Gtk struct */ 141 public GAppInfo* getAppInfoTStruct(); 142 143 /** the main Gtk struct as a void* */ 144 protected void* getStruct(); 145 146 147 /** 148 */ 149 150 @property void delegate(string, AppInfoIF)[] onLaunchFailedListeners(); 151 /** 152 */ 153 void addOnLaunchFailed(void delegate(string, AppInfoIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 154 @property void delegate(AppInfoIF, GVariant*, AppInfoIF)[] onLaunchedListeners(); 155 /** 156 */ 157 void addOnLaunched(void delegate(AppInfoIF, GVariant*, AppInfoIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 158 159 /** 160 * Creates a new GAppInfo from the given information. 161 * Note that for commandline, the quoting rules of the Exec key of the 162 * freedesktop.org Desktop 163 * Entry Specification are applied. For example, if the commandline contains 164 * percent-encoded URIs, the percent-character must be doubled in order to prevent it from 165 * being swallowed by Exec key unquoting. See the specification for exact quoting rules. 166 * Params: 167 * commandline = the commandline to use 168 * applicationName = the application name, or NULL to use commandline. [allow-none] 169 * flags = flags that can specify details of the created GAppInfo 170 * Returns: new GAppInfo for given command. [transfer full] 171 * Throws: GException on failure. 172 */ 173 public static AppInfoIF createFromCommandline(string commandline, string applicationName, GAppInfoCreateFlags flags); 174 175 /** 176 * Creates a duplicate of a GAppInfo. 177 * Returns: a duplicate of appinfo. [transfer full] 178 */ 179 public AppInfoIF dup(); 180 181 /** 182 * Checks if two GAppInfos are equal. 183 * Params: 184 * appinfo2 = the second GAppInfo. 185 * Returns: TRUE if appinfo1 is equal to appinfo2. FALSE otherwise. 186 */ 187 public int equal(AppInfoIF appinfo2); 188 189 /** 190 * Gets the ID of an application. An id is a string that 191 * identifies the application. The exact format of the id is 192 * platform dependent. For instance, on Unix this is the 193 * desktop file id from the xdg menu specification. 194 * Note that the returned ID may be NULL, depending on how 195 * the appinfo has been constructed. 196 * Returns: a string containing the application's ID. 197 */ 198 public string getId(); 199 200 /** 201 * Gets the installed name of the application. 202 * Returns: the name of the application for appinfo. 203 */ 204 public string getName(); 205 206 /** 207 * Gets the display name of the application. The display name is often more 208 * descriptive to the user than the name itself. 209 * Since 2.24 210 * Returns: the display name of the application for appinfo, or the name if no display name is available. 211 */ 212 public string getDisplayName(); 213 214 /** 215 * Gets a human-readable description of an installed application. 216 * Returns: a string containing a description of the application appinfo, or NULL if none. 217 */ 218 public string getDescription(); 219 220 /** 221 * Gets the executable's name for the installed application. 222 * Returns: a string containing the appinfo's application binaries name 223 */ 224 public string getExecutable(); 225 226 /** 227 * Gets the commandline with which the application will be 228 * started. 229 * Since 2.20 230 * Returns: a string containing the appinfo's commandline, or NULL if this information is not available 231 */ 232 public string getCommandline(); 233 234 /** 235 * Gets the icon for the application. 236 * Returns: the default GIcon for appinfo or NULL if there is no default icon. [transfer none] 237 */ 238 public IconIF getIcon(); 239 240 /** 241 * Launches the application. Passes files to the launched application 242 * as arguments, using the optional launch_context to get information 243 * about the details of the launcher (like what screen it is on). 244 * On error, error will be set accordingly. 245 * To launch the application without arguments pass a NULL files list. 246 * Note that even if the launch is successful the application launched 247 * can fail to start if it runs into problems during startup. There is 248 * no way to detect this. 249 * Some URIs can be changed when passed through a GFile (for instance 250 * unsupported URIs with strange formats like mailto:), so if you have 251 * a textual URI you want to pass in as argument, consider using 252 * g_app_info_launch_uris() instead. 253 * The launched application inherits the environment of the launching 254 * process, but it can be modified with g_app_launch_context_setenv() and 255 * g_app_launch_context_unsetenv(). 256 * On UNIX, this function sets the GIO_LAUNCHED_DESKTOP_FILE 257 * environment variable with the path of the launched desktop file and 258 * GIO_LAUNCHED_DESKTOP_FILE_PID to the process 259 * id of the launched process. This can be used to ignore 260 * GIO_LAUNCHED_DESKTOP_FILE, should it be inherited 261 * by further processes. The DISPLAY and 262 * DESKTOP_STARTUP_ID environment variables are also 263 * set, based on information provided in launch_context. 264 * Params: 265 * files = a GList of GFile objects. [allow-none][element-type GFile] 266 * launchContext = a GAppLaunchContext or NULL. [allow-none] 267 * Returns: TRUE on successful launch, FALSE otherwise. 268 * Throws: GException on failure. 269 */ 270 public int launch(ListG files, AppLaunchContext launchContext); 271 272 /** 273 * Checks if the application accepts files as arguments. 274 * Returns: TRUE if the appinfo supports files. 275 */ 276 public int supportsFiles(); 277 278 /** 279 * Checks if the application supports reading files and directories from URIs. 280 * Returns: TRUE if the appinfo supports URIs. 281 */ 282 public int supportsUris(); 283 284 /** 285 * Launches the application. This passes the uris to the launched application 286 * as arguments, using the optional launch_context to get information 287 * about the details of the launcher (like what screen it is on). 288 * On error, error will be set accordingly. 289 * To launch the application without arguments pass a NULL uris list. 290 * Note that even if the launch is successful the application launched 291 * can fail to start if it runs into problems during startup. There is 292 * no way to detect this. 293 * Params: 294 * uris = a GList containing URIs to launch. [allow-none][element-type utf8] 295 * launchContext = a GAppLaunchContext or NULL. [allow-none] 296 * Returns: TRUE on successful launch, FALSE otherwise. 297 * Throws: GException on failure. 298 */ 299 public int launchUris(ListG uris, AppLaunchContext launchContext); 300 301 /** 302 * Checks if the application info should be shown in menus that 303 * list available applications. 304 * Returns: TRUE if the appinfo should be shown, FALSE otherwise. 305 */ 306 public int shouldShow(); 307 308 /** 309 * Obtains the information whether the GAppInfo can be deleted. 310 * See g_app_info_delete(). 311 * Since 2.20 312 * Returns: TRUE if appinfo can be deleted 313 */ 314 public int canDelete(); 315 316 /** 317 * Tries to delete a GAppInfo. 318 * On some platforms, there may be a difference between user-defined 319 * GAppInfos which can be deleted, and system-wide ones which 320 * cannot. See g_app_info_can_delete(). 321 * Virtual: do_delete 322 * Since 2.20 323 * Returns: TRUE if appinfo has been deleted 324 */ 325 public int delet(); 326 327 /** 328 * Removes all changes to the type associations done by 329 * g_app_info_set_as_default_for_type(), 330 * g_app_info_set_as_default_for_extension(), 331 * g_app_info_add_supports_type() or 332 * g_app_info_remove_supports_type(). 333 * Since 2.20 334 * Params: 335 * contentType = a content type 336 */ 337 public static void resetTypeAssociations(string contentType); 338 339 /** 340 * Sets the application as the default handler for a given type. 341 * Params: 342 * contentType = the content type. 343 * Returns: TRUE on success, FALSE on error. 344 * Throws: GException on failure. 345 */ 346 public int setAsDefaultForType(string contentType); 347 348 /** 349 * Sets the application as the default handler for the given file extension. 350 * Params: 351 * extension = a string containing the file extension (without the dot). 352 * Returns: TRUE on success, FALSE on error. 353 * Throws: GException on failure. 354 */ 355 public int setAsDefaultForExtension(string extension); 356 357 /** 358 * Sets the application as the last used application for a given type. 359 * This will make the application appear as first in the list returned 360 * by g_app_info_get_recommended_for_type(), regardless of the default 361 * application for that content type. 362 * Params: 363 * contentType = the content type. 364 * Returns: TRUE on success, FALSE on error. 365 * Throws: GException on failure. 366 */ 367 public int setAsLastUsedForType(string contentType); 368 369 /** 370 * Adds a content type to the application information to indicate the 371 * application is capable of opening files with the given content type. 372 * Params: 373 * contentType = a string. 374 * Returns: TRUE on success, FALSE on error. 375 * Throws: GException on failure. 376 */ 377 public int addSupportsType(string contentType); 378 379 /** 380 * Checks if a supported content type can be removed from an application. 381 * Returns: TRUE if it is possible to remove supported content types from a given appinfo, FALSE if not. 382 */ 383 public int canRemoveSupportsType(); 384 385 /** 386 * Removes a supported type from an application, if possible. 387 * Params: 388 * contentType = a string. 389 * Returns: TRUE on success, FALSE on error. 390 * Throws: GException on failure. 391 */ 392 public int removeSupportsType(string contentType); 393 394 /** 395 * Retrieves the list of content types that app_info claims to support. 396 * If this information is not provided by the environment, this function 397 * will return NULL. 398 * This function does not take in consideration associations added with 399 * g_app_info_add_supports_type(), but only those exported directly by 400 * the application. 401 * Since 2.34 402 * Returns: a list of content types. [transfer none][array zero-terminated=1][element-type utf8] 403 */ 404 public string[] getSupportedTypes(); 405 406 /** 407 * Gets a list of all of the applications currently registered 408 * on this system. 409 * For desktop files, this includes applications that have 410 * NoDisplay=true set or are excluded from 411 * display by means of OnlyShowIn or 412 * NotShowIn. See g_app_info_should_show(). 413 * The returned list does not include applications which have 414 * the Hidden key set. 415 * Returns: a newly allocated GList of references to GAppInfos. [element-type GAppInfo][transfer full] 416 */ 417 public static ListG getAll(); 418 419 /** 420 * Gets a list of all GAppInfos for a given content type, 421 * including the recommended and fallback GAppInfos. See 422 * g_app_info_get_recommended_for_type() and 423 * g_app_info_get_fallback_for_type(). 424 * Params: 425 * contentType = the content type to find a GAppInfo for 426 * Returns: GList of GAppInfos for given content_type or NULL on error. [element-type GAppInfo][transfer full] 427 */ 428 public static ListG getAllForType(string contentType); 429 430 /** 431 * Gets the default GAppInfo for a given content type. 432 * Params: 433 * contentType = the content type to find a GAppInfo for 434 * mustSupportUris = if TRUE, the GAppInfo is expected to 435 * support URIs 436 * Returns: GAppInfo for given content_type or NULL on error. [transfer full] 437 */ 438 public static AppInfoIF getDefaultForType(string contentType, int mustSupportUris); 439 440 /** 441 * Gets the default application for handling URIs with 442 * the given URI scheme. A URI scheme is the initial part 443 * of the URI, up to but not including the ':', e.g. "http", 444 * "ftp" or "sip". 445 * Params: 446 * uriScheme = a string containing a URI scheme. 447 * Returns: GAppInfo for given uri_scheme or NULL on error. [transfer full] 448 */ 449 public static AppInfoIF getDefaultForUriScheme(string uriScheme); 450 451 /** 452 * Gets a list of fallback GAppInfos for a given content type, i.e. 453 * those applications which claim to support the given content type 454 * by MIME type subclassing and not directly. 455 * Since 2.28 456 * Params: 457 * contentType = the content type to find a GAppInfo for 458 * Returns: GList of GAppInfos for given content_type or NULL on error. [element-type GAppInfo][transfer full] 459 */ 460 public static ListG getFallbackForType(string contentType); 461 462 /** 463 * Gets a list of recommended GAppInfos for a given content type, i.e. 464 * those applications which claim to support the given content type exactly, 465 * and not by MIME type subclassing. 466 * Note that the first application of the list is the last used one, i.e. 467 * the last one for which g_app_info_set_as_last_used_for_type() has been 468 * called. 469 * Since 2.28 470 * Params: 471 * contentType = the content type to find a GAppInfo for 472 * Returns: GList of GAppInfos for given content_type or NULL on error. [element-type GAppInfo][transfer full] 473 */ 474 public static ListG getRecommendedForType(string contentType); 475 476 /** 477 * Utility function that launches the default application 478 * registered to handle the specified uri. Synchronous I/O 479 * is done on the uri to detect the type of the file if 480 * required. 481 * Params: 482 * uri = the uri to show 483 * launchContext = an optional GAppLaunchContext. [allow-none] 484 * Returns: TRUE on success, FALSE on error. 485 * Throws: GException on failure. 486 */ 487 public static int launchDefaultForUri(string uri, AppLaunchContext launchContext); 488 }