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