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 gobject.ObjectG;
40 public  import gtkc.giotypes;
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 an 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 	/**
128 	 * Gets a list of all of the applications currently registered
129 	 * on this system.
130 	 *
131 	 * For desktop files, this includes applications that have
132 	 * `NoDisplay=true` set or are excluded from display by means
133 	 * of `OnlyShowIn` or `NotShowIn`. See g_app_info_should_show().
134 	 * The returned list does not include applications which have
135 	 * the `Hidden` key set.
136 	 *
137 	 * Returns: a newly allocated #GList of references to #GAppInfos.
138 	 */
139 	public static ListG getAll();
140 
141 	/**
142 	 * Gets a list of all #GAppInfos for a given content type,
143 	 * including the recommended and fallback #GAppInfos. See
144 	 * g_app_info_get_recommended_for_type() and
145 	 * g_app_info_get_fallback_for_type().
146 	 *
147 	 * Params:
148 	 *     contentType = the content type to find a #GAppInfo for
149 	 *
150 	 * Returns: #GList of #GAppInfos
151 	 *     for given @content_type or %NULL on error.
152 	 */
153 	public static ListG getAllForType(string contentType);
154 
155 	/**
156 	 * Gets the default #GAppInfo for a given content type.
157 	 *
158 	 * Params:
159 	 *     contentType = the content type to find a #GAppInfo for
160 	 *     mustSupportUris = if %TRUE, the #GAppInfo is expected to
161 	 *         support URIs
162 	 *
163 	 * Returns: #GAppInfo for given @content_type or
164 	 *     %NULL on error.
165 	 */
166 	public static AppInfoIF getDefaultForType(string contentType, bool mustSupportUris);
167 
168 	/**
169 	 * Gets the default application for handling URIs with
170 	 * the given URI scheme. A URI scheme is the initial part
171 	 * of the URI, up to but not including the ':', e.g. "http",
172 	 * "ftp" or "sip".
173 	 *
174 	 * Params:
175 	 *     uriScheme = a string containing a URI scheme.
176 	 *
177 	 * Returns: #GAppInfo for given @uri_scheme or %NULL on error.
178 	 */
179 	public static AppInfoIF getDefaultForUriScheme(string uriScheme);
180 
181 	/**
182 	 * Gets a list of fallback #GAppInfos for a given content type, i.e.
183 	 * those applications which claim to support the given content type
184 	 * by MIME type subclassing and not directly.
185 	 *
186 	 * Params:
187 	 *     contentType = the content type to find a #GAppInfo for
188 	 *
189 	 * Returns: #GList of #GAppInfos
190 	 *     for given @content_type or %NULL on error.
191 	 *
192 	 * Since: 2.28
193 	 */
194 	public static ListG getFallbackForType(string contentType);
195 
196 	/**
197 	 * Gets a list of recommended #GAppInfos for a given content type, i.e.
198 	 * those applications which claim to support the given content type exactly,
199 	 * and not by MIME type subclassing.
200 	 * Note that the first application of the list is the last used one, i.e.
201 	 * the last one for which g_app_info_set_as_last_used_for_type() has been
202 	 * called.
203 	 *
204 	 * Params:
205 	 *     contentType = the content type to find a #GAppInfo for
206 	 *
207 	 * Returns: #GList of #GAppInfos
208 	 *     for given @content_type or %NULL on error.
209 	 *
210 	 * Since: 2.28
211 	 */
212 	public static ListG getRecommendedForType(string contentType);
213 
214 	/**
215 	 * Utility function that launches the default application
216 	 * registered to handle the specified uri. Synchronous I/O
217 	 * is done on the uri to detect the type of the file if
218 	 * required.
219 	 *
220 	 * Params:
221 	 *     uri = the uri to show
222 	 *     launchContext = an optional #GAppLaunchContext
223 	 *
224 	 * Returns: %TRUE on success, %FALSE on error.
225 	 *
226 	 * Throws: GException on failure.
227 	 */
228 	public static bool launchDefaultForUri(string uri, AppLaunchContext launchContext);
229 
230 	/**
231 	 * Async version of g_app_info_launch_default_for_uri().
232 	 *
233 	 * This version is useful if you are interested in receiving
234 	 * error information in the case where the application is
235 	 * sandboxed and the portal may present an application chooser
236 	 * dialog to the user.
237 	 *
238 	 * Params:
239 	 *     uri = the uri to show
240 	 *     callback = a #GASyncReadyCallback to call when the request is done
241 	 *     userData = data to pass to @callback
242 	 *
243 	 * Since: 2.50
244 	 */
245 	public static void launchDefaultForUriAsync(string uri, AppLaunchContext launchContext, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
246 
247 	/**
248 	 * Finishes an asynchronous launch-default-for-uri operation.
249 	 *
250 	 * Params:
251 	 *     result = a #GAsyncResult
252 	 *
253 	 * Returns: %TRUE if the launch was successful, %FALSE if @error is set
254 	 *
255 	 * Since: 2.50
256 	 *
257 	 * Throws: GException on failure.
258 	 */
259 	public static bool launchDefaultForUriFinish(AsyncResultIF result);
260 
261 	/**
262 	 * Removes all changes to the type associations done by
263 	 * g_app_info_set_as_default_for_type(),
264 	 * g_app_info_set_as_default_for_extension(),
265 	 * g_app_info_add_supports_type() or
266 	 * g_app_info_remove_supports_type().
267 	 *
268 	 * Params:
269 	 *     contentType = a content type
270 	 *
271 	 * Since: 2.20
272 	 */
273 	public static void resetTypeAssociations(string contentType);
274 
275 	/**
276 	 * Adds a content type to the application information to indicate the
277 	 * application is capable of opening files with the given content type.
278 	 *
279 	 * Params:
280 	 *     contentType = a string.
281 	 *
282 	 * Returns: %TRUE on success, %FALSE on error.
283 	 *
284 	 * Throws: GException on failure.
285 	 */
286 	public bool addSupportsType(string contentType);
287 
288 	/**
289 	 * Obtains the information whether the #GAppInfo can be deleted.
290 	 * See g_app_info_delete().
291 	 *
292 	 * Returns: %TRUE if @appinfo can be deleted
293 	 *
294 	 * Since: 2.20
295 	 */
296 	public bool canDelete();
297 
298 	/**
299 	 * Checks if a supported content type can be removed from an application.
300 	 *
301 	 * Returns: %TRUE if it is possible to remove supported
302 	 *     content types from a given @appinfo, %FALSE if not.
303 	 */
304 	public bool canRemoveSupportsType();
305 
306 	/**
307 	 * Tries to delete a #GAppInfo.
308 	 *
309 	 * On some platforms, there may be a difference between user-defined
310 	 * #GAppInfos which can be deleted, and system-wide ones which cannot.
311 	 * See g_app_info_can_delete().
312 	 *
313 	 * Returns: %TRUE if @appinfo has been deleted
314 	 *
315 	 * Since: 2.20
316 	 */
317 	public bool delet();
318 
319 	/**
320 	 * Creates a duplicate of a #GAppInfo.
321 	 *
322 	 * Returns: a duplicate of @appinfo.
323 	 */
324 	public AppInfoIF dup();
325 
326 	/**
327 	 * Checks if two #GAppInfos are equal.
328 	 *
329 	 * Note that the check <em>may not</em> compare each individual field, and
330 	 * only does an identity check. In case detecting changes in the contents
331 	 * is needed, program code must additionally compare relevant fields.
332 	 *
333 	 * Params:
334 	 *     appinfo2 = the second #GAppInfo.
335 	 *
336 	 * Returns: %TRUE if @appinfo1 is equal to @appinfo2. %FALSE otherwise.
337 	 */
338 	public bool equal(AppInfoIF appinfo2);
339 
340 	/**
341 	 * Gets the commandline with which the application will be
342 	 * started.
343 	 *
344 	 * Returns: a string containing the @appinfo's commandline,
345 	 *     or %NULL if this information is not available
346 	 *
347 	 * Since: 2.20
348 	 */
349 	public string getCommandline();
350 
351 	/**
352 	 * Gets a human-readable description of an installed application.
353 	 *
354 	 * Returns: a string containing a description of the
355 	 *     application @appinfo, or %NULL if none.
356 	 */
357 	public string getDescription();
358 
359 	/**
360 	 * Gets the display name of the application. The display name is often more
361 	 * descriptive to the user than the name itself.
362 	 *
363 	 * Returns: the display name of the application for @appinfo, or the name if
364 	 *     no display name is available.
365 	 *
366 	 * Since: 2.24
367 	 */
368 	public string getDisplayName();
369 
370 	/**
371 	 * Gets the executable's name for the installed application.
372 	 *
373 	 * Returns: a string containing the @appinfo's application
374 	 *     binaries name
375 	 */
376 	public string getExecutable();
377 
378 	/**
379 	 * Gets the icon for the application.
380 	 *
381 	 * Returns: the default #GIcon for @appinfo or %NULL
382 	 *     if there is no default icon.
383 	 */
384 	public IconIF getIcon();
385 
386 	/**
387 	 * Gets the ID of an application. An id is a string that
388 	 * identifies the application. The exact format of the id is
389 	 * platform dependent. For instance, on Unix this is the
390 	 * desktop file id from the xdg menu specification.
391 	 *
392 	 * Note that the returned ID may be %NULL, depending on how
393 	 * the @appinfo has been constructed.
394 	 *
395 	 * Returns: a string containing the application's ID.
396 	 */
397 	public string getId();
398 
399 	/**
400 	 * Gets the installed name of the application.
401 	 *
402 	 * Returns: the name of the application for @appinfo.
403 	 */
404 	public string getName();
405 
406 	/**
407 	 * Retrieves the list of content types that @app_info claims to support.
408 	 * If this information is not provided by the environment, this function
409 	 * will return %NULL.
410 	 * This function does not take in consideration associations added with
411 	 * g_app_info_add_supports_type(), but only those exported directly by
412 	 * the application.
413 	 *
414 	 * Returns: a list of content types.
415 	 *
416 	 * Since: 2.34
417 	 */
418 	public string[] getSupportedTypes();
419 
420 	/**
421 	 * Launches the application. Passes @files to the launched application
422 	 * as arguments, using the optional @launch_context to get information
423 	 * about the details of the launcher (like what screen it is on).
424 	 * On error, @error will be set accordingly.
425 	 *
426 	 * To launch the application without arguments pass a %NULL @files list.
427 	 *
428 	 * Note that even if the launch is successful the application launched
429 	 * can fail to start if it runs into problems during startup. There is
430 	 * no way to detect this.
431 	 *
432 	 * Some URIs can be changed when passed through a GFile (for instance
433 	 * unsupported URIs with strange formats like mailto:), so if you have
434 	 * a textual URI you want to pass in as argument, consider using
435 	 * g_app_info_launch_uris() instead.
436 	 *
437 	 * The launched application inherits the environment of the launching
438 	 * process, but it can be modified with g_app_launch_context_setenv()
439 	 * and g_app_launch_context_unsetenv().
440 	 *
441 	 * On UNIX, this function sets the `GIO_LAUNCHED_DESKTOP_FILE`
442 	 * environment variable with the path of the launched desktop file and
443 	 * `GIO_LAUNCHED_DESKTOP_FILE_PID` to the process id of the launched
444 	 * process. This can be used to ignore `GIO_LAUNCHED_DESKTOP_FILE`,
445 	 * should it be inherited by further processes. The `DISPLAY` and
446 	 * `DESKTOP_STARTUP_ID` environment variables are also set, based
447 	 * on information provided in @launch_context.
448 	 *
449 	 * Params:
450 	 *     files = a #GList of #GFile objects
451 	 *     launchContext = a #GAppLaunchContext or %NULL
452 	 *
453 	 * Returns: %TRUE on successful launch, %FALSE otherwise.
454 	 *
455 	 * Throws: GException on failure.
456 	 */
457 	public bool launch(ListG files, AppLaunchContext launchContext);
458 
459 	/**
460 	 * Launches the application. This passes the @uris to the launched application
461 	 * as arguments, using the optional @launch_context to get information
462 	 * about the details of the launcher (like what screen it is on).
463 	 * On error, @error will be set accordingly.
464 	 *
465 	 * To launch the application without arguments pass a %NULL @uris list.
466 	 *
467 	 * Note that even if the launch is successful the application launched
468 	 * can fail to start if it runs into problems during startup. There is
469 	 * no way to detect this.
470 	 *
471 	 * Params:
472 	 *     uris = a #GList containing URIs to launch.
473 	 *     launchContext = a #GAppLaunchContext or %NULL
474 	 *
475 	 * Returns: %TRUE on successful launch, %FALSE otherwise.
476 	 *
477 	 * Throws: GException on failure.
478 	 */
479 	public bool launchUris(ListG uris, AppLaunchContext launchContext);
480 
481 	/**
482 	 * Removes a supported type from an application, if possible.
483 	 *
484 	 * Params:
485 	 *     contentType = a string.
486 	 *
487 	 * Returns: %TRUE on success, %FALSE on error.
488 	 *
489 	 * Throws: GException on failure.
490 	 */
491 	public bool removeSupportsType(string contentType);
492 
493 	/**
494 	 * Sets the application as the default handler for the given file extension.
495 	 *
496 	 * Params:
497 	 *     extension = a string containing the file extension
498 	 *         (without the dot).
499 	 *
500 	 * Returns: %TRUE on success, %FALSE on error.
501 	 *
502 	 * Throws: GException on failure.
503 	 */
504 	public bool setAsDefaultForExtension(string extension);
505 
506 	/**
507 	 * Sets the application as the default handler for a given type.
508 	 *
509 	 * Params:
510 	 *     contentType = the content type.
511 	 *
512 	 * Returns: %TRUE on success, %FALSE on error.
513 	 *
514 	 * Throws: GException on failure.
515 	 */
516 	public bool setAsDefaultForType(string contentType);
517 
518 	/**
519 	 * Sets the application as the last used application for a given type.
520 	 * This will make the application appear as first in the list returned
521 	 * by g_app_info_get_recommended_for_type(), regardless of the default
522 	 * application for that content type.
523 	 *
524 	 * Params:
525 	 *     contentType = the content type.
526 	 *
527 	 * Returns: %TRUE on success, %FALSE on error.
528 	 *
529 	 * Throws: GException on failure.
530 	 */
531 	public bool setAsLastUsedForType(string contentType);
532 
533 	/**
534 	 * Checks if the application info should be shown in menus that
535 	 * list available applications.
536 	 *
537 	 * Returns: %TRUE if the @appinfo should be shown, %FALSE otherwise.
538 	 */
539 	public bool shouldShow();
540 
541 	/**
542 	 * Checks if the application accepts files as arguments.
543 	 *
544 	 * Returns: %TRUE if the @appinfo supports files.
545 	 */
546 	public bool supportsFiles();
547 
548 	/**
549 	 * Checks if the application supports reading files and directories from URIs.
550 	 *
551 	 * Returns: %TRUE if the @appinfo supports URIs.
552 	 */
553 	public bool supportsUris();
554 }