source: appstream-generator/build/girepo/gio/AppInfoT.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

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