From 1005c67ad27ff3c053121b1c500fb8906dfbcd27 Mon Sep 17 00:00:00 2001 From: Raul Gutierrez Segales Date: Sun, 30 Oct 2011 11:54:53 +0000 Subject: [PATCH] Add GdkWrapper to access non-introspectable Gdk API See https://bugzilla.gnome.org/show_bug.cgi?id=663261 Signed-off-by: Raul Gutierrez Segales --- src/sugar3/Makefile.am | 10 +++++-- src/sugar3/gdk-wrapper.c | 59 ++++++++++++++++++++++++++++++++++++++++ src/sugar3/gdk-wrapper.h | 36 ++++++++++++++++++++++++ src/sugar3/wm.py | 3 +- 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 src/sugar3/gdk-wrapper.c create mode 100644 src/sugar3/gdk-wrapper.h diff --git a/src/sugar3/Makefile.am b/src/sugar3/Makefile.am index e0eb9351..ca5abed4 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 00000000..f5d9fd61 --- /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 + +/** + * 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 gchar *) + * + * 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 00000000..3f936c56 --- /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 + + + +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 9c4db2e1..66db65e1 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: