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