If possible, always pass FUSE file:// URIs (such as
[platform/upstream/glib.git] / gio / gappinfo.c
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #include "config.h"
24 #include "gappinfo.h"
25 #include "glibintl.h"
26 #include <gioerror.h>
27 #include <gfile.h>
28
29 #include "gioalias.h"
30
31 /**
32  * SECTION:gappinfo
33  * @short_description: Application information and launch contexts
34  * @include: gio/gio.h
35  * 
36  * #GAppInfo and #GAppLaunchContext are used for describing and launching 
37  * applications installed on the system.
38  *
39  * As of GLib 2.20, URIs will always be converted to POSIX paths
40  * (using g_file_get_path()) when using g_app_info_launch() even if
41  * the application requested an URI and not a POSIX path. For example
42  * for an desktop-file based application with Exec key <literal>totem
43  * %%U</literal> and a single URI,
44  * <literal>sftp://foo/file.avi</literal>, then
45  * <literal>/home/user/.gvfs/sftp on foo/file.avi</literal> will be
46  * passed. This will only work if a set of suitable GIO extensions
47  * (such as gvfs 2.26 compiled with FUSE support), is available and
48  * operational; if this is not the case, the URI will be passed
49  * unmodified to the application. Some URIs, such as
50  * <literal>mailto:</literal>, of course cannot be mapped to a POSIX
51  * path (in gvfs there's no FUSE mount for it); such URIs will be
52  * passed unmodified to the application.
53  *
54  * Specifically for gvfs 2.26 and later, the POSIX URI will be mapped
55  * back to the GIO URI in the #GFile constructors (since gvfs
56  * implements the #GVfs extension point). As such, if the application
57  * needs to examine the URI, it needs to use g_file_get_uri() or
58  * similar on #GFile. In other words, an application cannot assume
59  * that the URI passed to e.g. g_file_new_for_commandline_arg() is
60  * equal to the result of g_file_get_uri(). The following snippet
61  * illustrates this:
62  *
63  * <programlisting>
64  * GFile *f;
65  * char *uri;
66  *
67  * file = g_file_new_for_commandline_arg (uri_from_commandline);
68  *
69  * uri = g_file_get_uri (file);
70  * strcmp (uri, uri_from_commandline) == 0; // FALSE
71  * g_free (uri);
72  *
73  * if (g_file_has_uri_scheme (file, "cdda"))
74  *   {
75  *     // do something special with uri
76  *   }
77  * g_object_unref (file);
78  * </programlisting>
79  *
80  * This code will work when both <literal>cdda://sr0/Track
81  * 1.wav</literal> and <literal>/home/user/.gvfs/cdda on sr0/Track
82  * 1.wav</literal> is passed to the application. It should be noted
83  * that it's generally not safe for applications to rely on the format
84  * of a particular URIs. Different launcher applications (e.g. file
85  * managers) may have different ideas of what a given URI means.
86  *
87  **/
88
89 static void g_app_info_base_init (gpointer g_class);
90 static void g_app_info_class_init (gpointer g_class,
91                                    gpointer class_data);
92
93
94 GType
95 g_app_info_get_type (void)
96 {
97   static volatile gsize g_define_type_id__volatile = 0;
98
99   if (g_once_init_enter (&g_define_type_id__volatile))
100     {
101      const GTypeInfo app_info_info =
102       {
103         sizeof (GAppInfoIface), /* class_size */
104         g_app_info_base_init,   /* base_init */
105         NULL,           /* base_finalize */
106         g_app_info_class_init,
107         NULL,           /* class_finalize */
108         NULL,           /* class_data */
109         0,
110         0,              /* n_preallocs */
111         NULL
112       };
113       GType g_define_type_id =
114         g_type_register_static (G_TYPE_INTERFACE, I_("GAppInfo"),
115                                 &app_info_info, 0);
116
117       g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT);
118
119       g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
120     }
121
122   return g_define_type_id__volatile;
123 }
124
125 static void
126 g_app_info_class_init (gpointer g_class,
127                        gpointer class_data)
128 {
129 }
130
131 static void
132 g_app_info_base_init (gpointer g_class)
133 {
134 }
135
136
137 /**
138  * g_app_info_dup:
139  * @appinfo: a #GAppInfo.
140  * 
141  * Creates a duplicate of a #GAppInfo.
142  *
143  * Returns: a duplicate of @appinfo.
144  **/
145 GAppInfo *
146 g_app_info_dup (GAppInfo *appinfo)
147 {
148   GAppInfoIface *iface;
149
150   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
151
152   iface = G_APP_INFO_GET_IFACE (appinfo);
153
154   return (* iface->dup) (appinfo);
155 }
156
157 /**
158  * g_app_info_equal:
159  * @appinfo1: the first #GAppInfo.  
160  * @appinfo2: the second #GAppInfo.
161  * 
162  * Checks if two #GAppInfos are equal.
163  *
164  * Returns: %TRUE if @appinfo1 is equal to @appinfo2. %FALSE otherwise.
165  **/
166 gboolean
167 g_app_info_equal (GAppInfo *appinfo1,
168                   GAppInfo *appinfo2)
169 {
170   GAppInfoIface *iface;
171
172   g_return_val_if_fail (G_IS_APP_INFO (appinfo1), FALSE);
173   g_return_val_if_fail (G_IS_APP_INFO (appinfo2), FALSE);
174
175   if (G_TYPE_FROM_INSTANCE (appinfo1) != G_TYPE_FROM_INSTANCE (appinfo2))
176     return FALSE;
177   
178   iface = G_APP_INFO_GET_IFACE (appinfo1);
179
180   return (* iface->equal) (appinfo1, appinfo2);
181 }
182
183 /**
184  * g_app_info_get_id:
185  * @appinfo: a #GAppInfo.
186  * 
187  * Gets the ID of an application. An id is a string that
188  * identifies the application. The exact format of the id is
189  * platform dependent. For instance, on Unix this is the
190  * desktop file id from the xdg menu specification.
191  *
192  * Note that the returned ID may be %NULL, depending on how
193  * the @appinfo has been constructed.
194  *
195  * Returns: a string containing the application's ID.
196  **/
197 const char *
198 g_app_info_get_id (GAppInfo *appinfo)
199 {
200   GAppInfoIface *iface;
201   
202   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
203
204   iface = G_APP_INFO_GET_IFACE (appinfo);
205
206   return (* iface->get_id) (appinfo);
207 }
208
209 /**
210  * g_app_info_get_name:
211  * @appinfo: a #GAppInfo.
212  * 
213  * Gets the installed name of the application. 
214  *
215  * Returns: the name of the application for @appinfo.
216  **/
217 const char *
218 g_app_info_get_name (GAppInfo *appinfo)
219 {
220   GAppInfoIface *iface;
221   
222   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
223
224   iface = G_APP_INFO_GET_IFACE (appinfo);
225
226   return (* iface->get_name) (appinfo);
227 }
228
229 /**
230  * g_app_info_get_description:
231  * @appinfo: a #GAppInfo.
232  * 
233  * Gets a human-readable description of an installed application.
234  *
235  * Returns: a string containing a description of the 
236  * application @appinfo, or %NULL if none. 
237  **/
238 const char *
239 g_app_info_get_description (GAppInfo *appinfo)
240 {
241   GAppInfoIface *iface;
242   
243   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
244
245   iface = G_APP_INFO_GET_IFACE (appinfo);
246
247   return (* iface->get_description) (appinfo);
248 }
249
250 /**
251  * g_app_info_get_executable:
252  * @appinfo: a #GAppInfo.
253  * 
254  * Gets the executable's name for the installed application.
255  *
256  * Returns: a string containing the @appinfo's application 
257  * binary's name.
258  **/
259 const char *
260 g_app_info_get_executable (GAppInfo *appinfo)
261 {
262   GAppInfoIface *iface;
263   
264   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
265
266   iface = G_APP_INFO_GET_IFACE (appinfo);
267
268   return (* iface->get_executable) (appinfo);
269 }
270
271
272 /**
273  * g_app_info_set_as_default_for_type:
274  * @appinfo: a #GAppInfo.
275  * @content_type: the content type.
276  * @error: a #GError.
277  * 
278  * Sets the application as the default handler for a given type.
279  *
280  * Returns: %TRUE on success, %FALSE on error.
281  **/
282 gboolean
283 g_app_info_set_as_default_for_type (GAppInfo    *appinfo,
284                                     const char  *content_type,
285                                     GError     **error)
286 {
287   GAppInfoIface *iface;
288   
289   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
290   g_return_val_if_fail (content_type != NULL, FALSE);
291
292   iface = G_APP_INFO_GET_IFACE (appinfo);
293
294   return (* iface->set_as_default_for_type) (appinfo, content_type, error);
295 }
296
297
298 /**
299  * g_app_info_set_as_default_for_extension:
300  * @appinfo: a #GAppInfo.
301  * @extension: a string containing the file extension (without the dot).
302  * @error: a #GError.
303  * 
304  * Sets the application as the default handler for the given file extention.
305  *
306  * Returns: %TRUE on success, %FALSE on error.
307  **/
308 gboolean
309 g_app_info_set_as_default_for_extension (GAppInfo    *appinfo,
310                                          const char  *extension,
311                                          GError     **error)
312 {
313   GAppInfoIface *iface;
314   
315   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
316   g_return_val_if_fail (extension != NULL, FALSE);
317
318   iface = G_APP_INFO_GET_IFACE (appinfo);
319
320   if (iface->set_as_default_for_extension)
321     return (* iface->set_as_default_for_extension) (appinfo, extension, error);
322
323   g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
324                        "g_app_info_set_as_default_for_extension not supported yet");
325   return FALSE;
326 }
327
328
329 /**
330  * g_app_info_add_supports_type:
331  * @appinfo: a #GAppInfo.
332  * @content_type: a string.
333  * @error: a #GError.
334  * 
335  * Adds a content type to the application information to indicate the 
336  * application is capable of opening files with the given content type.
337  *
338  * Returns: %TRUE on success, %FALSE on error.
339  **/
340 gboolean
341 g_app_info_add_supports_type (GAppInfo    *appinfo,
342                               const char  *content_type,
343                               GError     **error)
344 {
345   GAppInfoIface *iface;
346   
347   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
348   g_return_val_if_fail (content_type != NULL, FALSE);
349
350   iface = G_APP_INFO_GET_IFACE (appinfo);
351
352   if (iface->add_supports_type)
353     return (* iface->add_supports_type) (appinfo, content_type, error);
354
355   g_set_error_literal (error, G_IO_ERROR, 
356                        G_IO_ERROR_NOT_SUPPORTED, 
357                        "g_app_info_add_supports_type not supported yet");
358
359   return FALSE;
360 }
361
362
363 /**
364  * g_app_info_can_remove_supports_type:
365  * @appinfo: a #GAppInfo.
366  * 
367  * Checks if a supported content type can be removed from an application.
368  *
369  * Returns: %TRUE if it is possible to remove supported 
370  *     content types from a given @appinfo, %FALSE if not.
371  **/
372 gboolean
373 g_app_info_can_remove_supports_type (GAppInfo *appinfo)
374 {
375   GAppInfoIface *iface;
376   
377   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
378
379   iface = G_APP_INFO_GET_IFACE (appinfo);
380
381   if (iface->can_remove_supports_type)
382     return (* iface->can_remove_supports_type) (appinfo);
383
384   return FALSE;
385 }
386
387
388 /**
389  * g_app_info_remove_supports_type:
390  * @appinfo: a #GAppInfo.
391  * @content_type: a string.
392  * @error: a #GError.
393  *
394  * Removes a supported type from an application, if possible.
395  * 
396  * Returns: %TRUE on success, %FALSE on error.
397  **/
398 gboolean
399 g_app_info_remove_supports_type (GAppInfo    *appinfo,
400                                  const char  *content_type,
401                                  GError     **error)
402 {
403   GAppInfoIface *iface;
404   
405   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
406   g_return_val_if_fail (content_type != NULL, FALSE);
407
408   iface = G_APP_INFO_GET_IFACE (appinfo);
409
410   if (iface->remove_supports_type)
411     return (* iface->remove_supports_type) (appinfo, content_type, error);
412
413   g_set_error_literal (error, G_IO_ERROR, 
414                        G_IO_ERROR_NOT_SUPPORTED, 
415                        "g_app_info_remove_supports_type not supported yet");
416
417   return FALSE;
418 }
419
420
421 /**
422  * g_app_info_get_icon:
423  * @appinfo: a #GAppInfo.
424  * 
425  * Gets the icon for the application.
426  *
427  * Returns: the default #GIcon for @appinfo.
428  **/
429 GIcon *
430 g_app_info_get_icon (GAppInfo *appinfo)
431 {
432   GAppInfoIface *iface;
433   
434   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
435
436   iface = G_APP_INFO_GET_IFACE (appinfo);
437
438   return (* iface->get_icon) (appinfo);
439 }
440
441
442 /**
443  * g_app_info_launch:
444  * @appinfo: a #GAppInfo
445  * @files: a #GList of #GFile objects
446  * @launch_context: a #GAppLaunchContext or %NULL
447  * @error: a #GError
448  * 
449  * Launches the application. Passes @files to the launched application 
450  * as arguments, using the optional @launch_context to get information
451  * about the details of the launcher (like what screen it is on).
452  * On error, @error will be set accordingly.
453  *
454  * To lauch the application without arguments pass a %NULL @files list.
455  *
456  * Note that even if the launch is successful the application launched
457  * can fail to start if it runs into problems during startup. There is
458  * no way to detect this.
459  *
460  * Some URIs can be changed when passed through a GFile (for instance
461  * unsupported uris with strange formats like mailto:), so if you have
462  * a textual uri you want to pass in as argument, consider using
463  * g_app_info_launch_uris() instead.
464  * 
465  * Returns: %TRUE on successful launch, %FALSE otherwise. 
466  **/
467 gboolean
468 g_app_info_launch (GAppInfo           *appinfo,
469                    GList              *files,
470                    GAppLaunchContext  *launch_context,
471                    GError            **error)
472 {
473   GAppInfoIface *iface;
474   
475   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
476
477   iface = G_APP_INFO_GET_IFACE (appinfo);
478
479   return (* iface->launch) (appinfo, files, launch_context, error);
480 }
481
482
483 /**
484  * g_app_info_supports_uris:
485  * @appinfo: a #GAppInfo.
486  * 
487  * Checks if the application supports reading files and directories from URIs.
488  *
489  * Returns: %TRUE if the @appinfo supports URIs.
490  **/
491 gboolean
492 g_app_info_supports_uris (GAppInfo *appinfo)
493 {
494   GAppInfoIface *iface;
495   
496   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
497
498   iface = G_APP_INFO_GET_IFACE (appinfo);
499
500   return (* iface->supports_uris) (appinfo);
501 }
502
503
504 /**
505  * g_app_info_supports_files:
506  * @appinfo: a #GAppInfo.
507  * 
508  * Checks if the application accepts files as arguments.
509  *
510  * Returns: %TRUE if the @appinfo supports files.
511  **/
512 gboolean
513 g_app_info_supports_files (GAppInfo *appinfo)
514 {
515   GAppInfoIface *iface;
516   
517   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
518
519   iface = G_APP_INFO_GET_IFACE (appinfo);
520
521   return (* iface->supports_files) (appinfo);
522 }
523
524
525 /**
526  * g_app_info_launch_uris:
527  * @appinfo: a #GAppInfo
528  * @uris: a #GList containing URIs to launch. 
529  * @launch_context: a #GAppLaunchContext or %NULL
530  * @error: a #GError
531  * 
532  * Launches the application. Passes @uris to the launched application 
533  * as arguments, using the optional @launch_context to get information
534  * about the details of the launcher (like what screen it is on).
535  * On error, @error will be set accordingly.
536  *
537  * To lauch the application without arguments pass a %NULL @uris list.
538  *
539  * Note that even if the launch is successful the application launched
540  * can fail to start if it runs into problems during startup. There is
541  * no way to detect this.
542  *
543  * Returns: %TRUE on successful launch, %FALSE otherwise. 
544  **/
545 gboolean
546 g_app_info_launch_uris (GAppInfo           *appinfo,
547                         GList              *uris,
548                         GAppLaunchContext  *launch_context,
549                         GError            **error)
550 {
551   GAppInfoIface *iface;
552   
553   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
554
555   iface = G_APP_INFO_GET_IFACE (appinfo);
556
557   return (* iface->launch_uris) (appinfo, uris, launch_context, error);
558 }
559
560
561 /**
562  * g_app_info_should_show:
563  * @appinfo: a #GAppInfo.
564  *
565  * Checks if the application info should be shown in menus that 
566  * list available applications.
567  * 
568  * Returns: %TRUE if the @appinfo should be shown, %FALSE otherwise.
569  **/
570 gboolean
571 g_app_info_should_show (GAppInfo *appinfo)
572 {
573   GAppInfoIface *iface;
574   
575   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
576
577   iface = G_APP_INFO_GET_IFACE (appinfo);
578
579   return (* iface->should_show) (appinfo);
580 }
581
582 /**
583  * g_app_info_launch_default_for_uri:
584  * @uri: the uri to show
585  * @launch_context: an optional #GAppLaunchContext.
586  * @error: a #GError.
587  *
588  * Utility function that launches the default application 
589  * registered to handle the specified uri. Synchronous I/O
590  * is done on the uri to detext the type of the file if
591  * required.
592  * 
593  * Returns: %TRUE on success, %FALSE on error.
594  **/
595 gboolean
596 g_app_info_launch_default_for_uri (const char         *uri,
597                                    GAppLaunchContext  *launch_context,
598                                    GError            **error)
599 {
600   GAppInfo *app_info;
601   GFile *file;
602   GList l;
603   gboolean res;
604
605   file = g_file_new_for_uri (uri);
606   app_info = g_file_query_default_handler (file, NULL, error);
607   g_object_unref (file);
608   if (app_info == NULL)
609     return FALSE;
610
611   /* Use the uri, not the GFile, as the GFile roundtrip may
612    * affect the uri which we don't want (for instance for a
613    * mailto: uri).
614    */
615   l.data = (char *)uri;
616   l.next = l.prev = NULL;
617   res = g_app_info_launch_uris (app_info, &l,
618                                 launch_context, error);
619
620   g_object_unref (app_info);
621   
622   return res;
623 }
624
625 /**
626  * g_app_info_can_delete:
627  * @appinfo: a #GAppInfo
628  *
629  * Obtains the information whether the GAppInfo can be deleted.
630  * See g_app_info_delete().
631  *
632  * Returns: %TRUE if @appinfo can be deleted
633  *
634  * Since: 2.20
635  */
636 gboolean
637 g_app_info_can_delete (GAppInfo *appinfo)
638 {
639   GAppInfoIface *iface;
640   
641   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
642
643   iface = G_APP_INFO_GET_IFACE (appinfo);
644
645   if (iface->can_delete)
646     return (* iface->can_delete) (appinfo);
647  
648   return FALSE; 
649 }
650
651
652 /**
653  * g_app_info_delete:
654  * @appinfo: a #GAppInfo
655  *
656  * Tries to delete an #GAppInfo. 
657  *
658  * On some platforms, there may be a difference between user-defined
659  * #GAppInfo<!-- -->s which can be deleted, and system-wide ones which
660  * cannot. See g_app_info_can_delete().
661  * 
662  * Returns: %TRUE if @appinfo has been deleted
663  *
664  * Since: 2.20
665  */
666 gboolean
667 g_app_info_delete (GAppInfo *appinfo)
668 {
669   GAppInfoIface *iface;
670   
671   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
672
673   iface = G_APP_INFO_GET_IFACE (appinfo);
674
675   if (iface->do_delete)
676     return (* iface->do_delete) (appinfo);
677  
678   return FALSE; 
679 }
680
681
682 G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
683
684 /**
685  * g_app_launch_context_new:
686  * 
687  * Creates a new application launch context. This is not normally used,
688  * instead you instantiate a subclass of this, such as #GdkAppLaunchContext.
689  *
690  * Returns: a #GAppLaunchContext.
691  **/
692 GAppLaunchContext *
693 g_app_launch_context_new (void)
694 {
695   return g_object_new (G_TYPE_APP_LAUNCH_CONTEXT, NULL);
696 }
697
698 static void
699 g_app_launch_context_class_init (GAppLaunchContextClass *klass)
700 {
701 }
702
703 static void
704 g_app_launch_context_init (GAppLaunchContext *launch_context)
705 {
706 }
707
708 /**
709  * g_app_launch_context_get_display:
710  * @context: a #GAppLaunchContext
711  * @info: a #GAppInfo
712  * @files: a #GList of #GFile objects
713  *
714  * Gets the display string for the display. This is used to ensure new
715  * applications are started on the same display as the launching 
716  * application.
717  * 
718  * Returns: a display string for the display.
719  **/
720 char *
721 g_app_launch_context_get_display (GAppLaunchContext *context,
722                                   GAppInfo          *info,
723                                   GList             *files)
724 {
725   GAppLaunchContextClass *class;
726
727   g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
728   g_return_val_if_fail (G_IS_APP_INFO (info), NULL);
729
730   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
731
732   if (class->get_display == NULL)
733     return NULL;
734
735   return class->get_display (context, info, files);
736 }
737
738 /**
739  * g_app_launch_context_get_startup_notify_id:
740  * @context: a #GAppLaunchContext
741  * @info: a #GAppInfo
742  * @files: a #GList of of #GFile objects
743  * 
744  * Initiates startup notification for the application and returns the
745  * DESKTOP_STARTUP_ID for the launched operation, if supported.
746  *
747  * Startup notification IDs are defined in the <ulink
748  * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">
749  * FreeDesktop.Org Startup Notifications standard</ulink>.
750  *
751  * Returns: a startup notification ID for the application, or %NULL if 
752  *     not supported.
753  **/
754 char *
755 g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
756                                             GAppInfo          *info,
757                                             GList             *files)
758 {
759   GAppLaunchContextClass *class;
760
761   g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
762   g_return_val_if_fail (G_IS_APP_INFO (info), NULL);
763
764   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
765
766   if (class->get_startup_notify_id == NULL)
767     return NULL;
768
769   return class->get_startup_notify_id (context, info, files);
770 }
771
772
773 /**
774  * g_app_launch_context_launch_failed:
775  * @context: a #GAppLaunchContext.
776  * @startup_notify_id: the startup notification id that was returned by g_app_launch_context_get_startup_notify_id().
777  *
778  * Called when an application has failed to launch, so that it can cancel
779  * the application startup notification started in g_app_launch_context_get_startup_notify_id().
780  * 
781  **/
782 void
783 g_app_launch_context_launch_failed (GAppLaunchContext *context,
784                                     const char        *startup_notify_id)
785 {
786   GAppLaunchContextClass *class;
787
788   g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
789   g_return_if_fail (startup_notify_id != NULL);
790
791   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
792
793   if (class->launch_failed != NULL)
794     class->launch_failed (context, startup_notify_id);
795 }
796
797
798 #define __G_APP_INFO_C__
799 #include "gioaliasdef.c"