]> Pileus Git - ~andy/gtk/blob - gdk/gdkapplaunchcontext.c
Remove unneeded includes. (#505411, Kazuki IWAMOTO)
[~andy/gtk] / gdk / gdkapplaunchcontext.c
1 /* gdkapplaunchcontext.c - Gtk+ implementation for GAppLaunchContext
2
3    Copyright (C) 2007 Red Hat, Inc.
4
5    The Gnome Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    The Gnome 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    Library General Public License for more details.
14
15    You should have received a copy of the GNU Library General Public
16    License along with the Gnome Library; see the file COPYING.LIB.  If not,
17    write to the 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
25 #include <glib.h>
26
27 #include "gdkapplaunchcontext.h"
28 #include "gdkinternals.h"
29 #include "gdkscreen.h"
30 #include "gdkintl.h"
31 #include "gdkalias.h"
32
33
34 G_DEFINE_TYPE (GdkAppLaunchContext, gdk_app_launch_context,
35                G_TYPE_APP_LAUNCH_CONTEXT);
36
37 static void
38 gdk_app_launch_context_finalize (GObject *object)
39 {
40   GdkAppLaunchContext *context;
41   GdkAppLaunchContextPrivate *priv;
42
43   context = GDK_APP_LAUNCH_CONTEXT (object);
44
45   priv = context->priv;
46
47   if (priv->display)
48     g_object_unref (priv->display);
49
50   if (priv->screen)
51     g_object_unref (priv->screen);
52
53   if (priv->icon)
54     g_object_unref (priv->icon);
55
56   g_free (priv->icon_name);
57
58   (*G_OBJECT_CLASS (gdk_app_launch_context_parent_class)->finalize) (object);
59 }
60
61 static char *
62 get_display (GAppLaunchContext *context, 
63              GAppInfo          *info, 
64              GList             *files)
65 {
66   GdkDisplay *display;
67   GdkAppLaunchContextPrivate *priv;
68
69   priv = GDK_APP_LAUNCH_CONTEXT (context)->priv;
70
71   if (priv->screen)
72     return gdk_screen_make_display_name (priv->screen);
73
74   if (priv->display)
75     display = priv->display;
76   else
77     display = gdk_display_get_default ();
78
79   return g_strdup (gdk_display_get_name (display));
80 }
81
82 static void
83 gdk_app_launch_context_class_init (GdkAppLaunchContextClass *klass)
84 {
85   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
86   GAppLaunchContextClass *context_class = G_APP_LAUNCH_CONTEXT_CLASS (klass);
87
88   gobject_class->finalize = gdk_app_launch_context_finalize;
89
90   context_class->get_display = get_display;
91   context_class->get_startup_notify_id = _gdk_windowing_get_startup_notify_id;
92   context_class->launch_failed = _gdk_windowing_launch_failed;
93
94   g_type_class_add_private (klass, sizeof (GdkAppLaunchContextPrivate));
95 }
96
97 static void
98 gdk_app_launch_context_init (GdkAppLaunchContext *context)
99 {
100   context->priv = G_TYPE_INSTANCE_GET_PRIVATE (context,
101                                                GDK_TYPE_APP_LAUNCH_CONTEXT,
102                                                GdkAppLaunchContextPrivate);
103   context->priv->workspace = -1;
104 }
105
106 /**
107  * gdk_app_launch_context_set_display:
108  * @context: a #GdkAppLaunchContext
109  * @display: a #GdkDisplay
110  *
111  * Sets the display on which applications will be launched when
112  * using this context. See also gdk_app_launch_context_set_screen().
113  *
114  * Since: 2.16
115  */
116 void
117 gdk_app_launch_context_set_display (GdkAppLaunchContext *context,
118                                     GdkDisplay          *display)
119 {
120   if (context->priv->display)
121     {
122       g_object_unref (context->priv->display);
123       context->priv->display = NULL;
124     }
125
126   if (display)
127     context->priv->display = g_object_ref (display);
128 }
129
130 /**
131  * gdk_app_launch_context_set_screen:
132  * @context: a #GdkAppLaunchContext
133  * @screen: a #GdkScreen
134  *
135  * Sets the screen on which applications will be launched when
136  * using this context. See also gdk_app_launch_context_set_display().
137  * If both @screen and @display are set, the @screen takes priority.
138  *
139  * Since: 2.16
140  */
141 void
142 gdk_app_launch_context_set_screen (GdkAppLaunchContext *context,
143                                    GdkScreen           *screen)
144 {
145   if (context->priv->screen)
146     {
147       g_object_unref (context->priv->screen);
148       context->priv->screen = NULL;
149     }
150
151   if (screen)
152     context->priv->screen = g_object_ref (screen);
153 }
154
155 /**
156  * gdk_app_launch_context_set_desktop:
157  * @context: a #GdkAppLaunchContext
158  * @desktop: the number of a workspace, or -1
159  *
160  * Sets the workspace on which applications will be launched when
161  * using this context when running under a window manager that 
162  * supports multiple workspaces, as described in the 
163  * <ulink url="http://www.freedesktop.org/Standards/wm-spec">Extended 
164  * Window Manager Hints</ulink>. 
165  *
166  * Since: 2.16
167  */
168 void
169 gdk_app_launch_context_set_desktop (GdkAppLaunchContext *context,
170                                     gint                 desktop)
171 {
172   context->priv->workspace = desktop;
173 }
174
175 /**
176  * gdk_app_launch_context_set_timestamp:
177  * @context: a #GdkAppLaunchContext
178  * @timestamp: a timestamp
179  *
180  * Sets the timestamp of @context. The timestamp should ideally
181  * be taken from the event that triggered the launch.
182  *
183  * Since: 2.16
184  */
185 void
186 gdk_app_launch_context_set_timestamp (GdkAppLaunchContext *context,
187                                       guint32              timestamp)
188 {
189   context->priv->timestamp = timestamp;
190 }
191
192 /**
193  * gdk_app_launch_context_set_icon:
194  * @context: a #GdkAppLaunchContext
195  * @icon: a #GIcon, or %NULL
196  *
197  * Sets the icon for applications that are launched with this
198  * context. See also gdk_app_launch_context_set_icon_name().
199  *
200  * Since: 2.16
201  */
202 void
203 gdk_app_launch_context_set_icon (GdkAppLaunchContext *context, 
204                                  GIcon               *icon)
205 {
206   if (context->priv->icon)
207     {
208       g_object_unref (context->priv->icon);
209       context->priv->icon = NULL;
210     }
211
212   if (icon)
213     context->priv->icon = g_object_ref (icon);
214 }
215
216 /**
217  * gdk_app_launch_context_set_icon_name:
218  * @context: a #GdkAppLaunchContext
219  * @icon_name: an icon name, or %NULL
220  *
221  * Sets the icon for applications that are launched with this
222  * context. The @icon_name will be interpreted in the same way 
223  * as the Icon field in desktop files. 
224  * See also gdk_app_launch_context_set_icon(). If both @icon 
225  * and @icon_name are set, the @icon_name takes priority.
226  * 
227  * Since: 2.16
228  */
229 void
230 gdk_app_launch_context_set_icon_name (GdkAppLaunchContext *context,
231                                       const char          *icon_name)
232 {
233   g_free (context->priv->icon_name);
234   context->priv->icon_name = g_strdup (icon_name);
235 }
236
237 /**
238  * gdk_app_launch_context_new:
239  *
240  * Creates a new #GdkAppLaunchContext.
241  *
242  * Returns: a new #GdkAppLaunchContext
243  *
244  * Since: 2.16
245  */
246 GdkAppLaunchContext *
247 gdk_app_launch_context_new (void)
248 {
249   GdkAppLaunchContext *context;
250
251   context = g_object_new (gdk_app_launch_context_get_type (), NULL);
252
253   return context;
254 }
255
256
257 #define __GDK_APP_LAUNCH_CONTEXT_C__
258 #include "gdkaliasdef.c"