[gtk+/xi2: 508/1239] Hrm, actually add GtkDeviceGroup.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2: 508/1239] Hrm, actually add GtkDeviceGroup.
- Date: Tue, 29 Sep 2009 10:48:10 +0000 (UTC)
commit 3b80538ac08539e3cf7a9b71e722d393a5987036
Author: Carlos Garnacho <carlos lanedo com>
Date: Fri Jul 10 18:58:08 2009 +0100
Hrm, actually add GtkDeviceGroup.
gtk/gtkdevicegroup.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkdevicegroup.h | 71 ++++++++++++++++++++++++
2 files changed, 220 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkdevicegroup.c b/gtk/gtkdevicegroup.c
new file mode 100644
index 0000000..0f4b531
--- /dev/null
+++ b/gtk/gtkdevicegroup.c
@@ -0,0 +1,149 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2009 Carlos Garnacho <carlosg gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "gtkintl.h"
+#include "gtkdevicegroup.h"
+
+typedef struct GtkDeviceGroupPrivate GtkDeviceGroupPrivate;
+
+struct GtkDeviceGroupPrivate
+{
+ GList *devices;
+};
+
+#define GTK_DEVICE_GROUP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_DEVICE_GROUP, GtkDeviceGroupPrivate))
+
+static void gtk_device_group_class_init (GtkDeviceGroupClass *klass);
+static void gtk_device_group_init (GtkDeviceGroup *group);
+
+static void gtk_device_group_finalize (GObject *object);
+
+enum {
+ DEVICE_ADDED,
+ DEVICE_REMOVED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (GtkDeviceGroup, gtk_device_group, G_TYPE_OBJECT)
+
+
+static void
+gtk_device_group_class_init (GtkDeviceGroupClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gtk_device_group_finalize;
+
+ signals[DEVICE_ADDED] =
+ g_signal_new (I_("device-added"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkDeviceGroupClass, device_added),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GDK_TYPE_DEVICE);
+ signals[DEVICE_REMOVED] =
+ g_signal_new (I_("device-removed"),
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkDeviceGroupClass, device_removed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GDK_TYPE_DEVICE);
+
+ g_type_class_add_private (object_class, sizeof (GtkDeviceGroupPrivate));
+}
+
+static void
+gtk_device_group_init (GtkDeviceGroup *group)
+{
+}
+
+static void
+gtk_device_group_finalize (GObject *object)
+{
+ GtkDeviceGroupPrivate *priv;
+
+ priv = GTK_DEVICE_GROUP_GET_PRIVATE (object);
+
+ g_list_foreach (priv->devices, (GFunc) g_object_unref, NULL);
+ g_list_free (priv->devices);
+
+ G_OBJECT_CLASS (gtk_device_group_parent_class)->finalize (object);
+}
+
+void
+gtk_device_group_add_device (GtkDeviceGroup *group,
+ GdkDevice *device)
+{
+ GtkDeviceGroupPrivate *priv;
+
+ g_return_if_fail (GTK_IS_DEVICE_GROUP (group));
+ g_return_if_fail (GDK_IS_DEVICE (device));
+
+ priv = GTK_DEVICE_GROUP_GET_PRIVATE (group);
+
+ if (g_list_find (priv->devices, device))
+ return;
+
+ priv->devices = g_list_prepend (priv->devices,
+ g_object_ref (device));
+
+ g_signal_emit (group, signals[DEVICE_ADDED], 0, device);
+}
+
+void
+gtk_device_group_remove_device (GtkDeviceGroup *group,
+ GdkDevice *device)
+{
+ GtkDeviceGroupPrivate *priv;
+ GList *dev;
+
+ g_return_if_fail (GTK_IS_DEVICE_GROUP (group));
+ g_return_if_fail (GDK_IS_DEVICE (device));
+
+ priv = GTK_DEVICE_GROUP_GET_PRIVATE (group);
+
+ dev = g_list_find (priv->devices, device);
+
+ if (!dev)
+ return;
+
+ priv->devices = g_list_remove_link (priv->devices, dev);
+
+ g_signal_emit (group, signals[DEVICE_REMOVED], 0, device);
+
+ g_object_unref (dev->data);
+ g_list_free_1 (dev);
+}
+
+GList *
+gtk_device_group_get_devices (GtkDeviceGroup *group)
+{
+ GtkDeviceGroupPrivate *priv;
+
+ g_return_val_if_fail (GTK_IS_DEVICE_GROUP (group), NULL);
+
+ priv = GTK_DEVICE_GROUP_GET_PRIVATE (group);
+
+ return priv->devices;
+}
diff --git a/gtk/gtkdevicegroup.h b/gtk/gtkdevicegroup.h
new file mode 100644
index 0000000..1ccbcee
--- /dev/null
+++ b/gtk/gtkdevicegroup.h
@@ -0,0 +1,71 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2009 Carlos Garnacho <carlosg gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#ifndef __GTK_DEVICE_GROUP_H__
+#define __GTK_DEVICE_GROUP_H__
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+typedef struct GtkDeviceGroup GtkPointerGroup;
+
+#define GTK_TYPE_DEVICE_GROUP (gtk_device_group_get_type ())
+#define GTK_DEVICE_GROUP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_DEVICE_GROUP, GtkDeviceGroup))
+#define GTK_DEVICE_GROUP_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_DEVICE_GROUP, GtkDeviceGroupClass))
+#define GTK_IS_DEVICE_GROUP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_DEVICE_GROUP))
+#define GTK_IS_DEVICE_GROUP_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_DEVICE_GROUP))
+#define GTK_DEVICE_GROUP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_DEVICE_GROUP, GtkDeviceGroupClass))
+
+typedef struct GtkDeviceGroup GtkDeviceGroup;
+typedef struct GtkDeviceGroupClass GtkDeviceGroupClass;
+
+struct GtkDeviceGroup
+{
+ GObject parent_instance;
+};
+
+struct GtkDeviceGroupClass
+{
+ GObjectClass parent_class;
+
+ void (* device_added) (GtkDeviceGroup *group,
+ GdkDevice *device);
+ void (* device_removed) (GtkDeviceGroup *group,
+ GdkDevice *device);
+};
+
+GType gtk_device_group_get_type (void) G_GNUC_CONST;
+
+void gtk_device_group_add_device (GtkDeviceGroup *group,
+ GdkDevice *device);
+
+void gtk_device_group_remove_device (GtkDeviceGroup *group,
+ GdkDevice *device);
+
+GList * gtk_device_group_get_devices (GtkDeviceGroup *group);
+
+
+G_END_DECLS
+
+#endif /* __GTK_POINTER_GROUP_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]