Merge the wip/gapplication branch
[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  * On UNIX, this function sets the <envvar>GIO_LAUNCHED_DESKTOP_FILE</envvar>
481  * environment variable with the path of the launched desktop file and
482  * <envvar>GIO_LAUNCHED_DESKTOP_FILE_PID</envvar> to the process
483  * id of the launched process. This can be used to ignore
484  * <envvar>GIO_LAUNCHED_DESKTOP_FILE</envvar>, should it be inherited
485  * by further processes. The <envvar>DISPLAY</envvar> and
486  * <envvar>DESKTOP_STARTUP_ID</envvar> environment variables are also
487  * set, based on information provided in @launch_context.
488  *
489  * Returns: %TRUE on successful launch, %FALSE otherwise.
490  **/
491 gboolean
492 g_app_info_launch (GAppInfo           *appinfo,
493                    GList              *files,
494                    GAppLaunchContext  *launch_context,
495                    GError            **error)
496 {
497   GAppInfoIface *iface;
498   
499   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
500
501   iface = G_APP_INFO_GET_IFACE (appinfo);
502
503   return (* iface->launch) (appinfo, files, launch_context, error);
504 }
505
506
507 /**
508  * g_app_info_supports_uris:
509  * @appinfo: a #GAppInfo.
510  * 
511  * Checks if the application supports reading files and directories from URIs.
512  *
513  * Returns: %TRUE if the @appinfo supports URIs.
514  **/
515 gboolean
516 g_app_info_supports_uris (GAppInfo *appinfo)
517 {
518   GAppInfoIface *iface;
519   
520   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
521
522   iface = G_APP_INFO_GET_IFACE (appinfo);
523
524   return (* iface->supports_uris) (appinfo);
525 }
526
527
528 /**
529  * g_app_info_supports_files:
530  * @appinfo: a #GAppInfo.
531  * 
532  * Checks if the application accepts files as arguments.
533  *
534  * Returns: %TRUE if the @appinfo supports files.
535  **/
536 gboolean
537 g_app_info_supports_files (GAppInfo *appinfo)
538 {
539   GAppInfoIface *iface;
540   
541   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
542
543   iface = G_APP_INFO_GET_IFACE (appinfo);
544
545   return (* iface->supports_files) (appinfo);
546 }
547
548
549 /**
550  * g_app_info_launch_uris:
551  * @appinfo: a #GAppInfo
552  * @uris: a #GList containing URIs to launch.
553  * @launch_context: a #GAppLaunchContext or %NULL
554  * @error: a #GError
555  * 
556  * Launches the application. Passes @uris to the launched application
557  * as arguments, using the optional @launch_context to get information
558  * about the details of the launcher (like what screen it is on).
559  * On error, @error will be set accordingly.
560  *
561  * To lauch the application without arguments pass a %NULL @uris list.
562  *
563  * Note that even if the launch is successful the application launched
564  * can fail to start if it runs into problems during startup. There is
565  * no way to detect this.
566  *
567  * Returns: %TRUE on successful launch, %FALSE otherwise.
568  **/
569 gboolean
570 g_app_info_launch_uris (GAppInfo           *appinfo,
571                         GList              *uris,
572                         GAppLaunchContext  *launch_context,
573                         GError            **error)
574 {
575   GAppInfoIface *iface;
576   
577   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
578
579   iface = G_APP_INFO_GET_IFACE (appinfo);
580
581   return (* iface->launch_uris) (appinfo, uris, launch_context, error);
582 }
583
584
585 /**
586  * g_app_info_should_show:
587  * @appinfo: a #GAppInfo.
588  *
589  * Checks if the application info should be shown in menus that 
590  * list available applications.
591  * 
592  * Returns: %TRUE if the @appinfo should be shown, %FALSE otherwise.
593  **/
594 gboolean
595 g_app_info_should_show (GAppInfo *appinfo)
596 {
597   GAppInfoIface *iface;
598   
599   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
600
601   iface = G_APP_INFO_GET_IFACE (appinfo);
602
603   return (* iface->should_show) (appinfo);
604 }
605
606 /**
607  * g_app_info_launch_default_for_uri:
608  * @uri: the uri to show
609  * @launch_context: an optional #GAppLaunchContext.
610  * @error: a #GError.
611  *
612  * Utility function that launches the default application
613  * registered to handle the specified uri. Synchronous I/O
614  * is done on the uri to detect the type of the file if
615  * required.
616  * 
617  * Returns: %TRUE on success, %FALSE on error.
618  **/
619 gboolean
620 g_app_info_launch_default_for_uri (const char         *uri,
621                                    GAppLaunchContext  *launch_context,
622                                    GError            **error)
623 {
624   GAppInfo *app_info;
625   GFile *file;
626   GList l;
627   gboolean res;
628
629   file = g_file_new_for_uri (uri);
630   app_info = g_file_query_default_handler (file, NULL, error);
631   g_object_unref (file);
632   if (app_info == NULL)
633     return FALSE;
634
635   /* Use the uri, not the GFile, as the GFile roundtrip may
636    * affect the uri which we don't want (for instance for a
637    * mailto: uri).
638    */
639   l.data = (char *)uri;
640   l.next = l.prev = NULL;
641   res = g_app_info_launch_uris (app_info, &l,
642                                 launch_context, error);
643
644   g_object_unref (app_info);
645   
646   return res;
647 }
648
649 /**
650  * g_app_info_can_delete:
651  * @appinfo: a #GAppInfo
652  *
653  * Obtains the information whether the #GAppInfo can be deleted.
654  * See g_app_info_delete().
655  *
656  * Returns: %TRUE if @appinfo can be deleted
657  *
658  * Since: 2.20
659  */
660 gboolean
661 g_app_info_can_delete (GAppInfo *appinfo)
662 {
663   GAppInfoIface *iface;
664   
665   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
666
667   iface = G_APP_INFO_GET_IFACE (appinfo);
668
669   if (iface->can_delete)
670     return (* iface->can_delete) (appinfo);
671  
672   return FALSE; 
673 }
674
675
676 /**
677  * g_app_info_delete:
678  * @appinfo: a #GAppInfo
679  *
680  * Tries to delete a #GAppInfo.
681  *
682  * On some platforms, there may be a difference between user-defined
683  * #GAppInfo<!-- -->s which can be deleted, and system-wide ones which
684  * cannot. See g_app_info_can_delete().
685  * 
686  * Returns: %TRUE if @appinfo has been deleted
687  *
688  * Since: 2.20
689  */
690 gboolean
691 g_app_info_delete (GAppInfo *appinfo)
692 {
693   GAppInfoIface *iface;
694   
695   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
696
697   iface = G_APP_INFO_GET_IFACE (appinfo);
698
699   if (iface->do_delete)
700     return (* iface->do_delete) (appinfo);
701  
702   return FALSE; 
703 }
704
705
706 G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
707
708 /**
709  * g_app_launch_context_new:
710  * 
711  * Creates a new application launch context. This is not normally used,
712  * instead you instantiate a subclass of this, such as #GdkAppLaunchContext.
713  *
714  * Returns: a #GAppLaunchContext.
715  **/
716 GAppLaunchContext *
717 g_app_launch_context_new (void)
718 {
719   return g_object_new (G_TYPE_APP_LAUNCH_CONTEXT, NULL);
720 }
721
722 static void
723 g_app_launch_context_class_init (GAppLaunchContextClass *klass)
724 {
725 }
726
727 static void
728 g_app_launch_context_init (GAppLaunchContext *launch_context)
729 {
730 }
731
732 /**
733  * g_app_launch_context_get_display:
734  * @context: a #GAppLaunchContext
735  * @info: a #GAppInfo
736  * @files: a #GList of #GFile objects
737  *
738  * Gets the display string for the @context. This is used to ensure new
739  * applications are started on the same display as the launching
740  * application, by setting the <envvar>DISPLAY</envvar> environment variable.
741  *
742  * Returns: a display string for the display.
743  **/
744 char *
745 g_app_launch_context_get_display (GAppLaunchContext *context,
746                                   GAppInfo          *info,
747                                   GList             *files)
748 {
749   GAppLaunchContextClass *class;
750
751   g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
752   g_return_val_if_fail (G_IS_APP_INFO (info), NULL);
753
754   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
755
756   if (class->get_display == NULL)
757     return NULL;
758
759   return class->get_display (context, info, files);
760 }
761
762 /**
763  * g_app_launch_context_get_startup_notify_id:
764  * @context: a #GAppLaunchContext
765  * @info: a #GAppInfo
766  * @files: a #GList of of #GFile objects
767  * 
768  * Initiates startup notification for the application and returns the
769  * <envvar>DESKTOP_STARTUP_ID</envvar> for the launched operation,
770  * if supported.
771  *
772  * Startup notification IDs are defined in the <ulink
773  * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">
774  * FreeDesktop.Org Startup Notifications standard</ulink>.
775  *
776  * Returns: a startup notification ID for the application, or %NULL if
777  *     not supported.
778  **/
779 char *
780 g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
781                                             GAppInfo          *info,
782                                             GList             *files)
783 {
784   GAppLaunchContextClass *class;
785
786   g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
787   g_return_val_if_fail (G_IS_APP_INFO (info), NULL);
788
789   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
790
791   if (class->get_startup_notify_id == NULL)
792     return NULL;
793
794   return class->get_startup_notify_id (context, info, files);
795 }
796
797
798 /**
799  * g_app_launch_context_launch_failed:
800  * @context: a #GAppLaunchContext.
801  * @startup_notify_id: the startup notification id that was returned by g_app_launch_context_get_startup_notify_id().
802  *
803  * Called when an application has failed to launch, so that it can cancel
804  * the application startup notification started in g_app_launch_context_get_startup_notify_id().
805  * 
806  **/
807 void
808 g_app_launch_context_launch_failed (GAppLaunchContext *context,
809                                     const char        *startup_notify_id)
810 {
811   GAppLaunchContextClass *class;
812
813   g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
814   g_return_if_fail (startup_notify_id != NULL);
815
816   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
817
818   if (class->launch_failed != NULL)
819     class->launch_failed (context, startup_notify_id);
820 }
821
822
823 #define __G_APP_INFO_C__
824 #include "gioaliasdef.c"