1 /* gdkapplaunchcontext.c - Gtk+ implementation for GAppLaunchContext
3 Copyright (C) 2007 Red Hat, Inc.
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.
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.
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.
20 Author: Alexander Larsson <alexl@redhat.com>
27 #include "gdkapplaunchcontext.h"
28 #include "gdkinternals.h"
29 #include "gdkscreen.h"
34 G_DEFINE_TYPE (GdkAppLaunchContext, gdk_app_launch_context,
35 G_TYPE_APP_LAUNCH_CONTEXT);
38 gdk_app_launch_context_finalize (GObject *object)
40 GdkAppLaunchContext *context;
41 GdkAppLaunchContextPrivate *priv;
43 context = GDK_APP_LAUNCH_CONTEXT (object);
48 g_object_unref (priv->display);
51 g_object_unref (priv->screen);
54 g_object_unref (priv->icon);
56 g_free (priv->icon_name);
58 (*G_OBJECT_CLASS (gdk_app_launch_context_parent_class)->finalize) (object);
62 get_display (GAppLaunchContext *context,
67 GdkAppLaunchContextPrivate *priv;
69 priv = GDK_APP_LAUNCH_CONTEXT (context)->priv;
72 return gdk_screen_make_display_name (priv->screen);
75 display = priv->display;
77 display = gdk_display_get_default ();
79 return g_strdup (gdk_display_get_name (display));
83 gdk_app_launch_context_class_init (GdkAppLaunchContextClass *klass)
85 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
86 GAppLaunchContextClass *context_class = G_APP_LAUNCH_CONTEXT_CLASS (klass);
88 gobject_class->finalize = gdk_app_launch_context_finalize;
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;
94 g_type_class_add_private (klass, sizeof (GdkAppLaunchContextPrivate));
98 gdk_app_launch_context_init (GdkAppLaunchContext *context)
100 context->priv = G_TYPE_INSTANCE_GET_PRIVATE (context,
101 GDK_TYPE_APP_LAUNCH_CONTEXT,
102 GdkAppLaunchContextPrivate);
103 context->priv->workspace = -1;
107 * gdk_app_launch_context_set_display:
108 * @context: a #GdkAppLaunchContext
109 * @display: a #GdkDisplay
111 * Sets the display on which applications will be launched when
112 * using this context. See also gdk_app_launch_context_set_screen().
117 gdk_app_launch_context_set_display (GdkAppLaunchContext *context,
120 if (context->priv->display)
122 g_object_unref (context->priv->display);
123 context->priv->display = NULL;
127 context->priv->display = g_object_ref (display);
131 * gdk_app_launch_context_set_screen:
132 * @context: a #GdkAppLaunchContext
133 * @screen: a #GdkScreen
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.
142 gdk_app_launch_context_set_screen (GdkAppLaunchContext *context,
145 if (context->priv->screen)
147 g_object_unref (context->priv->screen);
148 context->priv->screen = NULL;
152 context->priv->screen = g_object_ref (screen);
156 * gdk_app_launch_context_set_desktop:
157 * @context: a #GdkAppLaunchContext
158 * @desktop: the number of a workspace, or -1
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>.
169 gdk_app_launch_context_set_desktop (GdkAppLaunchContext *context,
172 context->priv->workspace = desktop;
176 * gdk_app_launch_context_set_timestamp:
177 * @context: a #GdkAppLaunchContext
178 * @timestamp: a timestamp
180 * Sets the timestamp of @context. The timestamp should ideally
181 * be taken from the event that triggered the launch.
186 gdk_app_launch_context_set_timestamp (GdkAppLaunchContext *context,
189 context->priv->timestamp = timestamp;
193 * gdk_app_launch_context_set_icon:
194 * @context: a #GdkAppLaunchContext
195 * @icon: a #GIcon, or %NULL
197 * Sets the icon for applications that are launched with this
198 * context. See also gdk_app_launch_context_set_icon_name().
203 gdk_app_launch_context_set_icon (GdkAppLaunchContext *context,
206 if (context->priv->icon)
208 g_object_unref (context->priv->icon);
209 context->priv->icon = NULL;
213 context->priv->icon = g_object_ref (icon);
217 * gdk_app_launch_context_set_icon_name:
218 * @context: a #GdkAppLaunchContext
219 * @icon_name: an icon name, or %NULL
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.
230 gdk_app_launch_context_set_icon_name (GdkAppLaunchContext *context,
231 const char *icon_name)
233 g_free (context->priv->icon_name);
234 context->priv->icon_name = g_strdup (icon_name);
238 * gdk_app_launch_context_new:
240 * Creates a new #GdkAppLaunchContext.
242 * Returns: a new #GdkAppLaunchContext
246 GdkAppLaunchContext *
247 gdk_app_launch_context_new (void)
249 GdkAppLaunchContext *context;
251 context = g_object_new (gdk_app_launch_context_get_type (), NULL);
257 #define __GDK_APP_LAUNCH_CONTEXT_C__
258 #include "gdkaliasdef.c"