Bug 600620 - Add g_app_info_get_display_name()
[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 #GAppInfo<!-- -->s 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_display_name:
231  * @appinfo: a #GAppInfo.
232  *
233  * Gets the display name of the application. The display name is often more
234  * descriptive to the user than the name itself.
235  *
236  * Returns: the display name of the application for @appinfo, or the name if
237  * no display name is available.
238  *
239  * Since: 2.24
240  **/
241 const char *
242 g_app_info_get_display_name (GAppInfo *appinfo)
243 {
244   GAppInfoIface *iface;
245
246   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
247
248   iface = G_APP_INFO_GET_IFACE (appinfo);
249
250   if (iface->get_display_name == NULL)
251     return (* iface->get_name) (appinfo);
252
253   return (* iface->get_display_name) (appinfo);
254 }
255
256 /**
257  * g_app_info_get_description:
258  * @appinfo: a #GAppInfo.
259  * 
260  * Gets a human-readable description of an installed application.
261  *
262  * Returns: a string containing a description of the 
263  * application @appinfo, or %NULL if none. 
264  **/
265 const char *
266 g_app_info_get_description (GAppInfo *appinfo)
267 {
268   GAppInfoIface *iface;
269   
270   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
271
272   iface = G_APP_INFO_GET_IFACE (appinfo);
273
274   return (* iface->get_description) (appinfo);
275 }
276
277 /**
278  * g_app_info_get_executable:
279  * @appinfo: a #GAppInfo
280  * 
281  * Gets the executable's name for the installed application.
282  *
283  * Returns: a string containing the @appinfo's application 
284  * binaries name
285  **/
286 const char *
287 g_app_info_get_executable (GAppInfo *appinfo)
288 {
289   GAppInfoIface *iface;
290   
291   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
292
293   iface = G_APP_INFO_GET_IFACE (appinfo);
294
295   return (* iface->get_executable) (appinfo);
296 }
297
298
299 /**
300  * g_app_info_get_commandline:
301  * @appinfo: a #GAppInfo
302  * 
303  * Gets the commandline with which the application will be
304  * started.  
305  *
306  * Returns: a string containing the @appinfo's commandline, 
307  *     or %NULL if this information is not available
308  *
309  * Since: 2.20
310  **/
311 const char *
312 g_app_info_get_commandline (GAppInfo *appinfo)
313 {
314   GAppInfoIface *iface;
315   
316   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
317
318   iface = G_APP_INFO_GET_IFACE (appinfo);
319
320   if (iface->get_commandline)
321     return (* iface->get_commandline) (appinfo);
322  
323   return NULL;
324 }
325
326 /**
327  * g_app_info_set_as_default_for_type:
328  * @appinfo: a #GAppInfo.
329  * @content_type: the content type.
330  * @error: a #GError.
331  * 
332  * Sets the application as the default handler for a given type.
333  *
334  * Returns: %TRUE on success, %FALSE on error.
335  **/
336 gboolean
337 g_app_info_set_as_default_for_type (GAppInfo    *appinfo,
338                                     const char  *content_type,
339                                     GError     **error)
340 {
341   GAppInfoIface *iface;
342   
343   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
344   g_return_val_if_fail (content_type != NULL, FALSE);
345
346   iface = G_APP_INFO_GET_IFACE (appinfo);
347
348   return (* iface->set_as_default_for_type) (appinfo, content_type, error);
349 }
350
351
352 /**
353  * g_app_info_set_as_default_for_extension:
354  * @appinfo: a #GAppInfo.
355  * @extension: a string containing the file extension (without the dot).
356  * @error: a #GError.
357  * 
358  * Sets the application as the default handler for the given file extension.
359  *
360  * Returns: %TRUE on success, %FALSE on error.
361  **/
362 gboolean
363 g_app_info_set_as_default_for_extension (GAppInfo    *appinfo,
364                                          const char  *extension,
365                                          GError     **error)
366 {
367   GAppInfoIface *iface;
368   
369   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
370   g_return_val_if_fail (extension != NULL, FALSE);
371
372   iface = G_APP_INFO_GET_IFACE (appinfo);
373
374   if (iface->set_as_default_for_extension)
375     return (* iface->set_as_default_for_extension) (appinfo, extension, error);
376
377   g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
378                        "g_app_info_set_as_default_for_extension not supported yet");
379   return FALSE;
380 }
381
382
383 /**
384  * g_app_info_add_supports_type:
385  * @appinfo: a #GAppInfo.
386  * @content_type: a string.
387  * @error: a #GError.
388  * 
389  * Adds a content type to the application information to indicate the 
390  * application is capable of opening files with the given content type.
391  *
392  * Returns: %TRUE on success, %FALSE on error.
393  **/
394 gboolean
395 g_app_info_add_supports_type (GAppInfo    *appinfo,
396                               const char  *content_type,
397                               GError     **error)
398 {
399   GAppInfoIface *iface;
400   
401   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
402   g_return_val_if_fail (content_type != NULL, FALSE);
403
404   iface = G_APP_INFO_GET_IFACE (appinfo);
405
406   if (iface->add_supports_type)
407     return (* iface->add_supports_type) (appinfo, content_type, error);
408
409   g_set_error_literal (error, G_IO_ERROR, 
410                        G_IO_ERROR_NOT_SUPPORTED, 
411                        "g_app_info_add_supports_type not supported yet");
412
413   return FALSE;
414 }
415
416
417 /**
418  * g_app_info_can_remove_supports_type:
419  * @appinfo: a #GAppInfo.
420  * 
421  * Checks if a supported content type can be removed from an application.
422  *
423  * Returns: %TRUE if it is possible to remove supported 
424  *     content types from a given @appinfo, %FALSE if not.
425  **/
426 gboolean
427 g_app_info_can_remove_supports_type (GAppInfo *appinfo)
428 {
429   GAppInfoIface *iface;
430   
431   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
432
433   iface = G_APP_INFO_GET_IFACE (appinfo);
434
435   if (iface->can_remove_supports_type)
436     return (* iface->can_remove_supports_type) (appinfo);
437
438   return FALSE;
439 }
440
441
442 /**
443  * g_app_info_remove_supports_type:
444  * @appinfo: a #GAppInfo.
445  * @content_type: a string.
446  * @error: a #GError.
447  *
448  * Removes a supported type from an application, if possible.
449  * 
450  * Returns: %TRUE on success, %FALSE on error.
451  **/
452 gboolean
453 g_app_info_remove_supports_type (GAppInfo    *appinfo,
454                                  const char  *content_type,
455                                  GError     **error)
456 {
457   GAppInfoIface *iface;
458   
459   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
460   g_return_val_if_fail (content_type != NULL, FALSE);
461
462   iface = G_APP_INFO_GET_IFACE (appinfo);
463
464   if (iface->remove_supports_type)
465     return (* iface->remove_supports_type) (appinfo, content_type, error);
466
467   g_set_error_literal (error, G_IO_ERROR, 
468                        G_IO_ERROR_NOT_SUPPORTED, 
469                        "g_app_info_remove_supports_type not supported yet");
470
471   return FALSE;
472 }
473
474
475 /**
476  * g_app_info_get_icon:
477  * @appinfo: a #GAppInfo.
478  * 
479  * Gets the icon for the application.
480  *
481  * Returns: the default #GIcon for @appinfo.
482  **/
483 GIcon *
484 g_app_info_get_icon (GAppInfo *appinfo)
485 {
486   GAppInfoIface *iface;
487   
488   g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
489
490   iface = G_APP_INFO_GET_IFACE (appinfo);
491
492   return (* iface->get_icon) (appinfo);
493 }
494
495
496 /**
497  * g_app_info_launch:
498  * @appinfo: a #GAppInfo
499  * @files: a #GList of #GFile objects
500  * @launch_context: a #GAppLaunchContext or %NULL
501  * @error: a #GError
502  * 
503  * Launches the application. Passes @files to the launched application 
504  * as arguments, using the optional @launch_context to get information
505  * about the details of the launcher (like what screen it is on).
506  * On error, @error will be set accordingly.
507  *
508  * To lauch the application without arguments pass a %NULL @files list.
509  *
510  * Note that even if the launch is successful the application launched
511  * can fail to start if it runs into problems during startup. There is
512  * no way to detect this.
513  *
514  * Some URIs can be changed when passed through a GFile (for instance
515  * unsupported uris with strange formats like mailto:), so if you have
516  * a textual uri you want to pass in as argument, consider using
517  * g_app_info_launch_uris() instead.
518  * 
519  * Returns: %TRUE on successful launch, %FALSE otherwise. 
520  **/
521 gboolean
522 g_app_info_launch (GAppInfo           *appinfo,
523                    GList              *files,
524                    GAppLaunchContext  *launch_context,
525                    GError            **error)
526 {
527   GAppInfoIface *iface;
528   
529   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
530
531   iface = G_APP_INFO_GET_IFACE (appinfo);
532
533   return (* iface->launch) (appinfo, files, launch_context, error);
534 }
535
536
537 /**
538  * g_app_info_supports_uris:
539  * @appinfo: a #GAppInfo.
540  * 
541  * Checks if the application supports reading files and directories from URIs.
542  *
543  * Returns: %TRUE if the @appinfo supports URIs.
544  **/
545 gboolean
546 g_app_info_supports_uris (GAppInfo *appinfo)
547 {
548   GAppInfoIface *iface;
549   
550   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
551
552   iface = G_APP_INFO_GET_IFACE (appinfo);
553
554   return (* iface->supports_uris) (appinfo);
555 }
556
557
558 /**
559  * g_app_info_supports_files:
560  * @appinfo: a #GAppInfo.
561  * 
562  * Checks if the application accepts files as arguments.
563  *
564  * Returns: %TRUE if the @appinfo supports files.
565  **/
566 gboolean
567 g_app_info_supports_files (GAppInfo *appinfo)
568 {
569   GAppInfoIface *iface;
570   
571   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
572
573   iface = G_APP_INFO_GET_IFACE (appinfo);
574
575   return (* iface->supports_files) (appinfo);
576 }
577
578
579 /**
580  * g_app_info_launch_uris:
581  * @appinfo: a #GAppInfo
582  * @uris: a #GList containing URIs to launch. 
583  * @launch_context: a #GAppLaunchContext or %NULL
584  * @error: a #GError
585  * 
586  * Launches the application. Passes @uris to the launched application 
587  * as arguments, using the optional @launch_context to get information
588  * about the details of the launcher (like what screen it is on).
589  * On error, @error will be set accordingly.
590  *
591  * To lauch the application without arguments pass a %NULL @uris list.
592  *
593  * Note that even if the launch is successful the application launched
594  * can fail to start if it runs into problems during startup. There is
595  * no way to detect this.
596  *
597  * Returns: %TRUE on successful launch, %FALSE otherwise. 
598  **/
599 gboolean
600 g_app_info_launch_uris (GAppInfo           *appinfo,
601                         GList              *uris,
602                         GAppLaunchContext  *launch_context,
603                         GError            **error)
604 {
605   GAppInfoIface *iface;
606   
607   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
608
609   iface = G_APP_INFO_GET_IFACE (appinfo);
610
611   return (* iface->launch_uris) (appinfo, uris, launch_context, error);
612 }
613
614
615 /**
616  * g_app_info_should_show:
617  * @appinfo: a #GAppInfo.
618  *
619  * Checks if the application info should be shown in menus that 
620  * list available applications.
621  * 
622  * Returns: %TRUE if the @appinfo should be shown, %FALSE otherwise.
623  **/
624 gboolean
625 g_app_info_should_show (GAppInfo *appinfo)
626 {
627   GAppInfoIface *iface;
628   
629   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
630
631   iface = G_APP_INFO_GET_IFACE (appinfo);
632
633   return (* iface->should_show) (appinfo);
634 }
635
636 /**
637  * g_app_info_launch_default_for_uri:
638  * @uri: the uri to show
639  * @launch_context: an optional #GAppLaunchContext.
640  * @error: a #GError.
641  *
642  * Utility function that launches the default application 
643  * registered to handle the specified uri. Synchronous I/O
644  * is done on the uri to detect the type of the file if
645  * required.
646  * 
647  * Returns: %TRUE on success, %FALSE on error.
648  **/
649 gboolean
650 g_app_info_launch_default_for_uri (const char         *uri,
651                                    GAppLaunchContext  *launch_context,
652                                    GError            **error)
653 {
654   GAppInfo *app_info;
655   GFile *file;
656   GList l;
657   gboolean res;
658
659   file = g_file_new_for_uri (uri);
660   app_info = g_file_query_default_handler (file, NULL, error);
661   g_object_unref (file);
662   if (app_info == NULL)
663     return FALSE;
664
665   /* Use the uri, not the GFile, as the GFile roundtrip may
666    * affect the uri which we don't want (for instance for a
667    * mailto: uri).
668    */
669   l.data = (char *)uri;
670   l.next = l.prev = NULL;
671   res = g_app_info_launch_uris (app_info, &l,
672                                 launch_context, error);
673
674   g_object_unref (app_info);
675   
676   return res;
677 }
678
679 /**
680  * g_app_info_can_delete:
681  * @appinfo: a #GAppInfo
682  *
683  * Obtains the information whether the #GAppInfo can be deleted.
684  * See g_app_info_delete().
685  *
686  * Returns: %TRUE if @appinfo can be deleted
687  *
688  * Since: 2.20
689  */
690 gboolean
691 g_app_info_can_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->can_delete)
700     return (* iface->can_delete) (appinfo);
701  
702   return FALSE; 
703 }
704
705
706 /**
707  * g_app_info_delete:
708  * @appinfo: a #GAppInfo
709  *
710  * Tries to delete a #GAppInfo.
711  *
712  * On some platforms, there may be a difference between user-defined
713  * #GAppInfo<!-- -->s which can be deleted, and system-wide ones which
714  * cannot. See g_app_info_can_delete().
715  * 
716  * Returns: %TRUE if @appinfo has been deleted
717  *
718  * Since: 2.20
719  */
720 gboolean
721 g_app_info_delete (GAppInfo *appinfo)
722 {
723   GAppInfoIface *iface;
724   
725   g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE);
726
727   iface = G_APP_INFO_GET_IFACE (appinfo);
728
729   if (iface->do_delete)
730     return (* iface->do_delete) (appinfo);
731  
732   return FALSE; 
733 }
734
735
736 G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
737
738 /**
739  * g_app_launch_context_new:
740  * 
741  * Creates a new application launch context. This is not normally used,
742  * instead you instantiate a subclass of this, such as #GdkAppLaunchContext.
743  *
744  * Returns: a #GAppLaunchContext.
745  **/
746 GAppLaunchContext *
747 g_app_launch_context_new (void)
748 {
749   return g_object_new (G_TYPE_APP_LAUNCH_CONTEXT, NULL);
750 }
751
752 static void
753 g_app_launch_context_class_init (GAppLaunchContextClass *klass)
754 {
755 }
756
757 static void
758 g_app_launch_context_init (GAppLaunchContext *launch_context)
759 {
760 }
761
762 /**
763  * g_app_launch_context_get_display:
764  * @context: a #GAppLaunchContext
765  * @info: a #GAppInfo
766  * @files: a #GList of #GFile objects
767  *
768  * Gets the display string for the display. This is used to ensure new
769  * applications are started on the same display as the launching 
770  * application.
771  * 
772  * Returns: a display string for the display.
773  **/
774 char *
775 g_app_launch_context_get_display (GAppLaunchContext *context,
776                                   GAppInfo          *info,
777                                   GList             *files)
778 {
779   GAppLaunchContextClass *class;
780
781   g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
782   g_return_val_if_fail (G_IS_APP_INFO (info), NULL);
783
784   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
785
786   if (class->get_display == NULL)
787     return NULL;
788
789   return class->get_display (context, info, files);
790 }
791
792 /**
793  * g_app_launch_context_get_startup_notify_id:
794  * @context: a #GAppLaunchContext
795  * @info: a #GAppInfo
796  * @files: a #GList of of #GFile objects
797  * 
798  * Initiates startup notification for the application and returns the
799  * DESKTOP_STARTUP_ID for the launched operation, if supported.
800  *
801  * Startup notification IDs are defined in the <ulink
802  * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">
803  * FreeDesktop.Org Startup Notifications standard</ulink>.
804  *
805  * Returns: a startup notification ID for the application, or %NULL if 
806  *     not supported.
807  **/
808 char *
809 g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
810                                             GAppInfo          *info,
811                                             GList             *files)
812 {
813   GAppLaunchContextClass *class;
814
815   g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
816   g_return_val_if_fail (G_IS_APP_INFO (info), NULL);
817
818   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
819
820   if (class->get_startup_notify_id == NULL)
821     return NULL;
822
823   return class->get_startup_notify_id (context, info, files);
824 }
825
826
827 /**
828  * g_app_launch_context_launch_failed:
829  * @context: a #GAppLaunchContext.
830  * @startup_notify_id: the startup notification id that was returned by g_app_launch_context_get_startup_notify_id().
831  *
832  * Called when an application has failed to launch, so that it can cancel
833  * the application startup notification started in g_app_launch_context_get_startup_notify_id().
834  * 
835  **/
836 void
837 g_app_launch_context_launch_failed (GAppLaunchContext *context,
838                                     const char        *startup_notify_id)
839 {
840   GAppLaunchContextClass *class;
841
842   g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
843   g_return_if_fail (startup_notify_id != NULL);
844
845   class = G_APP_LAUNCH_CONTEXT_GET_CLASS (context);
846
847   if (class->launch_failed != NULL)
848     class->launch_failed (context, startup_notify_id);
849 }
850
851
852 #define __G_APP_INFO_C__
853 #include "gioaliasdef.c"