Merge remote branch 'gvdb/master'
[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 typedef GAppInfoIface GAppInfoInterface;
90 G_DEFINE_INTERFACE (GAppInfo, g_app_info, G_TYPE_OBJECT)
91
92 static void
93 g_app_info_default_init (GAppInfoInterface *iface)
94 {
95 }
96
97
98 /**
99  * g_app_info_dup:
100  * @appinfo: a #GAppInfo.
101  * 
102  * Creates a duplicate of a #GAppInfo.
103  *
104  * Returns: a duplicate of @appinfo.
105  **/
106 GAppInfo *
107 g_app_info_dup (GAppInfo *appinfo)
108 {
109   GAppInfoIface *iface;
110
111   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
112
113   iface = G_APP_INFO_GET_IFACE (appinfo);
114
115   return (* iface->dup) (appinfo);
116 }
117
118 /**
119  * g_app_info_equal:
120  * @appinfo1: the first #GAppInfo.  
121  * @appinfo2: the second #GAppInfo.
122  * 
123  * Checks if two #GAppInfo<!-- -->s are equal.
124  *
125  * Returns: %TRUE if @appinfo1 is equal to @appinfo2. %FALSE otherwise.
126  **/
127 gboolean
128 g_app_info_equal (GAppInfo *appinfo1,
129                   GAppInfo *appinfo2)
130 {
131   GAppInfoIface *iface;
132
133   g_return_val_if_fail (G_IS_APP_INFO (appinfo1), FALSE);
134   g_return_val_if_fail (G_IS_APP_INFO (appinfo2), FALSE);
135
136   if (G_TYPE_FROM_INSTANCE (appinfo1) != G_TYPE_FROM_INSTANCE (appinfo2))
137     return FALSE;
138   
139   iface = G_APP_INFO_GET_IFACE (appinfo1);
140
141   return (* iface->equal) (appinfo1, appinfo2);
142 }
143
144 /**
145  * g_app_info_get_id:
146  * @appinfo: a #GAppInfo.
147  * 
148  * Gets the ID of an application. An id is a string that
149  * identifies the application. The exact format of the id is
150  * platform dependent. For instance, on Unix this is the
151  * desktop file id from the xdg menu specification.
152  *
153  * Note that the returned ID may be %NULL, depending on how
154  * the @appinfo has been constructed.
155  *
156  * Returns: a string containing the application's ID.
157  **/
158 const char *
159 g_app_info_get_id (GAppInfo *appinfo)
160 {
161   GAppInfoIface *iface;
162   
163   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
164
165   iface = G_APP_INFO_GET_IFACE (appinfo);
166
167   return (* iface->get_id) (appinfo);
168 }
169
170 /**
171  * g_app_info_get_name:
172  * @appinfo: a #GAppInfo.
173  * 
174  * Gets the installed name of the application. 
175  *
176  * Returns: the name of the application for @appinfo.
177  **/
178 const char *
179 g_app_info_get_name (GAppInfo *appinfo)
180 {
181   GAppInfoIface *iface;
182   
183   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
184
185   iface = G_APP_INFO_GET_IFACE (appinfo);
186
187   return (* iface->get_name) (appinfo);
188 }
189
190 /**
191  * g_app_info_get_display_name:
192  * @appinfo: a #GAppInfo.
193  *
194  * Gets the display name of the application. The display name is often more
195  * descriptive to the user than the name itself.
196  *
197  * Returns: the display name of the application for @appinfo, or the name if
198  * no display name is available.
199  *
200  * Since: 2.24
201  **/
202 const char *
203 g_app_info_get_display_name (GAppInfo *appinfo)
204 {
205   GAppInfoIface *iface;
206
207   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
208
209   iface = G_APP_INFO_GET_IFACE (appinfo);
210
211   if (iface->get_display_name == NULL)
212     return (* iface->get_name) (appinfo);
213
214   return (* iface->get_display_name) (appinfo);
215 }
216
217 /**
218  * g_app_info_get_description:
219  * @appinfo: a #GAppInfo.
220  * 
221  * Gets a human-readable description of an installed application.
222  *
223  * Returns: a string containing a description of the 
224  * application @appinfo, or %NULL if none. 
225  **/
226 const char *
227 g_app_info_get_description (GAppInfo *appinfo)
228 {
229   GAppInfoIface *iface;
230   
231   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
232
233   iface = G_APP_INFO_GET_IFACE (appinfo);
234
235   return (* iface->get_description) (appinfo);
236 }
237
238 /**
239  * g_app_info_get_executable:
240  * @appinfo: a #GAppInfo
241  * 
242  * Gets the executable's name for the installed application.
243  *
244  * Returns: a string containing the @appinfo's application 
245  * binaries name
246  **/
247 const char *
248 g_app_info_get_executable (GAppInfo *appinfo)
249 {
250   GAppInfoIface *iface;
251   
252   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
253
254   iface = G_APP_INFO_GET_IFACE (appinfo);
255
256   return (* iface->get_executable) (appinfo);
257 }
258
259
260 /**
261  * g_app_info_get_commandline:
262  * @appinfo: a #GAppInfo
263  * 
264  * Gets the commandline with which the application will be
265  * started.  
266  *
267  * Returns: a string containing the @appinfo's commandline, 
268  *     or %NULL if this information is not available
269  *
270  * Since: 2.20
271  **/
272 const char *
273 g_app_info_get_commandline (GAppInfo *appinfo)
274 {
275   GAppInfoIface *iface;
276   
277   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
278
279   iface = G_APP_INFO_GET_IFACE (appinfo);
280
281   if (iface->get_commandline)
282     return (* iface->get_commandline) (appinfo);
283  
284   return NULL;
285 }
286
287 /**
288  * g_app_info_set_as_default_for_type:
289  * @appinfo: a #GAppInfo.
290  * @content_type: the content type.
291  * @error: a #GError.
292  * 
293  * Sets the application as the default handler for a given type.
294  *
295  * Returns: %TRUE on success, %FALSE on error.
296  **/
297 gboolean
298 g_app_info_set_as_default_for_type (GAppInfo    *appinfo,
299                                     const char  *content_type,
300                                     GError     **error)
301 {
302   GAppInfoIface *iface;
303   
304   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
305   g_return_val_if_fail (content_type != NULL, FALSE);
306
307   iface = G_APP_INFO_GET_IFACE (appinfo);
308
309   return (* iface->set_as_default_for_type) (appinfo, content_type, error);
310 }
311
312
313 /**
314  * g_app_info_set_as_default_for_extension:
315  * @appinfo: a #GAppInfo.
316  * @extension: a string containing the file extension (without the dot).
317  * @error: a #GError.
318  * 
319  * Sets the application as the default handler for the given file extension.
320  *
321  * Returns: %TRUE on success, %FALSE on error.
322  **/
323 gboolean
324 g_app_info_set_as_default_for_extension (GAppInfo    *appinfo,
325                                          const char  *extension,
326                                          GError     **error)
327 {
328   GAppInfoIface *iface;
329   
330   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
331   g_return_val_if_fail (extension != NULL, FALSE);
332
333   iface = G_APP_INFO_GET_IFACE (appinfo);
334
335   if (iface->set_as_default_for_extension)
336     return (* iface->set_as_default_for_extension) (appinfo, extension, error);
337
338   g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
339                        "g_app_info_set_as_default_for_extension not supported yet");
340   return FALSE;
341 }
342
343
344 /**
345  * g_app_info_add_supports_type:
346  * @appinfo: a #GAppInfo.
347  * @content_type: a string.
348  * @error: a #GError.
349  * 
350  * Adds a content type to the application information to indicate the 
351  * application is capable of opening files with the given content type.
352  *
353  * Returns: %TRUE on success, %FALSE on error.
354  **/
355 gboolean
356 g_app_info_add_supports_type (GAppInfo    *appinfo,
357                               const char  *content_type,
358                               GError     **error)
359 {
360   GAppInfoIface *iface;
361   
362   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
363   g_return_val_if_fail (content_type != NULL, FALSE);
364
365   iface = G_APP_INFO_GET_IFACE (appinfo);
366
367   if (iface->add_supports_type)
368     return (* iface->add_supports_type) (appinfo, content_type, error);
369
370   g_set_error_literal (error, G_IO_ERROR, 
371                        G_IO_ERROR_NOT_SUPPORTED, 
372                        "g_app_info_add_supports_type not supported yet");
373
374   return FALSE;
375 }
376
377
378 /**
379  * g_app_info_can_remove_supports_type:
380  * @appinfo: a #GAppInfo.
381  * 
382  * Checks if a supported content type can be removed from an application.
383  *
384  * Returns: %TRUE if it is possible to remove supported 
385  *     content types from a given @appinfo, %FALSE if not.
386  **/
387 gboolean
388 g_app_info_can_remove_supports_type (GAppInfo *appinfo)
389 {
390   GAppInfoIface *iface;
391   
392   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
393
394   iface = G_APP_INFO_GET_IFACE (appinfo);
395
396   if (iface->can_remove_supports_type)
397     return (* iface->can_remove_supports_type) (appinfo);
398
399   return FALSE;
400 }
401
402
403 /**
404  * g_app_info_remove_supports_type:
405  * @appinfo: a #GAppInfo.
406  * @content_type: a string.
407  * @error: a #GError.
408  *
409  * Removes a supported type from an application, if possible.
410  * 
411  * Returns: %TRUE on success, %FALSE on error.
412  **/
413 gboolean
414 g_app_info_remove_supports_type (GAppInfo    *appinfo,
415                                  const char  *content_type,
416                                  GError     **error)
417 {
418   GAppInfoIface *iface;
419   
420   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
421   g_return_val_if_fail (content_type != NULL, FALSE);
422
423   iface = G_APP_INFO_GET_IFACE (appinfo);
424
425   if (iface->remove_supports_type)
426     return (* iface->remove_supports_type) (appinfo, content_type, error);
427
428   g_set_error_literal (error, G_IO_ERROR, 
429                        G_IO_ERROR_NOT_SUPPORTED, 
430                        "g_app_info_remove_supports_type not supported yet");
431
432   return FALSE;
433 }
434
435
436 /**
437  * g_app_info_get_icon:
438  * @appinfo: a #GAppInfo.
439  * 
440  * Gets the icon for the application.
441  *
442  * Returns: the default #GIcon for @appinfo.
443  **/
444 GIcon *
445 g_app_info_get_icon (GAppInfo *appinfo)
446 {
447   GAppInfoIface *iface;
448   
449   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
450
451   iface = G_APP_INFO_GET_IFACE (appinfo);
452
453   return (* iface->get_icon) (appinfo);
454 }
455
456
457 /**
458  * g_app_info_launch:
459  * @appinfo: a #GAppInfo
460  * @files: a #GList of #GFile objects
461  * @launch_context: a #GAppLaunchContext or %NULL
462  * @error: a #GError
463  * 
464  * Launches the application. Passes @files to the launched application 
465  * as arguments, using the optional @launch_context to get information
466  * about the details of the launcher (like what screen it is on).
467  * On error, @error will be set accordingly.
468  *
469  * To lauch the application without arguments pass a %NULL @files list.
470  *
471  * Note that even if the launch is successful the application launched
472  * can fail to start if it runs into problems during startup. There is
473  * no way to detect this.
474  *
475  * Some URIs can be changed when passed through a GFile (for instance
476  * unsupported uris with strange formats like mailto:), so if you have
477  * a textual uri you want to pass in as argument, consider using
478  * g_app_info_launch_uris() instead.
479  * 
480  * Returns: %TRUE on successful launch, %FALSE otherwise. 
481  **/
482 gboolean
483 g_app_info_launch (GAppInfo           *appinfo,
484                    GList              *files,
485                    GAppLaunchContext  *launch_context,
486                    GError            **error)
487 {
488   GAppInfoIface *iface;
489   
490   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
491
492   iface = G_APP_INFO_GET_IFACE (appinfo);
493
494   return (* iface->launch) (appinfo, files, launch_context, error);
495 }
496
497
498 /**
499  * g_app_info_supports_uris:
500  * @appinfo: a #GAppInfo.
501  * 
502  * Checks if the application supports reading files and directories from URIs.
503  *
504  * Returns: %TRUE if the @appinfo supports URIs.
505  **/
506 gboolean
507 g_app_info_supports_uris (GAppInfo *appinfo)
508 {
509   GAppInfoIface *iface;
510   
511   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
512
513   iface = G_APP_INFO_GET_IFACE (appinfo);
514
515   return (* iface->supports_uris) (appinfo);
516 }
517
518
519 /**
520  * g_app_info_supports_files:
521  * @appinfo: a #GAppInfo.
522  * 
523  * Checks if the application accepts files as arguments.
524  *
525  * Returns: %TRUE if the @appinfo supports files.
526  **/
527 gboolean
528 g_app_info_supports_files (GAppInfo *appinfo)
529 {
530   GAppInfoIface *iface;
531   
532   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
533
534   iface = G_APP_INFO_GET_IFACE (appinfo);
535
536   return (* iface->supports_files) (appinfo);
537 }
538
539
540 /**
541  * g_app_info_launch_uris:
542  * @appinfo: a #GAppInfo
543  * @uris: a #GList containing URIs to launch. 
544  * @launch_context: a #GAppLaunchContext or %NULL
545  * @error: a #GError
546  * 
547  * Launches the application. Passes @uris to the launched application 
548  * as arguments, using the optional @launch_context to get information
549  * about the details of the launcher (like what screen it is on).
550  * On error, @error will be set accordingly.
551  *
552  * To lauch the application without arguments pass a %NULL @uris list.
553  *
554  * Note that even if the launch is successful the application launched
555  * can fail to start if it runs into problems during startup. There is
556  * no way to detect this.
557  *
558  * Returns: %TRUE on successful launch, %FALSE otherwise. 
559  **/
560 gboolean
561 g_app_info_launch_uris (GAppInfo           *appinfo,
562                         GList              *uris,
563                         GAppLaunchContext  *launch_context,
564                         GError            **error)
565 {
566   GAppInfoIface *iface;
567   
568   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
569
570   iface = G_APP_INFO_GET_IFACE (appinfo);
571
572   return (* iface->launch_uris) (appinfo, uris, launch_context, error);
573 }
574
575
576 /**
577  * g_app_info_should_show:
578  * @appinfo: a #GAppInfo.
579  *
580  * Checks if the application info should be shown in menus that 
581  * list available applications.
582  * 
583  * Returns: %TRUE if the @appinfo should be shown, %FALSE otherwise.
584  **/
585 gboolean
586 g_app_info_should_show (GAppInfo *appinfo)
587 {
588   GAppInfoIface *iface;
589   
590   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
591
592   iface = G_APP_INFO_GET_IFACE (appinfo);
593
594   return (* iface->should_show) (appinfo);
595 }
596
597 /**
598  * g_app_info_launch_default_for_uri:
599  * @uri: the uri to show
600  * @launch_context: an optional #GAppLaunchContext.
601  * @error: a #GError.
602  *
603  * Utility function that launches the default application 
604  * registered to handle the specified uri. Synchronous I/O
605  * is done on the uri to detect the type of the file if
606  * required.
607  * 
608  * Returns: %TRUE on success, %FALSE on error.
609  **/
610 gboolean
611 g_app_info_launch_default_for_uri (const char         *uri,
612                                    GAppLaunchContext  *launch_context,
613                                    GError            **error)
614 {
615   GAppInfo *app_info;
616   GFile *file;
617   GList l;
618   gboolean res;
619
620   file = g_file_new_for_uri (uri);
621   app_info = g_file_query_default_handler (file, NULL, error);
622   g_object_unref (file);
623   if (app_info == NULL)
624     return FALSE;
625
626   /* Use the uri, not the GFile, as the GFile roundtrip may
627    * affect the uri which we don't want (for instance for a
628    * mailto: uri).
629    */
630   l.data = (char *)uri;
631   l.next = l.prev = NULL;
632   res = g_app_info_launch_uris (app_info, &l,
633                                 launch_context, error);
634
635   g_object_unref (app_info);
636   
637   return res;
638 }
639
640 /**
641  * g_app_info_can_delete:
642  * @appinfo: a #GAppInfo
643  *
644  * Obtains the information whether the #GAppInfo can be deleted.
645  * See g_app_info_delete().
646  *
647  * Returns: %TRUE if @appinfo can be deleted
648  *
649  * Since: 2.20
650  */
651 gboolean
652 g_app_info_can_delete (GAppInfo *appinfo)
653 {
654   GAppInfoIface *iface;
655   
656   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
657
658   iface = G_APP_INFO_GET_IFACE (appinfo);
659
660   if (iface->can_delete)
661     return (* iface->can_delete) (appinfo);
662  
663   return FALSE; 
664 }
665
666
667 /**
668  * g_app_info_delete:
669  * @appinfo: a #GAppInfo
670  *
671  * Tries to delete a #GAppInfo.
672  *
673  * On some platforms, there may be a difference between user-defined
674  * #GAppInfo<!-- -->s which can be deleted, and system-wide ones which
675  * cannot. See g_app_info_can_delete().
676  * 
677  * Returns: %TRUE if @appinfo has been deleted
678  *
679  * Since: 2.20
680  */
681 gboolean
682 g_app_info_delete (GAppInfo *appinfo)
683 {
684   GAppInfoIface *iface;
685   
686   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
687
688   iface = G_APP_INFO_GET_IFACE (appinfo);
689
690   if (iface->do_delete)
691     return (* iface->do_delete) (appinfo);
692  
693   return FALSE; 
694 }
695
696
697 G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
698
699 /**
700  * g_app_launch_context_new:
701  * 
702  * Creates a new application launch context. This is not normally used,
703  * instead you instantiate a subclass of this, such as #GdkAppLaunchContext.
704  *
705  * Returns: a #GAppLaunchContext.
706  **/
707 GAppLaunchContext *
708 g_app_launch_context_new (void)
709 {
710   return g_object_new (G_TYPE_APP_LAUNCH_CONTEXT, NULL);
711 }
712
713 static void
714 g_app_launch_context_class_init (GAppLaunchContextClass *klass)
715 {
716 }
717
718 static void
719 g_app_launch_context_init (GAppLaunchContext *launch_context)
720 {
721 }
722
723 /**
724  * g_app_launch_context_get_display:
725  * @context: a #GAppLaunchContext
726  * @info: a #GAppInfo
727  * @files: a #GList of #GFile objects
728  *
729  * Gets the display string for the display. This is used to ensure new
730  * applications are started on the same display as the launching 
731  * application.
732  * 
733  * Returns: a display string for the display.
734  **/
735 char *
736 g_app_launch_context_get_display (GAppLaunchContext *context,
737                                   GAppInfo          *info,
738                                   GList             *files)
739 {
740   GAppLaunchContextClass *class;
741
742   g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
743   g_return_val_if_fail (G_IS_APP_INFO (info), NULL);
744
745   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
746
747   if (class->get_display == NULL)
748     return NULL;
749
750   return class->get_display (context, info, files);
751 }
752
753 /**
754  * g_app_launch_context_get_startup_notify_id:
755  * @context: a #GAppLaunchContext
756  * @info: a #GAppInfo
757  * @files: a #GList of of #GFile objects
758  * 
759  * Initiates startup notification for the application and returns the
760  * DESKTOP_STARTUP_ID for the launched operation, if supported.
761  *
762  * Startup notification IDs are defined in the <ulink
763  * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">
764  * FreeDesktop.Org Startup Notifications standard</ulink>.
765  *
766  * Returns: a startup notification ID for the application, or %NULL if 
767  *     not supported.
768  **/
769 char *
770 g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
771                                             GAppInfo          *info,
772                                             GList             *files)
773 {
774   GAppLaunchContextClass *class;
775
776   g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
777   g_return_val_if_fail (G_IS_APP_INFO (info), NULL);
778
779   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
780
781   if (class->get_startup_notify_id == NULL)
782     return NULL;
783
784   return class->get_startup_notify_id (context, info, files);
785 }
786
787
788 /**
789  * g_app_launch_context_launch_failed:
790  * @context: a #GAppLaunchContext.
791  * @startup_notify_id: the startup notification id that was returned by g_app_launch_context_get_startup_notify_id().
792  *
793  * Called when an application has failed to launch, so that it can cancel
794  * the application startup notification started in g_app_launch_context_get_startup_notify_id().
795  * 
796  **/
797 void
798 g_app_launch_context_launch_failed (GAppLaunchContext *context,
799                                     const char        *startup_notify_id)
800 {
801   GAppLaunchContextClass *class;
802
803   g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
804   g_return_if_fail (startup_notify_id != NULL);
805
806   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
807
808   if (class->launch_failed != NULL)
809     class->launch_failed (context, startup_notify_id);
810 }
811
812
813 #define __G_APP_INFO_C__
814 #include "gioaliasdef.c"