Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaul Gutierrez Segales <rgs@collabora.co.uk>2011-10-30 11:54:53 (GMT)
committer Sascha Silbe <silbe@activitycentral.com>2011-11-22 12:28:58 (GMT)
commit7d01f5927f1a862b07bb5b4eae95feccb198e594 (patch)
tree636a19df4771931b77221acc52b5c487acfca88e
parenta91983682a09ed5c631fb5bbb18b7fb14982b124 (diff)
Add GdkWrapper to access non-introspectable Gdk API
-rw-r--r--src/sugar3/Makefile.am10
-rw-r--r--src/sugar3/gdk-wrapper.c59
-rw-r--r--src/sugar3/gdk-wrapper.h36
-rw-r--r--src/sugar3/wm.py3
4 files changed, 105 insertions, 3 deletions
diff --git a/src/sugar3/Makefile.am b/src/sugar3/Makefile.am
index e0eb935..ca5abed 100644
--- a/src/sugar3/Makefile.am
+++ b/src/sugar3/Makefile.am
@@ -33,6 +33,8 @@ libsugarext_la_SOURCES = \
eggsmclient.h \
eggsmclient-private.h \
eggsmclient-xsmp.c \
+ gdk-wrapper.c \
+ gdk-wrapper.h \
gsm-app.c \
gsm-app.h \
gsm-client.c \
@@ -70,7 +72,8 @@ INTROSPECTION_GIRS = SugarExt-1.0.gir
INTROSPECTION_SCANNER_ARGS = --identifier-prefix=Sugar --symbol-prefix=sugar \
--identifier-prefix=EggSM --symbol-prefix=egg_sm \
--identifier-prefix=Gsm --symbol-prefix=gsm \
- --identifier-prefix=Acme --symbol-prefix=acme
+ --identifier-prefix=Acme --symbol-prefix=acme \
+ --identifier-prefix=GdkWrapper --symbol-prefix=gdk_wrapper
SugarExt_1_0_gir_LIBS = libsugarext.la
SugarExt_1_0_gir_FILES = \
acme-volume.c \
@@ -84,7 +87,10 @@ SugarExt_1_0_gir_FILES = \
gsm-xsmp.c \
gsm-xsmp.h \
sugar-key-grabber.c \
- sugar-key-grabber.h
+ sugar-key-grabber.h \
+ gdk-wrapper.c \
+ gdk-wrapper.h
+
SugarExt_1_0_gir_INCLUDES = Gtk-3.0 Gdk-3.0
SugarExt_1_0_gir_PACKAGES = gtk+-3.0 gdk-3.0
SugarExt_1_0_gir_EXPORT_PACKAGES = SugarExt-1.0
diff --git a/src/sugar3/gdk-wrapper.c b/src/sugar3/gdk-wrapper.c
new file mode 100644
index 0000000..f5d9fd6
--- /dev/null
+++ b/src/sugar3/gdk-wrapper.c
@@ -0,0 +1,59 @@
+/* gdk-wrapper.c
+ *
+ * Copyright (C) 1995-2007 Peter Mattis, Spencer Kimball,
+ * Josh MacDonald, Ryan Lortie
+ * Copyright (C) 2011 Raul Gutierrez Segales
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+/* Work around introspection unfriendly API in gdk */
+
+#include "gdk-wrapper.h"
+#include <string.h>
+
+/**
+ * gdk_wrapper_property_change:
+ * @window: a #GdkWindow
+ * @property: the property to change
+ * @type: the new type for the property. If @mode is
+ * %GDK_PROP_MODE_PREPEND or %GDK_PROP_MODE_APPEND, then this
+ * must match the existing type or an error will occur.
+ * @format: the new format for the property. If @mode is
+ * %GDK_PROP_MODE_PREPEND or %GDK_PROP_MODE_APPEND, then this
+ * must match the existing format or an error will occur.
+ * @mode: a value describing how the new data is to be combined
+ * with the current data.
+ * @data: the data (a <literal>gchar *</literal>)
+ *
+ * Changes the contents of a property on a window.
+ */
+void
+gdk_wrapper_property_change (GdkWindow *window,
+ const gchar *property,
+ const gchar *type,
+ gint format,
+ GdkPropMode mode,
+ const gchar *data)
+{
+ GdkAtom property_a = gdk_atom_intern (property, FALSE);
+ GdkAtom type_a = gdk_atom_intern (type, FALSE);
+ gint nelements = strlen(data);
+
+ gdk_property_change (window, property_a, type_a, format, mode,(const guchar *)data,
+ nelements);
+}
+
diff --git a/src/sugar3/gdk-wrapper.h b/src/sugar3/gdk-wrapper.h
new file mode 100644
index 0000000..3f936c5
--- /dev/null
+++ b/src/sugar3/gdk-wrapper.h
@@ -0,0 +1,36 @@
+/* gdk-wrapper.h
+ * Copyright (C) 2011 Raul Gutierrez Segales
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __GDK_WRAPPER_H__
+#define __GDK_WRAPPER_H__
+
+#include <gdk/gdk.h>
+
+
+
+void
+gdk_wrapper_property_change (GdkWindow *window,
+ const gchar *property,
+ const gchar *type,
+ gint format,
+ GdkPropMode mode,
+ const gchar *data);
+
+
+#endif /* __GDK_WRAPPER_H__ */
diff --git a/src/sugar3/wm.py b/src/sugar3/wm.py
index 9c4db2e..66db65e 100644
--- a/src/sugar3/wm.py
+++ b/src/sugar3/wm.py
@@ -21,6 +21,7 @@ UNSTABLE. Used only internally by Activity and jarabe.
from gi.repository import Gtk
from gi.repository import Gdk
+from gi.repository import SugarExt
import logging
@@ -42,7 +43,7 @@ def _property_change_trapped(window, prop, prop_type, format, mode, data):
# pylint: disable=W0622
Gdk.error_trap_push()
- window.property_change(prop, prop_type, format, mode, data)
+ SugarExt.property_change(window, prop, prop_type, format, mode, data)
error = Gdk.error_trap_pop()
if error: