1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.AppInfoIF;
26 
27 private import gio.AppInfo;
28 private import gio.AppInfoIF;
29 private import gio.AppLaunchContext;
30 private import gio.AsyncResultIF;
31 private import gio.Cancellable;
32 private import gio.FileIF;
33 private import gio.Icon;
34 private import gio.IconIF;
35 private import glib.ErrorG;
36 private import glib.GException;
37 private import glib.ListG;
38 private import glib.Str;
39 private import gobject.ObjectG;
40 private import gtkc.gio;
41 public  import gtkc.giotypes;
42 
43 
44 /**
45  * #GAppInfo and #GAppLaunchContext are used for describing and launching
46  * applications installed on the system.
47  * 
48  * As of GLib 2.20, URIs will always be converted to POSIX paths
49  * (using g_file_get_path()) when using g_app_info_launch() even if
50  * the application requested an URI and not a POSIX path. For example
51  * for an desktop-file based application with Exec key `totem
52  * %U` and a single URI, `sftp://foo/file.avi`, then
53  * `/home/user/.gvfs/sftp on foo/file.avi` will be passed. This will
54  * only work if a set of suitable GIO extensions (such as gvfs 2.26
55  * compiled with FUSE support), is available and operational; if this
56  * is not the case, the URI will be passed unmodified to the application.
57  * Some URIs, such as `mailto:`, of course cannot be mapped to a POSIX
58  * path (in gvfs there's no FUSE mount for it); such URIs will be
59  * passed unmodified to the application.
60  * 
61  * Specifically for gvfs 2.26 and later, the POSIX URI will be mapped
62  * back to the GIO URI in the #GFile constructors (since gvfs
63  * implements the #GVfs extension point). As such, if the application
64  * needs to examine the URI, it needs to use g_file_get_uri() or
65  * similar on #GFile. In other words, an application cannot assume
66  * that the URI passed to e.g. g_file_new_for_commandline_arg() is
67  * equal to the result of g_file_get_uri(). The following snippet
68  * illustrates this:
69  * 
70  * |[
71  * GFile *f;
72  * char *uri;
73  * 
74  * file = g_file_new_for_commandline_arg (uri_from_commandline);
75  * 
76  * uri = g_file_get_uri (file);
77  * strcmp (uri, uri_from_commandline) == 0;
78  * g_free (uri);
79  * 
80  * if (g_file_has_uri_scheme (file, "cdda"))
81  * {
82  * // do something special with uri
83  * }
84  * g_object_unref (file);
85  * ]|
86  * 
87  * This code will work when both `cdda://sr0/Track 1.wav` and
88  * `/home/user/.gvfs/cdda on sr0/Track 1.wav` is passed to the
89  * application. It should be noted that it's generally not safe
90  * for applications to rely on the format of a particular URIs.
91  * Different launcher applications (e.g. file managers) may have
92  * different ideas of what a given URI means.
93  */
94 public interface AppInfoIF{
95 	/** Get the main Gtk struct */
96 	public GAppInfo* getAppInfoStruct(bool transferOwnership = false);
97 
98 	/** the main Gtk struct as a void* */
99 	protected void* getStruct();
100 
101 
102 	/**
103 	 * Creates a new #GAppInfo from the given information.
104 	 *
105 	 * Note that for @commandline, the quoting rules of the Exec key of the
106 	 * [freedesktop.org Desktop Entry Specification](http://freedesktop.org/Standards/desktop-entry-spec)
107 	 * are applied. For example, if the @commandline contains
108 	 * percent-encoded URIs, the percent-character must be doubled in order to prevent it from
109 	 * being swallowed by Exec key unquoting. See the specification for exact quoting rules.
110 	 *
111 	 * Params:
112 	 *     commandline = the commandline to use
113 	 *     applicationName = the application name, or %NULL to use @commandline
114 	 *     flags = flags that can specify details of the created #GAppInfo
115 	 *
116 	 * Returns: new #GAppInfo for given command.
117 	 *
118 	 * Throws: GException on failure.
119 	 */
120 	public static AppInfoIF createFromCommandline(string commandline, string applicationName, GAppInfoCreateFlags flags);
121 
122 	/**
123 	 * Gets a list of all of the applications currently registered
124 	 * on this system.
125 	 *
126 	 * For desktop files, this includes applications that have
127 	 * `NoDisplay=true` set or are excluded from display by means
128 	 * of `OnlyShowIn` or `NotShowIn`. See g_app_info_should_show().
129 	 * The returned list does not include applications which have
130 	 * the `Hidden` key set.
131 	 *
132 	 * Returns: a newly allocated #GList of references to #GAppInfos.
133 	 */
134 	public static ListG getAll();
135 
136 	/**
137 	 * Gets a list of all #GAppInfos for a given content type,
138 	 * including the recommended and fallback #GAppInfos. See
139 	 * g_app_info_get_recommended_for_type() and
140 	 * g_app_info_get_fallback_for_type().
141 	 *
142 	 * Params:
143 	 *     contentType = the content type to find a #GAppInfo for
144 	 *
145 	 * Returns: #GList of #GAppInfos
146 	 *     for given @content_type or %NULL on error.
147 	 */
148 	public static ListG getAllForType(string contentType);
149 
150 	/**
151 	 * Gets the default #GAppInfo for a given content type.
152 	 *
153 	 * Params:
154 	 *     contentType = the content type to find a #GAppInfo for
155 	 *     mustSupportUris = if %TRUE, the #GAppInfo is expected to
156 	 *         support URIs
157 	 *
158 	 * Returns: #GAppInfo for given @content_type or
159 	 *     %NULL on error.
160 	 */
161 	public static AppInfoIF getDefaultForType(string contentType, bool mustSupportUris);
162 
163 	/**
164 	 * Gets the default application for handling URIs with
165 	 * the given URI scheme. A URI scheme is the initial part
166 	 * of the URI, up to but not including the ':', e.g. "http",
167 	 * "ftp" or "sip".
168 	 *
169 	 * Params:
170 	 *     uriScheme = a string containing a URI scheme.
171 	 *
172 	 * Returns: #GAppInfo for given @uri_scheme or %NULL on error.
173 	 */
174 	public static AppInfoIF getDefaultForUriScheme(string uriScheme);
175 
176 	/**
177 	 * Gets a list of fallback #GAppInfos for a given content type, i.e.
178 	 * those applications which claim to support the given content type
179 	 * by MIME type subclassing and not directly.
180 	 *
181 	 * Params:
182 	 *     contentType = the content type to find a #GAppInfo for
183 	 *
184 	 * Returns: #GList of #GAppInfos
185 	 *     for given @content_type or %NULL on error.
186 	 *
187 	 * Since: 2.28
188 	 */
189 	public static ListG getFallbackForType(string contentType);
190 
191 	/**
192 	 * Gets a list of recommended #GAppInfos for a given content type, i.e.
193 	 * those applications which claim to support the given content type exactly,
194 	 * and not by MIME type subclassing.
195 	 * Note that the first application of the list is the last used one, i.e.
196 	 * the last one for which g_app_info_set_as_last_used_for_type() has been
197 	 * called.
198 	 *
199 	 * Params:
200 	 *     contentType = the content type to find a #GAppInfo for
201 	 *
202 	 * Returns: #GList of #GAppInfos
203 	 *     for given @content_type or %NULL on error.
204 	 *
205 	 * Since: 2.28
206 	 */
207 	public static ListG getRecommendedForType(string contentType);
208 
209 	/**
210 	 * Utility function that launches the default application
211 	 * registered to handle the specified uri. Synchronous I/O
212 	 * is done on the uri to detect the type of the file if
213 	 * required.
214 	 *
215 	 * Params:
216 	 *     uri = the uri to show
217 	 *     launchContext = an optional #GAppLaunchContext
218 	 *
219 	 * Returns: %TRUE on success, %FALSE on error.
220 	 *
221 	 * Throws: GException on failure.
222 	 */
223 	public static bool launchDefaultForUri(string uri, AppLaunchContext launchContext);
224 
225 	/**
226 	 * Async version of g_app_info_launch_default_for_uri().
227 	 *
228 	 * This version is useful if you are interested in receiving
229 	 * error information in the case where the application is
230 	 * sandboxed and the portal may present an application chooser
231 	 * dialog to the user.
232 	 *
233 	 * Params:
234 	 *     uri = the uri to show
235 	 *     callback = a #GASyncReadyCallback to call when the request is done
236 	 *     userData = data to pass to @callback
237 	 *
238 	 * Since: 2.50
239 	 */
240 	public static void launchDefaultForUriAsync(string uri, AppLaunchContext launchContext, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
241 
242 	/**
243 	 * Finishes an asynchronous launch-default-for-uri operation.
244 	 *
245 	 * Params:
246 	 *     result = a #GAsyncResult
247 	 *
248 	 * Returns: %TRUE if the launch was successful, %FALSE if @error is set
249 	 *
250 	 * Since: 2.50
251 	 *
252 	 * Throws: GException on failure.
253 	 */
254 	public static bool launchDefaultForUriFinish(AsyncResultIF result);
255 
256 	/**
257 	 * Removes all changes to the type associations done by
258 	 * g_app_info_set_as_default_for_type(),
259 	 * g_app_info_set_as_default_for_extension(),
260 	 * g_app_info_add_supports_type() or
261 	 * g_app_info_remove_supports_type().
262 	 *
263 	 * Params:
264 	 *     contentType = a content type
265 	 *
266 	 * Since: 2.20
267 	 */
268 	public static void resetTypeAssociations(string contentType);
269 
270 	/**
271 	 * Adds a content type to the application information to indicate the
272 	 * application is capable of opening files with the given content type.
273 	 *
274 	 * Params:
275 	 *     contentType = a string.
276 	 *
277 	 * Returns: %TRUE on success, %FALSE on error.
278 	 *
279 	 * Throws: GException on failure.
280 	 */
281 	public bool addSupportsType(string contentType);
282 
283 	/**
284 	 * Obtains the information whether the #GAppInfo can be deleted.
285 	 * See g_app_info_delete().
286 	 *
287 	 * Returns: %TRUE if @appinfo can be deleted
288 	 *
289 	 * Since: 2.20
290 	 */
291 	public bool canDelete();
292 
293 	/**
294 	 * Checks if a supported content type can be removed from an application.
295 	 *
296 	 * Returns: %TRUE if it is possible to remove supported
297 	 *     content types from a given @appinfo, %FALSE if not.
298 	 */
299 	public bool canRemoveSupportsType();
300 
301 	/**
302 	 * Tries to delete a #GAppInfo.
303 	 *
304 	 * On some platforms, there may be a difference between user-defined
305 	 * #GAppInfos which can be deleted, and system-wide ones which cannot.
306 	 * See g_app_info_can_delete().
307 	 *
308 	 * Returns: %TRUE if @appinfo has been deleted
309 	 *
310 	 * Since: 2.20
311 	 */
312 	public bool delet();
313 
314 	/**
315 	 * Creates a duplicate of a #GAppInfo.
316 	 *
317 	 * Returns: a duplicate of @appinfo.
318 	 */
319 	public AppInfoIF dup();
320 
321 	/**
322 	 * Checks if two #GAppInfos are equal.
323 	 *
324 	 * Note that the check <em>may not</em> compare each individual field, and
325 	 * only does an identity check. In case detecting changes in the contents
326 	 * is needed, program code must additionally compare relevant fields.
327 	 *
328 	 * Params:
329 	 *     appinfo2 = the second #GAppInfo.
330 	 *
331 	 * Returns: %TRUE if @appinfo1 is equal to @appinfo2. %FALSE otherwise.
332 	 */
333 	public bool equal(AppInfoIF appinfo2);
334 
335 	/**
336 	 * Gets the commandline with which the application will be
337 	 * started.
338 	 *
339 	 * Returns: a string containing the @appinfo's commandline,
340 	 *     or %NULL if this information is not available
341 	 *
342 	 * Since: 2.20
343 	 */
344 	public string getCommandline();
345 
346 	/**
347 	 * Gets a human-readable description of an installed application.
348 	 *
349 	 * Returns: a string containing a description of the
350 	 *     application @appinfo, or %NULL if none.
351 	 */
352 	public string getDescription();
353 
354 	/**
355 	 * Gets the display name of the application. The display name is often more
356 	 * descriptive to the user than the name itself.
357 	 *
358 	 * Returns: the display name of the application for @appinfo, or the name if
359 	 *     no display name is available.
360 	 *
361 	 * Since: 2.24
362 	 */
363 	public string getDisplayName();
364 
365 	/**
366 	 * Gets the executable's name for the installed application.
367 	 *
368 	 * Returns: a string containing the @appinfo's application
369 	 *     binaries name
370 	 */
371 	public string getExecutable();
372 
373 	/**
374 	 * Gets the icon for the application.
375 	 *
376 	 * Returns: the default #GIcon for @appinfo or %NULL
377 	 *     if there is no default icon.
378 	 */
379 	public IconIF getIcon();
380 
381 	/**
382 	 * Gets the ID of an application. An id is a string that
383 	 * identifies the application. The exact format of the id is
384 	 * platform dependent. For instance, on Unix this is the
385 	 * desktop file id from the xdg menu specification.
386 	 *
387 	 * Note that the returned ID may be %NULL, depending on how
388 	 * the @appinfo has been constructed.
389 	 *
390 	 * Returns: a string containing the application's ID.
391 	 */
392 	public string getId();
393 
394 	/**
395 	 * Gets the installed name of the application.
396 	 *
397 	 * Returns: the name of the application for @appinfo.
398 	 */
399 	public string getName();
400 
401 	/**
402 	 * Retrieves the list of content types that @app_info claims to support.
403 	 * If this information is not provided by the environment, this function
404 	 * will return %NULL.
405 	 * This function does not take in consideration associations added with
406 	 * g_app_info_add_supports_type(), but only those exported directly by
407 	 * the application.
408 	 *
409 	 * Returns: a list of content types.
410 	 *
411 	 * Since: 2.34
412 	 */
413 	public string[] getSupportedTypes();
414 
415 	/**
416 	 * Launches the application. Passes @files to the launched application
417 	 * as arguments, using the optional @launch_context to get information
418 	 * about the details of the launcher (like what screen it is on).
419 	 * On error, @error will be set accordingly.
420 	 *
421 	 * To launch the application without arguments pass a %NULL @files list.
422 	 *
423 	 * Note that even if the launch is successful the application launched
424 	 * can fail to start if it runs into problems during startup. There is
425 	 * no way to detect this.
426 	 *
427 	 * Some URIs can be changed when passed through a GFile (for instance
428 	 * unsupported URIs with strange formats like mailto:), so if you have
429 	 * a textual URI you want to pass in as argument, consider using
430 	 * g_app_info_launch_uris() instead.
431 	 *
432 	 * The launched application inherits the environment of the launching
433 	 * process, but it can be modified with g_app_launch_context_setenv()
434 	 * and g_app_launch_context_unsetenv().
435 	 *
436 	 * On UNIX, this function sets the `GIO_LAUNCHED_DESKTOP_FILE`
437 	 * environment variable with the path of the launched desktop file and
438 	 * `GIO_LAUNCHED_DESKTOP_FILE_PID` to the process id of the launched
439 	 * process. This can be used to ignore `GIO_LAUNCHED_DESKTOP_FILE`,
440 	 * should it be inherited by further processes. The `DISPLAY` and
441 	 * `DESKTOP_STARTUP_ID` environment variables are also set, based
442 	 * on information provided in @launch_context.
443 	 *
444 	 * Params:
445 	 *     files = a #GList of #GFile objects
446 	 *     launchContext = a #GAppLaunchContext or %NULL
447 	 *
448 	 * Returns: %TRUE on successful launch, %FALSE otherwise.
449 	 *
450 	 * Throws: GException on failure.
451 	 */
452 	public bool launch(ListG files, AppLaunchContext launchContext);
453 
454 	/**
455 	 * Launches the application. This passes the @uris to the launched application
456 	 * as arguments, using the optional @launch_context to get information
457 	 * about the details of the launcher (like what screen it is on).
458 	 * On error, @error will be set accordingly.
459 	 *
460 	 * To launch the application without arguments pass a %NULL @uris list.
461 	 *
462 	 * Note that even if the launch is successful the application launched
463 	 * can fail to start if it runs into problems during startup. There is
464 	 * no way to detect this.
465 	 *
466 	 * Params:
467 	 *     uris = a #GList containing URIs to launch.
468 	 *     launchContext = a #GAppLaunchContext or %NULL
469 	 *
470 	 * Returns: %TRUE on successful launch, %FALSE otherwise.
471 	 *
472 	 * Throws: GException on failure.
473 	 */
474 	public bool launchUris(ListG uris, AppLaunchContext launchContext);
475 
476 	/**
477 	 * Removes a supported type from an application, if possible.
478 	 *
479 	 * Params:
480 	 *     contentType = a string.
481 	 *
482 	 * Returns: %TRUE on success, %FALSE on error.
483 	 *
484 	 * Throws: GException on failure.
485 	 */
486 	public bool removeSupportsType(string contentType);
487 
488 	/**
489 	 * Sets the application as the default handler for the given file extension.
490 	 *
491 	 * Params:
492 	 *     extension = a string containing the file extension
493 	 *         (without the dot).
494 	 *
495 	 * Returns: %TRUE on success, %FALSE on error.
496 	 *
497 	 * Throws: GException on failure.
498 	 */
499 	public bool setAsDefaultForExtension(string extension);
500 
501 	/**
502 	 * Sets the application as the default handler for a given type.
503 	 *
504 	 * Params:
505 	 *     contentType = the content type.
506 	 *
507 	 * Returns: %TRUE on success, %FALSE on error.
508 	 *
509 	 * Throws: GException on failure.
510 	 */
511 	public bool setAsDefaultForType(string contentType);
512 
513 	/**
514 	 * Sets the application as the last used application for a given type.
515 	 * This will make the application appear as first in the list returned
516 	 * by g_app_info_get_recommended_for_type(), regardless of the default
517 	 * application for that content type.
518 	 *
519 	 * Params:
520 	 *     contentType = the content type.
521 	 *
522 	 * Returns: %TRUE on success, %FALSE on error.
523 	 *
524 	 * Throws: GException on failure.
525 	 */
526 	public bool setAsLastUsedForType(string contentType);
527 
528 	/**
529 	 * Checks if the application info should be shown in menus that
530 	 * list available applications.
531 	 *
532 	 * Returns: %TRUE if the @appinfo should be shown, %FALSE otherwise.
533 	 */
534 	public bool shouldShow();
535 
536 	/**
537 	 * Checks if the application accepts files as arguments.
538 	 *
539 	 * Returns: %TRUE if the @appinfo supports files.
540 	 */
541 	public bool supportsFiles();
542 
543 	/**
544 	 * Checks if the application supports reading files and directories from URIs.
545 	 *
546 	 * Returns: %TRUE if the @appinfo supports URIs.
547 	 */
548 	public bool supportsUris();
549 }