Add GdkWrapper to access non-introspectable Gdk API

See https://bugzilla.gnome.org/show_bug.cgi?id=663261

Signed-off-by: Raul Gutierrez Segales <rgs@collabora.co.uk>
This commit is contained in:
Raul Gutierrez Segales 2011-10-30 11:54:53 +00:00 committed by Simon Schampijer
parent 09b3740768
commit 1005c67ad2
4 changed files with 105 additions and 3 deletions

View File

@ -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

59
src/sugar3/gdk-wrapper.c Normal file
View File

@ -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);
}

36
src/sugar3/gdk-wrapper.h Normal file
View File

@ -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__ */

View File

@ -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: