diff options
author | Matthias Clasen <mclasen@redhat.com> | 2007-12-13 05:16:33 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2007-12-13 05:16:33 +0000 |
commit | 1397a9fd7d6771cbf07f62409e46ae03e29a407c (patch) | |
tree | 17df1a5c99654026f089497fbf5ab115037fbc56 /gdk/gdkapplaunchcontext.c | |
parent | 594e3660e9c0ad8b34b6c5103a3fd6fd091b629a (diff) | |
download | gtk+-1397a9fd7d6771cbf07f62409e46ae03e29a407c.tar.gz |
Implement GAppLaunchContext in gdk, providing startup notification.
2007-12-12 Matthias Clasen <mclasen@redhat.com>
* gdk/gdkapplaunchcontext.[hc]: Implement GAppLaunchContext
in gdk, providing startup notification. (#503203)
* gdk/x11/gdkapplaunchcontext-x11.c:
* gdk/win32/gdkapplaunchcontext-win32.c:
* gdk/quartz/gdkapplaunchcontext-quartz.c:
* gdk/directfb/gdkapplaunchcontext-directfb.c: Backend-specific
parts. All but X11 are just empty stubs for now.
* gdk/gdk.symbols:
* gdk/gdkinternals.h:
* gdk/Makefile.am:
* gdk/x11/Makefile.am:
* gdk/win32/Makefile.am:
* gdk/quartz/Makefile.am:
* gdk/directfb/Makefile.am: Necessary glue.
svn path=/trunk/; revision=19165
Diffstat (limited to 'gdk/gdkapplaunchcontext.c')
-rw-r--r-- | gdk/gdkapplaunchcontext.c | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/gdk/gdkapplaunchcontext.c b/gdk/gdkapplaunchcontext.c new file mode 100644 index 0000000000..d63a2fc524 --- /dev/null +++ b/gdk/gdkapplaunchcontext.c @@ -0,0 +1,186 @@ +/* gdkapplaunchcontext.c - Gtk+ implementation for GAppLaunchContext + + Copyright (C) 2007 Red Hat, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#include <config.h> + +#include <string.h> +#include <unistd.h> + +#include <glib.h> +#include <gio/gfileicon.h> +#include <gio/gthemedicon.h> + +#include "gdkapplaunchcontext.h" +#include "gdkinternals.h" +#include "gdkscreen.h" +#include "gdkintl.h" +#include "gdkalias.h" + + +G_DEFINE_TYPE (GdkAppLaunchContext, gdk_app_launch_context, + G_TYPE_APP_LAUNCH_CONTEXT); + +static void +gdk_app_launch_context_finalize (GObject *object) +{ + GdkAppLaunchContext *context; + GdkAppLaunchContextPrivate *priv; + + context = GDK_APP_LAUNCH_CONTEXT (object); + + priv = context->priv; + + if (priv->display) + g_object_unref (priv->display); + + if (priv->screen) + g_object_unref (priv->screen); + + if (priv->icon) + g_object_unref (priv->icon); + + g_free (priv->icon_name); + + (*G_OBJECT_CLASS (gdk_app_launch_context_parent_class)->finalize) (object); +} + +static char * +get_display (GAppLaunchContext *context, + GAppInfo *info, + GList *files) +{ + GdkDisplay *display; + GdkAppLaunchContextPrivate *priv; + + priv = GDK_APP_LAUNCH_CONTEXT (context)->priv; + + if (priv->screen) + return gdk_screen_make_display_name (priv->screen); + + if (priv->display) + display = priv->display; + else + display = gdk_display_get_default (); + + return g_strdup (gdk_display_get_name (display)); +} + +static void +gdk_app_launch_context_class_init (GdkAppLaunchContextClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GAppLaunchContextClass *context_class = G_APP_LAUNCH_CONTEXT_CLASS (klass); + + gobject_class->finalize = gdk_app_launch_context_finalize; + + context_class->get_display = get_display; + context_class->get_startup_notify_id = _gdk_windowing_get_startup_notify_id; + context_class->launch_failed = _gdk_windowing_launch_failed; + + g_type_class_add_private (klass, sizeof (GdkAppLaunchContextPrivate)); +} + +static void +gdk_app_launch_context_init (GdkAppLaunchContext *context) +{ + context->priv = G_TYPE_INSTANCE_GET_PRIVATE (context, + GDK_TYPE_APP_LAUNCH_CONTEXT, + GdkAppLaunchContextPrivate); + context->priv->workspace = -1; +} + +void +gdk_app_launch_context_set_display (GdkAppLaunchContext *context, + GdkDisplay *display) +{ + if (context->priv->display) + { + g_object_unref (context->priv->display); + context->priv->display = NULL; + } + + if (display) + context->priv->display = g_object_ref (display); +} +void +gdk_app_launch_context_set_screen (GdkAppLaunchContext *context, + GdkScreen *screen) +{ + if (context->priv->screen) + { + g_object_unref (context->priv->screen); + context->priv->screen = NULL; + } + + if (screen) + context->priv->screen = g_object_ref (screen); +} + + +void +gdk_app_launch_context_set_desktop (GdkAppLaunchContext *context, + gint desktop) +{ + context->priv->workspace = desktop; +} + +void +gdk_app_launch_context_set_timestamp (GdkAppLaunchContext *context, + guint32 timestamp) +{ + context->priv->timestamp = timestamp; +} + +void +gdk_app_launch_context_set_icon (GdkAppLaunchContext *context, + GIcon *icon) +{ + if (context->priv->icon) + { + g_object_unref (context->priv->icon); + context->priv->icon = NULL; + } + + if (icon) + context->priv->icon = g_object_ref (icon); +} + +void +gdk_app_launch_context_set_icon_name (GdkAppLaunchContext *context, + const char *icon_name) +{ + g_free (context->priv->icon_name); + context->priv->icon_name = g_strdup (icon_name); +} + +GdkAppLaunchContext * +gdk_app_launch_context_new (void) +{ + GdkAppLaunchContext *context; + + context = g_object_new (gdk_app_launch_context_get_type (), NULL); + return context; +} + + +#define __GDK_APP_LAUNCH_CONTEXT_C__ +#include "gdkaliasdef.c" |