Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-10-12 13:19:59 (GMT)
committer Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-08-18 18:08:31 (GMT)
commit79b62380356816cef733a3ba172daa1b0be10e2e (patch)
treeca02f6aa1ac6841d77ab8ccb3adac1213e15d4b9
parentd6da506dfdd8dbfa2e6baf145d4bb62dbb5b73cc (diff)
Add GObject introspection support and remove static bindings
-rw-r--r--configure.ac4
-rw-r--r--src/sugar/Makefile.am84
-rw-r--r--src/sugar/_sugarext.defs422
-rw-r--r--src/sugar/_sugarext.override81
-rw-r--r--src/sugar/_sugarextmodule.c50
5 files changed, 53 insertions, 588 deletions
diff --git a/configure.ac b/configure.ac
index f66d564..3b89aaa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,9 @@ AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, no)
-PKG_CHECK_MODULES(EXT, pygtk-2.0 gtk+-2.0 sm ice alsa)
+PKG_CHECK_MODULES(EXT, gtk+-2.0 sm ice alsa)
+
+GOBJECT_INTROSPECTION_CHECK([0.6.3])
PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
AC_SUBST(PYGTK_DEFSDIR)
diff --git a/src/sugar/Makefile.am b/src/sugar/Makefile.am
index 236e337..5c697db 100644
--- a/src/sugar/Makefile.am
+++ b/src/sugar/Makefile.am
@@ -9,25 +9,30 @@ sugar_PYTHON = \
util.py \
wm.py
-pkgpyexecdir = $(pythondir)/sugar
+EXTRA_LTLIBRARIES = libsugarext.la
-pkgpyexec_LTLIBRARIES = _sugarext.la
-
-_sugarext_la_CFLAGS = \
+libsugarext_la_CFLAGS = \
-DHAVE_ALSA \
- $(WARN_CFLAGS) \
- $(EXT_CFLAGS) \
- $(PYTHON_INCLUDES)
+ $(EXT_CFLAGS) \
+ $(WARN_CFLAGS)
-_sugarext_la_LDFLAGS = -module -avoid-version
-_sugarext_la_LIBADD = $(EXT_LIBS) -lSM -lICE
+libsugarext_la_LDFLAGS = $(LDADD)
+libsugarext_la_LIBADD = -lSM -lICE
-_sugarext_la_SOURCES = \
- $(BUILT_SOURCES) \
- _sugarextmodule.c \
+public_headers = \
+ sugar-address-entry.h \
+ sugar-key-grabber.h \
+ sugar-menu.h \
+ sugar-grid.h \
+ sexy-icon-entry.h \
+ eggsmclient.h \
acme-volume.h \
+ acme-volume-alsa.h
+
+libsugarext_la_SOURCES = \
+ $(BUILT_SOURCES) \
+ $(public_headers) \
acme-volume.c \
- acme-volume-alsa.h \
acme-volume-alsa.c \
gsm-app.h \
gsm-app.c \
@@ -43,38 +48,19 @@ _sugarext_la_SOURCES = \
eggaccelerators.h \
eggdesktopfile.h \
eggdesktopfile.c \
- eggsmclient.h \
eggsmclient.c \
eggsmclient-private.h \
eggsmclient-xsmp.c \
- sexy-icon-entry.h \
sexy-icon-entry.c \
sugar-address-entry.c \
- sugar-address-entry.h \
sugar-grid.c \
- sugar-grid.h \
sugar-key-grabber.c \
- sugar-key-grabber.h \
- sugar-menu.h \
sugar-menu.c
BUILT_SOURCES = \
- _sugarext.c \
sugar-marshal.c \
sugar-marshal.h
-_sugarext.c: _sugarext.defs _sugarext.override
-
-.defs.c:
- (cd $(srcdir)\
- && $(PYGTK_CODEGEN) \
- --register $(PYGTK_DEFSDIR)/gdk-types.defs \
- --register $(PYGTK_DEFSDIR)/gtk-types.defs \
- --override $*.override \
- --prefix py$* $*.defs) > gen-$*.c \
- && cp gen-$*.c $*.c \
- && rm -f gen-$*.c
-
sugar-marshal.c: sugar-marshal.list
$(GLIB_GENMARSHAL) --prefix=sugar_marshal \
$(srcdir)/sugar-marshal.list --header --body > sugar-marshal.c
@@ -83,5 +69,35 @@ sugar-marshal.h: sugar-marshal.list
$(GLIB_GENMARSHAL) --prefix=sugar_marshal \
$(srcdir)/sugar-marshal.list --header > sugar-marshal.h
-CLEANFILES = $(BUILT_SOURCES)
-EXTRA_DIST = sugar-marshal.list _sugarext.defs _sugarext.override
+SugarExt-1.0.gir: $(INTROSPECTION_SCANNER) libsugarext.la
+ $(INTROSPECTION_SCANNER) -v \
+ --namespace SugarExt --nsversion=1.0 \
+ --include=Gtk-2.0 \
+ --library=libsugarext.la \
+ --library asound \
+ --library gdk-x11-2.0 \
+ --library gtk-x11-2.0 \
+ --output $@ \
+ $(public_headers)
+
+BUILT_GIRSOURCES = SugarExt-1.0.gir
+
+# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to
+# install anything - we need to install inside our prefix.
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(BUILT_GIRSOURCES)
+
+typelibsdir = $(libdir)/girepository-1.0/
+
+typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
+
+%.typelib: %.gir $(INTROSPECTION_COMPILER)
+ $(QUIET_GEN) \
+ LD_LIBRARY_PATH=.libs$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH} \
+ $(INTROSPECTION_COMPILER) \
+ --includedir=$(srcdir) \
+ --includedir=. \
+ $(INTROSPECTION_COMPILER_OPTS) $< -o $(@F)
+
+CLEANFILES = $(BUILT_SOURCES) $(BUILT_GIRSOURCES) $(typelibs_DATA)
+EXTRA_DIST = sugar-marshal.list
diff --git a/src/sugar/_sugarext.defs b/src/sugar/_sugarext.defs
deleted file mode 100644
index e36034d..0000000
--- a/src/sugar/_sugarext.defs
+++ /dev/null
@@ -1,422 +0,0 @@
-;; -*- scheme -*-
-; object definitions
-
-(define-object AddressEntry
- (in-module "Sugar")
- (parent "GtkEntry")
- (c-name "SugarAddressEntry")
- (gtype-id "SUGAR_TYPE_ADDRESS_ENTRY")
-)
-
-(define-object KeyGrabber
- (in-module "Sugar")
- (parent "GObject")
- (c-name "SugarKeyGrabber")
- (gtype-id "SUGAR_TYPE_KEY_GRABBER")
-)
-
-(define-object Menu
- (in-module "Sugar")
- (parent "GtkMenu")
- (c-name "SugarMenu")
- (gtype-id "SUGAR_TYPE_MENU")
-)
-
-(define-object Grid
- (in-module "Sugar")
- (parent "GObject")
- (c-name "SugarGrid")
- (gtype-id "SUGAR_TYPE_GRID")
-)
-
-(define-object IconEntry
- (in-module "Sexy")
- (parent "GtkEntry")
- (c-name "SexyIconEntry")
- (gtype-id "SEXY_TYPE_ICON_ENTRY")
-)
-
-(define-object SMClientXSMP
- (in-module "Egg")
- (parent "EggSMClient")
- (c-name "EggSMClientXSMP")
- (gtype-id "EGG_TYPE_SM_CLIENT_XSMP")
-)
-
-(define-object SMClient
- (in-module "Egg")
- (parent "GObject")
- (c-name "EggSMClient")
- (gtype-id "EGG_TYPE_SM_CLIENT")
-)
-
-(define-object Session
- (in-module "Gsm")
- (parent "GObject")
- (c-name "GsmSession")
- (gtype-id "GSM_TYPE_SESSION")
-)
-
-(define-object Volume
- (in-module "Acme")
- (parent "GObject")
- (c-name "AcmeVolume")
- (gtype-id "ACME_TYPE_VOLUME")
-)
-
-(define-object VolumeAlsa
- (in-module "Acme")
- (parent "AcmeVolume")
- (c-name "AcmeVolumeAlsa")
- (gtype-id "ACME_TYPE_VOLUME_ALSA")
-)
-
-;; Enumerations and flags ...
-
-(define-enum IconEntryPosition
- (in-module "Sexy")
- (c-name "SexyIconEntryPosition")
- (gtype-id "SEXY_TYPE_ICON_ENTRY_POSITION")
- (values
- '("primary" "SEXY_ICON_ENTRY_PRIMARY")
- '("secondary" "SEXY_ICON_ENTRY_SECONDARY")
- )
-)
-
-;; From sugar-menu.h
-
-(define-method set_active
- (of-object "SugarMenu")
- (c-name "sugar_menu_set_active")
- (return-type "none")
- (parameters
- '("gboolean" "active")
- )
-)
-
-(define-method embed
- (of-object "SugarMenu")
- (c-name "sugar_menu_embed")
- (return-type "none")
- (parameters
- '("GtkContainer" "container")
- )
-)
-
-(define-method unembed
- (of-object "SugarMenu")
- (c-name "sugar_menu_unembed")
- (return-type "none")
-)
-
-;; From sugar-grid.h
-
-(define-method setup
- (of-object "SugarGrid")
- (c-name "sugar_grid_setup")
- (return-type "none")
- (parameters
- '("gint" "width")
- '("gint" "height")
- )
-)
-
-(define-method add_weight
- (of-object "SugarGrid")
- (c-name "sugar_grid_add_weight")
- (return-type "none")
- (parameters
- '("GdkRectangle*" "rect")
- )
-)
-
-(define-method remove_weight
- (of-object "SugarGrid")
- (c-name "sugar_grid_remove_weight")
- (return-type "none")
- (parameters
- '("GdkRectangle*" "rect")
- )
-)
-
-(define-method compute_weight
- (of-object "SugarGrid")
- (c-name "sugar_grid_compute_weight")
- (return-type "guint")
- (parameters
- '("GdkRectangle*" "rect")
- )
-)
-
-;; From sugar-key-grabber.h
-
-(define-function sugar_key_grabber_get_type
- (c-name "sugar_key_grabber_get_type")
- (return-type "GType")
-)
-
-(define-method grab_keys
- (of-object "SugarKeyGrabber")
- (c-name "sugar_key_grabber_grab_keys")
- (return-type "none")
- (parameters
- '("const-char*[]" "keys")
- )
-)
-
-(define-method get_key
- (of-object "SugarKeyGrabber")
- (c-name "sugar_key_grabber_get_key")
- (return-type "char*")
- (parameters
- '("guint" "keycode")
- '("guint" "state")
- )
-)
-
-(define-method is_modifier
- (of-object "SugarKeyGrabber")
- (c-name "sugar_key_grabber_is_modifier")
- (return-type "gboolean")
- (parameters
- '("guint" "keycode")
- '("guint" "mask" (default "-1"))
- )
-)
-
-;; From sexy-icon-entry.h
-
-(define-function sexy_icon_entry_get_type
- (c-name "sexy_icon_entry_get_type")
- (return-type "GType")
-)
-
-(define-function sexy_icon_entry_new
- (c-name "sexy_icon_entry_new")
- (is-constructor-of "SexyIconEntry")
- (return-type "GtkWidget*")
-)
-
-(define-method set_icon
- (of-object "SexyIconEntry")
- (c-name "sexy_icon_entry_set_icon")
- (return-type "none")
- (parameters
- '("SexyIconEntryPosition" "position")
- '("GtkImage*" "icon" (null-ok))
- )
-)
-
-(define-method set_icon_highlight
- (of-object "SexyIconEntry")
- (c-name "sexy_icon_entry_set_icon_highlight")
- (return-type "none")
- (parameters
- '("SexyIconEntryPosition" "position")
- '("gboolean" "highlight")
- )
-)
-
-(define-method get_icon
- (of-object "SexyIconEntry")
- (c-name "sexy_icon_entry_get_icon")
- (return-type "GtkImage*")
- (parameters
- '("SexyIconEntryPosition" "position")
- )
-)
-
-(define-method get_icon_highlight
- (of-object "SexyIconEntry")
- (c-name "sexy_icon_entry_get_icon_highlight")
- (return-type "gboolean")
- (parameters
- '("SexyIconEntryPosition" "position")
- )
-)
-
-(define-method add_clear_button
- (of-object "SexyIconEntry")
- (c-name "sexy_icon_entry_add_clear_button")
- (return-type "none")
-)
-
-;; From eggsmclient.h
-
-(define-function egg_sm_client_get_type
- (c-name "egg_sm_client_get_type")
- (return-type "GType")
-)
-
-(define-function egg_sm_client_get_option_group
- (c-name "egg_sm_client_get_option_group")
- (return-type "GOptionGroup*")
-)
-
-(define-method is_resumed
- (of-object "EggSMClient")
- (c-name "egg_sm_client_is_resumed")
- (return-type "gboolean")
-)
-
-(define-method get_state_file
- (of-object "EggSMClient")
- (c-name "egg_sm_client_get_state_file")
- (return-type "GKeyFile*")
-)
-
-(define-method set_restart_command
- (of-object "EggSMClient")
- (c-name "egg_sm_client_set_restart_command")
- (return-type "none")
- (parameters
- '("int" "argc")
- '("const-char**" "argv")
- )
-)
-
-(define-method startup
- (of-object "EggSMClient")
- (c-name "egg_sm_client_startup")
- (return-type "none")
-)
-
-(define-method will_quit
- (of-object "EggSMClient")
- (c-name "egg_sm_client_will_quit")
- (return-type "none")
- (parameters
- '("gboolean" "will_quit")
- )
-)
-
-(define-function egg_sm_client_end_session
- (c-name "egg_sm_client_end_session")
- (return-type "gboolean")
- (parameters
- '("EggSMClientEndStyle" "style")
- '("gboolean" "request_confirmation")
- )
-)
-
-;; From xsmp.h
-
-(define-function xsmp_init
- (c-name "gsm_xsmp_init")
- (return-type "char*")
-)
-
-(define-function xsmp_run
- (c-name "gsm_xsmp_run")
- (return-type "none")
-)
-
-(define-function xsmp_shutdown
- (c-name "gsm_xsmp_shutdown")
- (return-type "none")
-)
-
-;; From session.h
-
-(define-method set_name
- (of-object "GsmSession")
- (c-name "gsm_session_set_name")
- (return-type "none")
- (parameters
- '("const-char*" "name")
- )
-)
-
-(define-method start
- (of-object "GsmSession")
- (c-name "gsm_session_start")
- (return-type "none")
-)
-
-(define-method get_phase
- (of-object "GsmSession")
- (c-name "gsm_session_get_phase")
- (return-type "GsmSessionPhase")
-)
-
-(define-method initiate_shutdown
- (of-object "GsmSession")
- (c-name "gsm_session_initiate_shutdown")
- (return-type "none")
-)
-
-(define-method cancel_shutdown
- (of-object "GsmSession")
- (c-name "gsm_session_cancel_shutdown")
- (return-type "none")
-)
-
-(define-method register_client
- (of-object "GsmSession")
- (c-name "gsm_session_register_client")
- (return-type "char*")
- (parameters
- '("GsmClient*" "client")
- '("const-char*" "previous_id")
- )
-)
-
-(define-function session_create_global
- (c-name "gsm_session_create_global")
- (return-type "GsmSession*")
-)
-
-;; From acme-volume.h
-
-(define-function acme_volume_get_type
- (c-name "acme_volume_get_type")
- (return-type "GType")
-)
-
-(define-method get_volume
- (of-object "AcmeVolume")
- (c-name "acme_volume_get_volume")
- (return-type "int")
-)
-
-(define-method set_volume
- (of-object "AcmeVolume")
- (c-name "acme_volume_set_volume")
- (return-type "none")
- (parameters
- '("int" "val")
- )
-)
-
-(define-method get_mute
- (of-object "AcmeVolume")
- (c-name "acme_volume_get_mute")
- (return-type "gboolean")
-)
-
-(define-method set_mute
- (of-object "AcmeVolume")
- (c-name "acme_volume_set_mute")
- (return-type "none")
- (parameters
- '("gboolean" "val")
- )
-)
-
-(define-method mute_toggle
- (of-object "AcmeVolume")
- (c-name "acme_volume_mute_toggle")
- (return-type "none")
-)
-
-(define-method get_threshold
- (of-object "AcmeVolume")
- (c-name "acme_volume_get_threshold")
- (return-type "int")
-)
-
-(define-function acme_volume_new
- (c-name "acme_volume_new")
- (is-constructor-of "AcmeVolume")
- (return-type "AcmeVolume*")
-)
diff --git a/src/sugar/_sugarext.override b/src/sugar/_sugarext.override
deleted file mode 100644
index 6b768bb..0000000
--- a/src/sugar/_sugarext.override
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C; c-basic-offset: 4 -*- */
-%%
-headers
-#include <Python.h>
-
-#include "pygobject.h"
-#include "sugar-address-entry.h"
-#include "sugar-grid.h"
-#include "sugar-key-grabber.h"
-#include "sugar-menu.h"
-#include "sexy-icon-entry.h"
-#include "gsm-session.h"
-#include "gsm-xsmp.h"
-#include "acme-volume-alsa.h"
-
-#include "eggsmclient.h"
-#include "eggsmclient-private.h"
-
-#include <pygtk/pygtk.h>
-#include <glib.h>
-
-%%
-modulename sugar._sugarext
-%%
-import gobject.GObject as PyGObject_Type
-import gtk.Widget as PyGtkWidget_Type
-import gtk.Entry as PyGtkEntry_Type
-import gtk.Menu as PyGtkMenu_Type
-import gtk.Container as PyGtkContainer_Type
-import gtk.gdk.Window as PyGdkWindow_Type
-import gtk.Image as PyGtkImage_Type
-%%
-ignore-glob
- *_get_type
- _*
-%%
-override sugar_key_grabber_grab_keys kwargs
-static PyObject *
-_wrap_sugar_key_grabber_grab_keys(PyGObject *self, PyObject *args, PyObject *kwargs)
-{
- static char *kwlist[] = { "key", NULL };
- PyObject *py_keys;
- char **keys;
- int i, len;
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,
- "O:SugarKeyGrabber.grab_keys",
- kwlist, &py_keys))
- return NULL;
-
- if (!PySequence_Check(py_keys) || (len = PySequence_Size(py_keys)) < 0) {
- PyErr_SetString(PyExc_ValueError,
- "keys should be a sequence of strings");
- return NULL;
- }
-
- keys = g_new(char*, len + 1);
- for (i = 0; i < len; i++) {
- PyObject *item = PySequence_GetItem(py_keys, i);
- if (!item) {
- g_free(keys);
- return NULL;
- }
- if (!PyString_Check(item)) {
- PyErr_SetString(PyExc_TypeError, "key must be a string");
- g_free(keys);
- Py_DECREF(item);
- return NULL;
- }
- keys[i] = PyString_AsString(item);
- Py_DECREF(item);
- }
- keys[len] = NULL;
-
- sugar_key_grabber_grab_keys (SUGAR_KEY_GRABBER(self->obj), (const char**) keys);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-%%
diff --git a/src/sugar/_sugarextmodule.c b/src/sugar/_sugarextmodule.c
deleted file mode 100644
index 1bb8545..0000000
--- a/src/sugar/_sugarextmodule.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2006-2007, Red Hat, Inc.
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* include this first, before NO_IMPORT_PYGOBJECT is defined */
-#include <pygobject.h>
-#include <pygtk/pygtk.h>
-
-extern PyMethodDef py_sugarext_functions[];
-
-void py_sugarext_register_classes (PyObject *d);
-void py_sugarext_add_constants (PyObject *module, const gchar *strip_prefix);
-
-DL_EXPORT(void)
-init_sugarext(void)
-{
- PyObject *m, *d;
-
- init_pygobject();
- init_pygtk();
-
- m = Py_InitModule("_sugarext", py_sugarext_functions);
- d = PyModule_GetDict(m);
-
- py_sugarext_register_classes(d);
- py_sugarext_add_constants(m, "SEXY_");
-
- if (PyErr_Occurred ()) {
- Py_FatalError ("can't initialise module _sugarext");
- }
-}