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.AppInfoIF;
28 private import gio.AppLaunchContext;
29 private import gio.AsyncResultIF;
30 private import gio.Cancellable;
31 private import gio.FileIF;
32 private import gio.IconIF;
33 private import gio.c.functions;
34 public  import gio.c.types;
35 private import glib.ErrorG;
36 private import glib.GException;
37 private import glib.ListG;
38 private import glib.Str;
39 private import glib.c.functions;
40 private import gobject.ObjectG;
41 
42 
43 /**
44  * #GAppInfo and #GAppLaunchContext are used for describing and launching
45  * applications installed on the system.
46  * 
47  * As of GLib 2.20, URIs will always be converted to POSIX paths
48  * (using g_file_get_path()) when using g_app_info_launch() even if
49  * the application requested an URI and not a POSIX path. For example
50  * for a desktop-file based application with Exec key `totem
51  * %U` and a single URI, `sftp://foo/file.avi`, then
52  * `/home/user/.gvfs/sftp on foo/file.avi` will be passed. This will
53  * only work if a set of suitable GIO extensions (such as gvfs 2.26
54  * compiled with FUSE support), is available and operational; if this
55  * is not the case, the URI will be passed unmodified to the application.
56  * Some URIs, such as `mailto:`, of course cannot be mapped to a POSIX
57  * path (in gvfs there's no FUSE mount for it); such URIs will be
58  * passed unmodified to the application.
59  * 
60  * Specifically for gvfs 2.26 and later, the POSIX URI will be mapped
61  * back to the GIO URI in the #GFile constructors (since gvfs
62  * implements the #GVfs extension point). As such, if the application
63  * needs to examine the URI, it needs to use g_file_get_uri() or
64  * similar on #GFile. In other words, an application cannot assume
65  * that the URI passed to e.g. g_file_new_for_commandline_arg() is
66  * equal to the result of g_file_get_uri(). The following snippet
67  * illustrates this:
68  * 
69  * |[
70  * GFile *f;
71  * char *uri;
72  * 
73  * file = g_file_new_for_commandline_arg (uri_from_commandline);
74  * 
75  * uri = g_file_get_uri (file);
76  * strcmp (uri, uri_from_commandline) == 0;
77  * g_free (uri);
78  * 
79  * if (g_file_has_uri_scheme (file, "cdda"))
80  * {
81  * // do something special with uri
82  * }
83  * g_object_unref (file);
84  * ]|
85  * 
86  * This code will work when both `cdda://sr0/Track 1.wav` and
87  * `/home/user/.gvfs/cdda on sr0/Track 1.wav` is passed to the
88  * application. It should be noted that it's generally not safe
89  * for applications to rely on the format of a particular URIs.
90  * Different launcher applications (e.g. file managers) may have
91  * different ideas of what a given URI means.
92  */
93 public interface AppInfoIF{
94 	/** Get the main Gtk struct */
95 	public GAppInfo* getAppInfoStruct(bool transferOwnership = false);
96 
97 	/** the main Gtk struct as a void* */
98 	protected void* getStruct();
99 
100 
101 	/** */
102 	public static GType getType()
103 	{
104 		return g_app_info_get_type();
105 	}
106 
107 	/**
108 	 * Creates a new #GAppInfo from the given information.
109 	 *
110 	 * Note that for @commandline, the quoting rules of the Exec key of the
111 	 * [freedesktop.org Desktop Entry Specification](http://freedesktop.org/Standards/desktop-entry-spec)
112 	 * are applied. For example, if the @commandline contains
113 	 * percent-encoded URIs, the percent-character must be doubled in order to prevent it from
114 	 * being swallowed by Exec key unquoting. See the specification for exact quoting rules.
115 	 *
116 	 * Params:
117 	 *     commandline = the commandline to use
118 	 *     applicationName = the application name, or %NULL to use @commandline
119 	 *     flags = flags that can specify details of the created #GAppInfo
120 	 *
121 	 * Returns: new #GAppInfo for given command.
122 	 *
123 	 * Throws: GException on failure.
124 	 */
125 	public static AppInfoIF createFromCommandline(string commandline, string applicationName, GAppInfoCreateFlags flags)
126 	{
127 		GError* err = null;
128 
129 		auto __p = g_app_info_create_from_commandline(Str.toStringz(commandline), Str.toStringz(applicationName), flags, &err);
130 
131 		if (err !is null)
132 		{
133 			throw new GException( new ErrorG(err) );
134 		}
135 
136 		if(__p is null)
137 		{
138 			return null;
139 		}
140 
141 		return ObjectG.getDObject!(AppInfoIF)(cast(GAppInfo*) __p, true);
142 	}
143 
144 	/**
145 	 * Gets a list of all of the applications currently registered
146 	 * on this system.
147 	 *
148 	 * For desktop files, this includes applications that have
149 	 * `NoDisplay=true` set or are excluded from display by means
150 	 * of `OnlyShowIn` or `NotShowIn`. See g_app_info_should_show().
151 	 * The returned list does not include applications which have
152 	 * the `Hidden` key set.
153 	 *
154 	 * Returns: a newly allocated #GList of references to #GAppInfos.
155 	 */
156 	public static ListG getAll()
157 	{
158 		auto __p = g_app_info_get_all();
159 
160 		if(__p is null)
161 		{
162 			return null;
163 		}
164 
165 		return new ListG(cast(GList*) __p, true);
166 	}
167 
168 	/**
169 	 * Gets a list of all #GAppInfos for a given content type,
170 	 * including the recommended and fallback #GAppInfos. See
171 	 * g_app_info_get_recommended_for_type() and
172 	 * g_app_info_get_fallback_for_type().
173 	 *
174 	 * Params:
175 	 *     contentType = the content type to find a #GAppInfo for
176 	 *
177 	 * Returns: #GList of #GAppInfos
178 	 *     for given @content_type or %NULL on error.
179 	 */
180 	public static ListG getAllForType(string contentType)
181 	{
182 		auto __p = g_app_info_get_all_for_type(Str.toStringz(contentType));
183 
184 		if(__p is null)
185 		{
186 			return null;
187 		}
188 
189 		return new ListG(cast(GList*) __p, true);
190 	}
191 
192 	/**
193 	 * Gets the default #GAppInfo for a given content type.
194 	 *
195 	 * Params:
196 	 *     contentType = the content type to find a #GAppInfo for
197 	 *     mustSupportUris = if %TRUE, the #GAppInfo is expected to
198 	 *         support URIs
199 	 *
200 	 * Returns: #GAppInfo for given @content_type or
201 	 *     %NULL on error.
202 	 */
203 	public static AppInfoIF getDefaultForType(string contentType, bool mustSupportUris)
204 	{
205 		auto __p = g_app_info_get_default_for_type(Str.toStringz(contentType), mustSupportUris);
206 
207 		if(__p is null)
208 		{
209 			return null;
210 		}
211 
212 		return ObjectG.getDObject!(AppInfoIF)(cast(GAppInfo*) __p, true);
213 	}
214 
215 	/**
216 	 * Gets the default application for handling URIs with
217 	 * the given URI scheme. A URI scheme is the initial part
218 	 * of the URI, up to but not including the ':', e.g. "http",
219 	 * "ftp" or "sip".
220 	 *
221 	 * Params:
222 	 *     uriScheme = a string containing a URI scheme.
223 	 *
224 	 * Returns: #GAppInfo for given @uri_scheme or
225 	 *     %NULL on error.
226 	 */
227 	public static AppInfoIF getDefaultForUriScheme(string uriScheme)
228 	{
229 		auto __p = g_app_info_get_default_for_uri_scheme(Str.toStringz(uriScheme));
230 
231 		if(__p is null)
232 		{
233 			return null;
234 		}
235 
236 		return ObjectG.getDObject!(AppInfoIF)(cast(GAppInfo*) __p, true);
237 	}
238 
239 	/**
240 	 * Gets a list of fallback #GAppInfos for a given content type, i.e.
241 	 * those applications which claim to support the given content type
242 	 * by MIME type subclassing and not directly.
243 	 *
244 	 * Params:
245 	 *     contentType = the content type to find a #GAppInfo for
246 	 *
247 	 * Returns: #GList of #GAppInfos
248 	 *     for given @content_type or %NULL on error.
249 	 *
250 	 * Since: 2.28
251 	 */
252 	public static ListG getFallbackForType(string contentType)
253 	{
254 		auto __p = g_app_info_get_fallback_for_type(Str.toStringz(contentType));
255 
256 		if(__p is null)
257 		{
258 			return null;
259 		}
260 
261 		return new ListG(cast(GList*) __p, true);
262 	}
263 
264 	/**
265 	 * Gets a list of recommended #GAppInfos for a given content type, i.e.
266 	 * those applications which claim to support the given content type exactly,
267 	 * and not by MIME type subclassing.
268 	 * Note that the first application of the list is the last used one, i.e.
269 	 * the last one for which g_app_info_set_as_last_used_for_type() has been
270 	 * called.
271 	 *
272 	 * Params:
273 	 *     contentType = the content type to find a #GAppInfo for
274 	 *
275 	 * Returns: #GList of #GAppInfos
276 	 *     for given @content_type or %NULL on error.
277 	 *
278 	 * Since: 2.28
279 	 */
280 	public static ListG getRecommendedForType(string contentType)
281 	{
282 		auto __p = g_app_info_get_recommended_for_type(Str.toStringz(contentType));
283 
284 		if(__p is null)
285 		{
286 			return null;
287 		}
288 
289 		return new ListG(cast(GList*) __p, true);
290 	}
291 
292 	/**
293 	 * Utility function that launches the default application
294 	 * registered to handle the specified uri. Synchronous I/O
295 	 * is done on the uri to detect the type of the file if
296 	 * required.
297 	 *
298 	 * The D-Bus–activated applications don't have to be started if your application
299 	 * terminates too soon after this function. To prevent this, use
300 	 * g_app_info_launch_default_for_uri_async() instead.
301 	 *
302 	 * Params:
303 	 *     uri = the uri to show
304 	 *     context = an optional #GAppLaunchContext
305 	 *
306 	 * Returns: %TRUE on success, %FALSE on error.
307 	 *
308 	 * Throws: GException on failure.
309 	 */
310 	public static bool launchDefaultForUri(string uri, AppLaunchContext context)
311 	{
312 		GError* err = null;
313 
314 		auto __p = g_app_info_launch_default_for_uri(Str.toStringz(uri), (context is null) ? null : context.getAppLaunchContextStruct(), &err) != 0;
315 
316 		if (err !is null)
317 		{
318 			throw new GException( new ErrorG(err) );
319 		}
320 
321 		return __p;
322 	}
323 
324 	/**
325 	 * Async version of g_app_info_launch_default_for_uri().
326 	 *
327 	 * This version is useful if you are interested in receiving
328 	 * error information in the case where the application is
329 	 * sandboxed and the portal may present an application chooser
330 	 * dialog to the user.
331 	 *
332 	 * This is also useful if you want to be sure that the D-Bus–activated
333 	 * applications are really started before termination and if you are interested
334 	 * in receiving error information from their activation.
335 	 *
336 	 * Params:
337 	 *     uri = the uri to show
338 	 *     context = an optional #GAppLaunchContext
339 	 *     cancellable = a #GCancellable
340 	 *     callback = a #GAsyncReadyCallback to call when the request is done
341 	 *     userData = data to pass to @callback
342 	 *
343 	 * Since: 2.50
344 	 */
345 	public static void launchDefaultForUriAsync(string uri, AppLaunchContext context, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
346 	{
347 		g_app_info_launch_default_for_uri_async(Str.toStringz(uri), (context is null) ? null : context.getAppLaunchContextStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
348 	}
349 
350 	/**
351 	 * Finishes an asynchronous launch-default-for-uri operation.
352 	 *
353 	 * Params:
354 	 *     result = a #GAsyncResult
355 	 *
356 	 * Returns: %TRUE if the launch was successful, %FALSE if @error is set
357 	 *
358 	 * Since: 2.50
359 	 *
360 	 * Throws: GException on failure.
361 	 */
362 	public static bool launchDefaultForUriFinish(AsyncResultIF result)
363 	{
364 		GError* err = null;
365 
366 		auto __p = g_app_info_launch_default_for_uri_finish((result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
367 
368 		if (err !is null)
369 		{
370 			throw new GException( new ErrorG(err) );
371 		}
372 
373 		return __p;
374 	}
375 
376 	/**
377 	 * Removes all changes to the type associations done by
378 	 * g_app_info_set_as_default_for_type(),
379 	 * g_app_info_set_as_default_for_extension(),
380 	 * g_app_info_add_supports_type() or
381 	 * g_app_info_remove_supports_type().
382 	 *
383 	 * Params:
384 	 *     contentType = a content type
385 	 *
386 	 * Since: 2.20
387 	 */
388 	public static void resetTypeAssociations(string contentType)
389 	{
390 		g_app_info_reset_type_associations(Str.toStringz(contentType));
391 	}
392 
393 	/**
394 	 * Adds a content type to the application information to indicate the
395 	 * application is capable of opening files with the given content type.
396 	 *
397 	 * Params:
398 	 *     contentType = a string.
399 	 *
400 	 * Returns: %TRUE on success, %FALSE on error.
401 	 *
402 	 * Throws: GException on failure.
403 	 */
404 	public bool addSupportsType(string contentType);
405 
406 	/**
407 	 * Obtains the information whether the #GAppInfo can be deleted.
408 	 * See g_app_info_delete().
409 	 *
410 	 * Returns: %TRUE if @appinfo can be deleted
411 	 *
412 	 * Since: 2.20
413 	 */
414 	public bool canDelete();
415 
416 	/**
417 	 * Checks if a supported content type can be removed from an application.
418 	 *
419 	 * Returns: %TRUE if it is possible to remove supported
420 	 *     content types from a given @appinfo, %FALSE if not.
421 	 */
422 	public bool canRemoveSupportsType();
423 
424 	alias delet = delete_;
425 	/**
426 	 * Tries to delete a #GAppInfo.
427 	 *
428 	 * On some platforms, there may be a difference between user-defined
429 	 * #GAppInfos which can be deleted, and system-wide ones which cannot.
430 	 * See g_app_info_can_delete().
431 	 *
432 	 * Returns: %TRUE if @appinfo has been deleted
433 	 *
434 	 * Since: 2.20
435 	 */
436 	public bool delete_();
437 
438 	/**
439 	 * Creates a duplicate of a #GAppInfo.
440 	 *
441 	 * Returns: a duplicate of @appinfo.
442 	 */
443 	public AppInfoIF dup();
444 
445 	/**
446 	 * Checks if two #GAppInfos are equal.
447 	 *
448 	 * Note that the check *may not* compare each individual
449 	 * field, and only does an identity check. In case detecting changes in the
450 	 * contents is needed, program code must additionally compare relevant fields.
451 	 *
452 	 * Params:
453 	 *     appinfo2 = the second #GAppInfo.
454 	 *
455 	 * Returns: %TRUE if @appinfo1 is equal to @appinfo2. %FALSE otherwise.
456 	 */
457 	public bool equal(AppInfoIF appinfo2);
458 
459 	/**
460 	 * Gets the commandline with which the application will be
461 	 * started.
462 	 *
463 	 * Returns: a string containing the @appinfo's commandline,
464 	 *     or %NULL if this information is not available
465 	 *
466 	 * Since: 2.20
467 	 */
468 	public string getCommandline();
469 
470 	/**
471 	 * Gets a human-readable description of an installed application.
472 	 *
473 	 * Returns: a string containing a description of the
474 	 *     application @appinfo, or %NULL if none.
475 	 */
476 	public string getDescription();
477 
478 	/**
479 	 * Gets the display name of the application. The display name is often more
480 	 * descriptive to the user than the name itself.
481 	 *
482 	 * Returns: the display name of the application for @appinfo, or the name if
483 	 *     no display name is available.
484 	 *
485 	 * Since: 2.24
486 	 */
487 	public string getDisplayName();
488 
489 	/**
490 	 * Gets the executable's name for the installed application.
491 	 *
492 	 * Returns: a string containing the @appinfo's application
493 	 *     binaries name
494 	 */
495 	public string getExecutable();
496 
497 	/**
498 	 * Gets the icon for the application.
499 	 *
500 	 * Returns: the default #GIcon for @appinfo or %NULL
501 	 *     if there is no default icon.
502 	 */
503 	public IconIF getIcon();
504 
505 	/**
506 	 * Gets the ID of an application. An id is a string that
507 	 * identifies the application. The exact format of the id is
508 	 * platform dependent. For instance, on Unix this is the
509 	 * desktop file id from the xdg menu specification.
510 	 *
511 	 * Note that the returned ID may be %NULL, depending on how
512 	 * the @appinfo has been constructed.
513 	 *
514 	 * Returns: a string containing the application's ID.
515 	 */
516 	public string getId();
517 
518 	/**
519 	 * Gets the installed name of the application.
520 	 *
521 	 * Returns: the name of the application for @appinfo.
522 	 */
523 	public string getName();
524 
525 	/**
526 	 * Retrieves the list of content types that @app_info claims to support.
527 	 * If this information is not provided by the environment, this function
528 	 * will return %NULL.
529 	 * This function does not take in consideration associations added with
530 	 * g_app_info_add_supports_type(), but only those exported directly by
531 	 * the application.
532 	 *
533 	 * Returns: a list of content types.
534 	 *
535 	 * Since: 2.34
536 	 */
537 	public string[] getSupportedTypes();
538 
539 	/**
540 	 * Launches the application. Passes @files to the launched application
541 	 * as arguments, using the optional @context to get information
542 	 * about the details of the launcher (like what screen it is on).
543 	 * On error, @error will be set accordingly.
544 	 *
545 	 * To launch the application without arguments pass a %NULL @files list.
546 	 *
547 	 * Note that even if the launch is successful the application launched
548 	 * can fail to start if it runs into problems during startup. There is
549 	 * no way to detect this.
550 	 *
551 	 * Some URIs can be changed when passed through a GFile (for instance
552 	 * unsupported URIs with strange formats like mailto:), so if you have
553 	 * a textual URI you want to pass in as argument, consider using
554 	 * g_app_info_launch_uris() instead.
555 	 *
556 	 * The launched application inherits the environment of the launching
557 	 * process, but it can be modified with g_app_launch_context_setenv()
558 	 * and g_app_launch_context_unsetenv().
559 	 *
560 	 * On UNIX, this function sets the `GIO_LAUNCHED_DESKTOP_FILE`
561 	 * environment variable with the path of the launched desktop file and
562 	 * `GIO_LAUNCHED_DESKTOP_FILE_PID` to the process id of the launched
563 	 * process. This can be used to ignore `GIO_LAUNCHED_DESKTOP_FILE`,
564 	 * should it be inherited by further processes. The `DISPLAY` and
565 	 * `DESKTOP_STARTUP_ID` environment variables are also set, based
566 	 * on information provided in @context.
567 	 *
568 	 * Params:
569 	 *     files = a #GList of #GFile objects
570 	 *     context = a #GAppLaunchContext or %NULL
571 	 *
572 	 * Returns: %TRUE on successful launch, %FALSE otherwise.
573 	 *
574 	 * Throws: GException on failure.
575 	 */
576 	public bool launch(ListG files, AppLaunchContext context);
577 
578 	/**
579 	 * Launches the application. This passes the @uris to the launched application
580 	 * as arguments, using the optional @context to get information
581 	 * about the details of the launcher (like what screen it is on).
582 	 * On error, @error will be set accordingly.
583 	 *
584 	 * To launch the application without arguments pass a %NULL @uris list.
585 	 *
586 	 * Note that even if the launch is successful the application launched
587 	 * can fail to start if it runs into problems during startup. There is
588 	 * no way to detect this.
589 	 *
590 	 * Params:
591 	 *     uris = a #GList containing URIs to launch.
592 	 *     context = a #GAppLaunchContext or %NULL
593 	 *
594 	 * Returns: %TRUE on successful launch, %FALSE otherwise.
595 	 *
596 	 * Throws: GException on failure.
597 	 */
598 	public bool launchUris(ListG uris, AppLaunchContext context);
599 
600 	/**
601 	 * Async version of g_app_info_launch_uris().
602 	 *
603 	 * The @callback is invoked immediately after the application launch, but it
604 	 * waits for activation in case of D-Bus–activated applications and also provides
605 	 * extended error information for sandboxed applications, see notes for
606 	 * g_app_info_launch_default_for_uri_async().
607 	 *
608 	 * Params:
609 	 *     uris = a #GList containing URIs to launch.
610 	 *     context = a #GAppLaunchContext or %NULL
611 	 *     cancellable = a #GCancellable
612 	 *     callback = a #GAsyncReadyCallback to call when the request is done
613 	 *     userData = data to pass to @callback
614 	 *
615 	 * Since: 2.60
616 	 */
617 	public void launchUrisAsync(ListG uris, AppLaunchContext context, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
618 
619 	/**
620 	 * Finishes a g_app_info_launch_uris_async() operation.
621 	 *
622 	 * Params:
623 	 *     result = a #GAsyncResult
624 	 *
625 	 * Returns: %TRUE on successful launch, %FALSE otherwise.
626 	 *
627 	 * Since: 2.60
628 	 *
629 	 * Throws: GException on failure.
630 	 */
631 	public bool launchUrisFinish(AsyncResultIF result);
632 
633 	/**
634 	 * Removes a supported type from an application, if possible.
635 	 *
636 	 * Params:
637 	 *     contentType = a string.
638 	 *
639 	 * Returns: %TRUE on success, %FALSE on error.
640 	 *
641 	 * Throws: GException on failure.
642 	 */
643 	public bool removeSupportsType(string contentType);
644 
645 	/**
646 	 * Sets the application as the default handler for the given file extension.
647 	 *
648 	 * Params:
649 	 *     extension = a string containing the file extension
650 	 *         (without the dot).
651 	 *
652 	 * Returns: %TRUE on success, %FALSE on error.
653 	 *
654 	 * Throws: GException on failure.
655 	 */
656 	public bool setAsDefaultForExtension(string extension);
657 
658 	/**
659 	 * Sets the application as the default handler for a given type.
660 	 *
661 	 * Params:
662 	 *     contentType = the content type.
663 	 *
664 	 * Returns: %TRUE on success, %FALSE on error.
665 	 *
666 	 * Throws: GException on failure.
667 	 */
668 	public bool setAsDefaultForType(string contentType);
669 
670 	/**
671 	 * Sets the application as the last used application for a given type.
672 	 * This will make the application appear as first in the list returned
673 	 * by g_app_info_get_recommended_for_type(), regardless of the default
674 	 * application for that content type.
675 	 *
676 	 * Params:
677 	 *     contentType = the content type.
678 	 *
679 	 * Returns: %TRUE on success, %FALSE on error.
680 	 *
681 	 * Throws: GException on failure.
682 	 */
683 	public bool setAsLastUsedForType(string contentType);
684 
685 	/**
686 	 * Checks if the application info should be shown in menus that
687 	 * list available applications.
688 	 *
689 	 * Returns: %TRUE if the @appinfo should be shown, %FALSE otherwise.
690 	 */
691 	public bool shouldShow();
692 
693 	/**
694 	 * Checks if the application accepts files as arguments.
695 	 *
696 	 * Returns: %TRUE if the @appinfo supports files.
697 	 */
698 	public bool supportsFiles();
699 
700 	/**
701 	 * Checks if the application supports reading files and directories from URIs.
702 	 *
703 	 * Returns: %TRUE if the @appinfo supports URIs.
704 	 */
705 	public bool supportsUris();
706 }