Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2011-11-13 16:03:44 (GMT)
committer Sascha Silbe <silbe@activitycentral.com>2011-11-22 12:28:55 (GMT)
commite326b7287caeac6a252387594ba3180aa8fb5cc1 (patch)
tree7a2817952897bca413f2a3548007dfa9a550463b
parent2158c38830e71ec856b962b734a2e6fd2261dcf5 (diff)
Switch sugarext to be an introspectable library
This makes sugarext accessible through introspection. It is used from the shell (key grabber, sound volume management) and the shell session management.
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am1
-rw-r--r--configure.ac2
-rw-r--r--src/sugar3/Makefile.am99
-rw-r--r--src/sugar3/_sugarext.defs339
-rw-r--r--src/sugar3/_sugarext.override79
-rw-r--r--src/sugar3/_sugarextmodule.c48
-rw-r--r--src/sugar3/eggaccelerators.h2
-rw-r--r--src/sugar3/eggsmclient-private.h1
-rw-r--r--src/sugar3/gsm-session.c8
-rw-r--r--src/sugar3/sugar-key-grabber.h2
-rw-r--r--src/sugar3/sugar-menu.h2
12 files changed, 73 insertions, 512 deletions
diff --git a/.gitignore b/.gitignore
index fe4cc56..60ce11b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,8 @@
*.lo
*.pyc
*~
+*.gir
+*.typelib
.deps
.libs
diff --git a/Makefile.am b/Makefile.am
index b62b8cc..6359a2b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,5 @@
ACLOCAL_AMFLAGS = -I m4
+DISTCHECK_CONFIGURE_FLAGS = --enable-introspection
DISTCLEANFILES = \
intltool-extract \
diff --git a/configure.ac b/configure.ac
index a12f071..e815274 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,8 @@ AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package])
AM_GLIB_GNU_GETTEXT
+GOBJECT_INTROSPECTION_CHECK([1.30.0])
+
AC_OUTPUT([
Makefile
src/Makefile
diff --git a/src/sugar3/Makefile.am b/src/sugar3/Makefile.am
index a66b741..e0eb935 100644
--- a/src/sugar3/Makefile.am
+++ b/src/sugar3/Makefile.am
@@ -9,68 +9,51 @@ sugar_PYTHON = \
util.py \
wm.py
-pkgpyexecdir = $(pythondir)/sugar3
+lib_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 = $(EXT_LIBS) -lSM -lICE -lasound
-_sugarext_la_SOURCES = \
+libsugarext_la_SOURCES = \
$(BUILT_SOURCES) \
- _sugarextmodule.c \
- acme-volume.h \
- acme-volume.c \
- acme-volume-alsa.h \
acme-volume-alsa.c \
- gsm-app.h \
- gsm-app.c \
- gsm-client.h \
- gsm-client.c \
- gsm-client-xsmp.h \
- gsm-client-xsmp.c \
- gsm-xsmp.h \
- gsm-xsmp.c \
- gsm-session.h \
- gsm-session.c \
+ acme-volume-alsa.h \
+ acme-volume.c \
+ acme-volume.h \
eggaccelerators.c \
eggaccelerators.h \
- eggdesktopfile.h \
eggdesktopfile.c \
- eggsmclient.h \
+ eggdesktopfile.h \
eggsmclient.c \
+ eggsmclient.h \
eggsmclient-private.h \
eggsmclient-xsmp.c \
+ gsm-app.c \
+ gsm-app.h \
+ gsm-client.c \
+ gsm-client.h \
+ gsm-client-xsmp.c \
+ gsm-client-xsmp.h \
+ gsm-session.c \
+ gsm-session.h \
+ gsm-xsmp.c \
+ gsm-xsmp.h \
sugar-grid.c \
sugar-grid.h \
sugar-key-grabber.c \
sugar-key-grabber.h \
- sugar-menu.h \
- sugar-menu.c
+ sugar-menu.c \
+ sugar-menu.h
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
@@ -80,4 +63,36 @@ sugar-marshal.h: sugar-marshal.list
$(srcdir)/sugar-marshal.list --header > sugar-marshal.h
CLEANFILES = $(BUILT_SOURCES)
-EXTRA_DIST = sugar-marshal.list _sugarext.defs _sugarext.override
+EXTRA_DIST = sugar-marshal.list
+
+-include $(INTROSPECTION_MAKEFILE)
+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
+SugarExt_1_0_gir_LIBS = libsugarext.la
+SugarExt_1_0_gir_FILES = \
+ acme-volume.c \
+ acme-volume.h \
+ acme-volume-alsa.c \
+ acme-volume-alsa.h \
+ eggsmclient.c \
+ eggsmclient.h \
+ gsm-session.c \
+ gsm-session.h \
+ gsm-xsmp.c \
+ gsm-xsmp.h \
+ sugar-key-grabber.c \
+ sugar-key-grabber.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
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = SugarExt-1.0.gir
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = SugarExt-1.0.typelib
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
diff --git a/src/sugar3/_sugarext.defs b/src/sugar3/_sugarext.defs
deleted file mode 100644
index 070fb5b..0000000
--- a/src/sugar3/_sugarext.defs
+++ /dev/null
@@ -1,339 +0,0 @@
-;; -*- scheme -*-
-; object definitions
-
-(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 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")
-)
-
-;; 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 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/sugar3/_sugarext.override b/src/sugar3/_sugarext.override
deleted file mode 100644
index def0927..0000000
--- a/src/sugar3/_sugarext.override
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C; c-basic-offset: 4 -*- */
-%%
-headers
-#include <Python.h>
-
-#include "pygobject.h"
-#include "sugar-grid.h"
-#include "sugar-key-grabber.h"
-#include "sugar-menu.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/sugar3/_sugarextmodule.c b/src/sugar3/_sugarextmodule.c
deleted file mode 100644
index dc5dfca..0000000
--- a/src/sugar3/_sugarextmodule.c
+++ /dev/null
@@ -1,48 +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);
-
-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);
-
- if (PyErr_Occurred ()) {
- Py_FatalError ("can't initialise module _sugarext");
- }
-}
diff --git a/src/sugar3/eggaccelerators.h b/src/sugar3/eggaccelerators.h
index 96d5390..423b274 100644
--- a/src/sugar3/eggaccelerators.h
+++ b/src/sugar3/eggaccelerators.h
@@ -21,7 +21,7 @@
#ifndef __EGG_ACCELERATORS_H__
#define __EGG_ACCELERATORS_H__
-#include <gtk/gtkaccelgroup.h>
+#include <gtk/gtk.h>
#include <gdk/gdk.h>
G_BEGIN_DECLS
diff --git a/src/sugar3/eggsmclient-private.h b/src/sugar3/eggsmclient-private.h
index d2958c9..fd95ace 100644
--- a/src/sugar3/eggsmclient-private.h
+++ b/src/sugar3/eggsmclient-private.h
@@ -20,7 +20,6 @@
#ifndef __EGG_SM_CLIENT_PRIVATE_H__
#define __EGG_SM_CLIENT_PRIVATE_H__
-#include <gdkconfig.h>
#include "eggsmclient.h"
G_BEGIN_DECLS
diff --git a/src/sugar3/gsm-session.c b/src/sugar3/gsm-session.c
index 6430a94..d507a57 100644
--- a/src/sugar3/gsm-session.c
+++ b/src/sugar3/gsm-session.c
@@ -501,6 +501,14 @@ client_disconnected (GsmClient *client, gpointer data)
g_object_unref (client);
}
+/**
+ * gsm_session_create_global
+ *
+ * Creates a new GSM_SESSION
+ *
+ * Returns: (transfer full): returns GSM_SESSION
+ **/
+
GsmSession *
gsm_session_create_global (void)
{
diff --git a/src/sugar3/sugar-key-grabber.h b/src/sugar3/sugar-key-grabber.h
index ab02870..9abc887 100644
--- a/src/sugar3/sugar-key-grabber.h
+++ b/src/sugar3/sugar-key-grabber.h
@@ -21,7 +21,7 @@
#define __SUGAR_KEY_GRABBER_H__
#include <glib-object.h>
-#include <gdk/gdkwindow.h>
+#include <gdk/gdk.h>
G_BEGIN_DECLS
diff --git a/src/sugar3/sugar-menu.h b/src/sugar3/sugar-menu.h
index 74ce891..c3bb3d0 100644
--- a/src/sugar3/sugar-menu.h
+++ b/src/sugar3/sugar-menu.h
@@ -20,7 +20,7 @@
#ifndef __SUGAR_MENU_H__
#define __SUGAR_MENU_H__
-#include <gtk/gtkmenu.h>
+#include <gtk/gtk.h>
G_BEGIN_DECLS