2 * GTK - The GIMP Toolkit
3 * Copyright (C) 2008 Jaap Haitsma <jaap@haitsma.org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
29 * @screen: (allow-none): screen to show the uri on
30 * or %NULL for the default screen
31 * @uri: the uri to show
32 * @timestamp: a timestamp to prevent focus stealing
33 * @error: a #GError that is returned in case of errors
35 * This is a convenience function for launching the default application
36 * to show the uri. The uri must be of a form understood by GIO (i.e. you
37 * need to install gvfs to get support for uri schemes such as http://
38 * or ftp://, as only local files are handled by GIO itself).
39 * Typical examples are
41 * <member><filename>file:///home/gnome/pict.jpg</filename></member>
42 * <member><filename>http://www.gnome.org</filename></member>
43 * <member><filename>mailto:me@gnome.org</filename></member>
45 * Ideally the timestamp is taken from the event triggering
46 * the gtk_show_uri() call. If timestamp is not known you can take
49 * This function can be used as a replacement for gnome_vfs_url_show()
50 * and gnome_url_show().
52 * Returns: %TRUE on success, %FALSE on error
57 gtk_show_uri (GdkScreen *screen,
62 GdkAppLaunchContext *context;
66 g_return_val_if_fail (uri != NULL, FALSE);
69 display = gdk_screen_get_display (screen);
71 display = gdk_display_get_default ();
73 context = gdk_display_get_app_launch_context (display);
74 gdk_app_launch_context_set_screen (context, screen);
75 gdk_app_launch_context_set_timestamp (context, timestamp);
77 ret = g_app_info_launch_default_for_uri (uri, (GAppLaunchContext*)context, error);
78 g_object_unref (context);