]> Pileus Git - ~andy/gtk/blob - gtk/gtkshow.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkshow.c
1 /*
2  * GTK - The GIMP Toolkit
3  * Copyright (C) 2008  Jaap Haitsma <jaap@haitsma.org>
4  *
5  * All rights reserved.
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
21 #include "config.h"
22
23 #include <gdk/gdk.h>
24
25 #include "gtkshow.h"
26
27 /**
28  * gtk_show_uri:
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
34  *
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
40  * <simplelist>
41  *   <member><filename>file:///home/gnome/pict.jpg</filename></member>
42  *   <member><filename>http://www.gnome.org</filename></member>
43  *   <member><filename>mailto:me&commat;gnome.org</filename></member>
44  * </simplelist>
45  * Ideally the timestamp is taken from the event triggering
46  * the gtk_show_uri() call. If timestamp is not known you can take
47  * %GDK_CURRENT_TIME.
48  *
49  * This function can be used as a replacement for gnome_vfs_url_show()
50  * and gnome_url_show().
51  *
52  * Returns: %TRUE on success, %FALSE on error
53  *
54  * Since: 2.14
55  */
56 gboolean
57 gtk_show_uri (GdkScreen    *screen,
58               const gchar  *uri,
59               guint32       timestamp,
60               GError      **error)
61 {
62   GdkAppLaunchContext *context;
63   gboolean ret;
64   GdkDisplay *display;
65
66   g_return_val_if_fail (uri != NULL, FALSE);
67
68   if (screen != NULL)
69     display = gdk_screen_get_display (screen);
70   else
71     display = gdk_display_get_default ();
72
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);
76
77   ret = g_app_info_launch_default_for_uri (uri, (GAppLaunchContext*)context, error);
78   g_object_unref (context);
79
80   return ret;
81 }