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. Making the sugarext introspectable was done following the descriptions at: http://live.gnome.org/GObjectIntrospection#Using_GI Signed-off-by: Simon Schampijer <simon@schampijer.de>master
parent
820efa56b9
commit
10d7f7d3f9
@ -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*")
|
||||
)
|
@ -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;
|
||||
}
|
||||
|
||||
%%
|
@ -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");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue