Split the UI part of sugarext out to his own module to avoid

dragging gtk inside services.
This commit is contained in:
Marco Pesenti Gritti 2007-07-27 20:15:31 +02:00
parent b9d7d00985
commit b23b63cdd5
43 changed files with 276 additions and 580 deletions

View File

@ -43,7 +43,7 @@ Makefile
bin/Makefile bin/Makefile
data/Makefile data/Makefile
lib/Makefile lib/Makefile
lib/xdgmime/Makefile lib/ui/Makefile
services/Makefile services/Makefile
services/clipboard/Makefile services/clipboard/Makefile
shell/Makefile shell/Makefile

View File

@ -1,51 +1,21 @@
SUBDIRS = xdgmime SUBDIRS = ui
libsugar_la_CPPFLAGS = \ INCLUDES = -DXDG_PREFIX=sugar_mime
$(LIB_CFLAGS)
noinst_LTLIBRARIES = libsugar.la noinst_LTLIBRARIES = libsugar.la
libsugar_la_LIBADD = \
$(LIB_LIBS) \
$(top_builddir)/lib/xdgmime/libxdgmime.la
libsugar_la_SOURCES = \ libsugar_la_SOURCES = \
$(BUILT_SOURCES) \ xdgmime.c \
eggaccelerators.c \ xdgmime.h \
eggaccelerators.h \ xdgmimealias.c \
sugar-address-entry.c \ xdgmimealias.h \
sugar-address-entry.h \ xdgmimecache.c \
sugar-key-grabber.c \ xdgmimecache.h \
sugar-key-grabber.h \ xdgmimeglob.c \
sugar-menu.h \ xdgmimeglob.h \
sugar-menu.c \ xdgmimeint.c \
sugar-x11-util.c \ xdgmimeint.h \
sugar-x11-util.h xdgmimemagic.c \
xdgmimemagic.h \
BUILT_SOURCES = \ xdgmimeparent.c \
sugar-marshal.c \ xdgmimeparent.h
sugar-marshal.h
stamp_files = \
stamp-sugar-marshal.c \
stamp-sugar-marshal.h
sugar-marshal.c: stamp-sugar-marshal.c
@true
stamp-sugar-marshal.c: sugar-marshal.list
$(GLIB_GENMARSHAL) --prefix=sugar_marshal \
$(srcdir)/sugar-marshal.list --header --body > \
sugar-marshal.c && echo timestamp > $(@F)
sugar-marshal.h: stamp-sugar-marshal.h
@true
stamp-sugar-marshal.h: sugar-marshal.list
$(GLIB_GENMARSHAL) --prefix=sugar_marshal \
$(srcdir)/sugar-marshal.list --header > \
sugar-marshal.h && echo timestamp > $(@F)
CLEANFILES = $(stamp_files) $(BUILT_SOURCES)
DISTCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
MAINTAINERCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
EXTRA_DIST = sugar-marshal.list

48
lib/ui/Makefile.am Normal file
View File

@ -0,0 +1,48 @@
libsugarui_la_CPPFLAGS = \
$(LIB_CFLAGS)
noinst_LTLIBRARIES = libsugarui.la
libsugarui_la_LIBADD = \
$(LIB_LIBS)
libsugarui_la_SOURCES = \
$(BUILT_SOURCES) \
eggaccelerators.c \
eggaccelerators.h \
sugar-address-entry.c \
sugar-address-entry.h \
sugar-key-grabber.c \
sugar-key-grabber.h \
sugar-menu.h \
sugar-menu.c \
sugar-x11-util.c \
sugar-x11-util.h
BUILT_SOURCES = \
sugar-marshal.c \
sugar-marshal.h
stamp_files = \
stamp-sugar-marshal.c \
stamp-sugar-marshal.h
sugar-marshal.c: stamp-sugar-marshal.c
@true
stamp-sugar-marshal.c: sugar-marshal.list
$(GLIB_GENMARSHAL) --prefix=sugar_marshal \
$(srcdir)/sugar-marshal.list --header --body > \
sugar-marshal.c && echo timestamp > $(@F)
sugar-marshal.h: stamp-sugar-marshal.h
@true
stamp-sugar-marshal.h: sugar-marshal.list
$(GLIB_GENMARSHAL) --prefix=sugar_marshal \
$(srcdir)/sugar-marshal.list --header > \
sugar-marshal.h && echo timestamp > $(@F)
CLEANFILES = $(stamp_files) $(BUILT_SOURCES)
DISTCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
MAINTAINERCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
EXTRA_DIST = sugar-marshal.list

View File

@ -1,378 +0,0 @@
2007-01-22 Matthias Clasen <mclasen@redhat.com>
* === 2.10.9 ===
2007-01-17 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.8 ===
2007-01-07 Matthias Clasen <mclasen@redhat.com>
* xdgmimecache.c (cache_glob_node_lookup_suffix): Don't return ""
as match. (fd.o #9544, Yevgen Muntyan)
2007-01-07 Matthias Clasen <mclasen@redhat.com>
* xdgmimecache.c (_xdg_mime_cache_list_mime_parents): Fix
several problems with this function. (fd.o #9560, Yevgen Muntyan)
2007-01-05 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.7 ===
2006-10-03 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.6 ===
2006-10-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.5 ===
2006-09-22 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.4 ===
2006-09-04 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.3 ===
2006-08-17 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.2 ===
2006-07-23 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.1 ===
2006-07-20 Matthias Clasen <mclasen@redhat.com>
Fix a thinko that leads to constantly reloading
the mime data if a mime.cache is present. Patch
by Yevgen Muntyan, bugs.freedesktop.org #7495
* xdgmime.c (xdg_check_dir): Look for mime.cache first.
(xdg_check_file): Report existance of the file separately.
2006-07-20 Matthias Clasen <mclasen@redhat.com>
* xdgmime.c (xdg_mime_shutdown): Unref the caches.
Patch by Yevgen Muntyan, bugs.freedesktop.org #7496
* xdgmimemagic.c:
* xdgmime.c:
* xdgmime.h: Add xdg_init-free versions of some
functions and use them internally, so that we don't
reload caches and clobber data structures in the
middle of an operation. Patch by Joe Shaw,
bugs.freedesktop.org #6824
2006-07-19 Matthias Clasen <mclasen@redhat.com>
* xdgmimeglob.c (_xdg_glob_hash_node_lookup_file_name):
Don't return NULL as a mimetype, ever, patch
by Yevgen Muntyan, bugs.freedesktop.org #5241
2006-07-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.0 ===
2006-06-21 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.4 ===
2006-06-12 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.3 ===
2006-06-05 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.2 ===
2006-05-16 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.1 ====
2006-05-04 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.0 ===
2006-04-03 Matthias Clasen <mclasen@redhat.com>
* xdgmime.[hc]: Move xdg_mime_type_unknown to .rodata.
2006-03-06 Matthias Clasen <mclasen@redhat.com>
* xdgmimemagic.c: Remove superfluous extern errno
declaration. (#333605, Tommi Komulainen)
2006-02-27 Matthias Clasen <mclasen@redhat.com>
* xdgmime.h (xdg_mime_dump): Don't export xdg_mime_dump.
2005-12-01 Matthias Clasen <mclasen@redhat.com>
* Merge upstream changes to handle duplicate glob
patterns.
2005-11-04 Matthias Clasen <mclasen@redhat.com>
* xdgmime.c (xdg_mime_list_mime_parents): Prevent
a segfault.
2005-10-18 Matthias Clasen <mclasen@redhat.com>
* xdgmimecache.c: Make magic comparisons work correctly
in the cache.
2005-10-17 Matthias Clasen <mclasen@redhat.com>
* xdgmime.c (xdg_mime_get_mime_type_for_file): Remove
a debugging printf.
2005-09-01 Matthias Clasen <mclasen@redhat.com>
* xdgmime.h:
* xdgmime.c (xdg_mime_get_mime_type_for_file): Take
a struct statbuf * as argument.
* test-mime.c (main): Adjust.
2005-08-24 Matthias Clasen <mclasen@redhat.com>
* === Released 2.8.2 ===
* === Released 2.8.1 ===
2005-08-13 Matthias Clasen <mclasen@redhat.com>
* === Released 2.8.0 ===
2005-08-07 Matthias Clasen <mclasen@redhat.com>
* Rename caches to _caches, so it doesn't
get exported. Also don't export n_caches.
2005-08-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.5 ===
2005-07-22 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.4 ===
2005-07-15 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.3 ===
2005-07-08 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.2 ===
2005-07-01 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.1 ===
2005-06-20 Matthias Clasen <mclasen@redhat.com>
* xdgmimecache.c: Handle missing MAP_FAILED. (#308449, Georg
Schwarz)
2005-06-20 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.0 ===
2005-06-10 Federico Mena Quintero <federico@ximian.com>
* xdgmime.c (xdg_mime_init_from_directory): Pass the correct size
to realloc(). Fixes https://bugs.freedesktop.org/show_bug.cgi?id=3506.
2005-06-09 Matthias Clasen <mclasen@redhat.com>
* xdgmimemagic.c: Don't declare errno, including errno.h
is enough. (#304164, Joerg Sonnenberger)
2005-05-20 Matthias Clasen <mclasen@redhat.com>
* xdgmimecache.c (GET_UINT32): Don't rely on C99
types. (#304924, John Ehresman)
2005-04-29 Matthias Clasen <mclasen@redhat.com>
* Sync to upstream.
2005-04-08 Matthias Clasen <mclasen@redhat.com>
* xdgmimecache.c (cache_magic_matchlet_compare_to_data)
(cache_magic_matchlet_compare): Use cache->buffer, not
cache.
Tue Apr 5 16:00:04 2005 Manish Singh <yosh@gimp.org>
* Makefile.am: add xdgmimecache.[ch].
2005-03-28 Matthias Clasen <mclasen@redhat.com>
* xdgmimeglob.c: Sync to latest upstream,
including fixes for matching against multiple
extensions (eg .tar.gz) and for suffix
patterns which don't start with a dot.
Sat Mar 19 23:52:33 2005 Manish Singh <yosh@gimp.org>
* xdgmimeglob.c (_xdg_glob_hash_insert_text): cast away the constness
in the call to free().
2005-03-20 Matthias Clasen <mclasen@redhat.com>
* xdgmimeglob.c (_xdg_glob_hash_insert_text): Don't
leak node->mime_type if we are reusing an existing
node. (#170774, Kjartan Maraas)
2005-01-08 Matthias Clasen <mclasen@redhat.com>
* === Released 2.6.1 ===
2004-12-16 Matthias Clasen <mclasen@redhat.com>
* === Released 2.6.0 ===
2004-12-13 Marco Pesenti Gritti <marco@gnome.org>
* xdgmimeglob.c: (_xdg_glob_hash_lookup_file_name):
Resync with upstream again
Fri Dec 10 13:58:38 2004 Manish Singh <yosh@gimp.org>
* xdgmime.h: wrap new API in XDG_ENTRY().
2004-12-09 Marco Pesenti Gritti <marco@gnome.org>
* xdgmime.c: (xdg_mime_unalias_mime_type),
(xdg_mime_mime_type_equal), (xdg_mime_mime_type_subclass),
(xdg_mime_get_mime_parents):
* xdgmime.h:
* xdgmimealias.c: (_xdg_mime_alias_list_lookup):
* xdgmimeglob.c: (_xdg_glob_hash_node_lookup_file_name):
* xdgmimeint.c: (_xdg_ucs4_to_lower):
* xdgmimeint.h:
* xdgmimemagic.c: (_xdg_mime_magic_read_from_file):
* xdgmimeparent.c: (_xdg_mime_parent_list_lookup):
Resync with upstream
2004-12-09 Matthias Clasen <mclasen@redhat.com>
* xdgmimealias.c (_xdg_mime_alias_read_from_file):
* xdgmimeparent.c (_xdg_mime_parent_read_from_file): Make
repeated calls accumulate the results, don't call qsort()
on empty arrays. (#160838, Mariano Suárez-Alvarez)
2004-12-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.6 ===
2004-11-29 Matthias Clasen <mclasen@redhat.com>
* xdgmimeparent.c (_xdg_mime_parent_list_lookup):
* xdgmimealias.c (_xdg_mime_alias_list_lookup): Protect
against stupid bsearch() implementations. (#159737,
Morten Welinder)
2004-11-24 Matthias Clasen <mclasen@redhat.com>
* xdgmimeparent.c (_xdg_mime_parent_read_from_file):
Initialize the parent field of the newly allocate list
entry. (#159330, Alex Larsson)
Fri Nov 19 15:10:32 2004 Manish Singh <yosh@gimp.org>
* xdgmime.c: Don't put /* within a comment.
2004-11-09 Matthias Clasen <mclasen@redhat.com>
* xdgmime.h: Prefix all symbols.
2004-11-08 Matthias Clasen <mclasen@redhat.com>
* xdgmime.c (xdg_mime_mime_type_subclass): Enable matching
of supertypes as text/*.
* Sync from upstream
2004-10-27 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.4 ===
2004-09-19 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.3 ===
2004-08-25 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.2 ===
Wed Aug 11 20:44:35 2004 Matthias Clasen <maclas@gmx.de>
* xdgmime.h (xdg_mime_shutdown): Add the XDG_PREFIX to
this function as well.
2004-08-01 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.1 ===
Tue Jul 20 22:24:35 2004 Matthias Clasen <maclas@gmx.de>
* xdgmimeglob.h: Remove trailing commas from
enumerations. (#148035)
Sun Jul 18 20:17:41 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* === Released 2.5.0 ==
Thu May 27 15:23:17 2004 Jonathan Blandford <jrb@gnome.org>
* Sync from upstream
Fri Apr 30 00:19:11 2004 Matthias Clasen <maclas@gmx.de>
* xdgmimemagic.c (_xdg_mime_magic_read_a_number): Make sure
the static string is long enough. (#136323, Morten Welinder)
2004-03-12 Morten Welinder <terra@gnome.org>
* *.c: Make sure to include <config.h> (#137001)
Wed Mar 10 22:48:15 2004 Jonathan Blandford <jrb@gnome.org>
* Sync from upstream
Sun Feb 8 19:05:16 2004 Manish Singh <yosh@gimp.org>
* xdgmimeint.h: declare _xdg_utf8_skip as extern to prevent multiple
definitions.
Wed Jan 21 09:33:13 2004 Jonathan Blandford <jrb@gnome.org>
* libgnomevfs/xdgmimeglob.c:
* libgnomevfs/xdgmimemagic.c: Sync from upstream
Tue Jan 20 13:07:04 2004 Jonathan Blandford <jrb@gnome.org>
* xdgmime.c: resync with upstream sources.
Fri Oct 24 16:54:57 2003 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libxdgmime_la_SOURCES): Add .h files to
SOURCES.
Fri Oct 24 16:02:32 2003 Owen Taylor <otaylor@redhat.com>
* *.[ch]: Relicense to be dual AFL/LGPL (and thus also
GPL) rather than AFL/GPL. Also update AFL version to 1.2.
Tue Jul 22 15:37:45 2003 Jonathan Blandford <jrb@gnome.org>
* xdgmime/xdgmime.c (xdg_mime_init): use XDG_DATA_HOME instead of
XDG_CONFIG_HOME.

View File

@ -1,19 +0,0 @@
INCLUDES = -DXDG_PREFIX=sugar_mime
noinst_LTLIBRARIES = libxdgmime.la
libxdgmime_la_SOURCES = \
xdgmime.c \
xdgmime.h \
xdgmimealias.c \
xdgmimealias.h \
xdgmimecache.c \
xdgmimecache.h \
xdgmimeglob.c \
xdgmimeglob.h \
xdgmimeint.c \
xdgmimeint.h \
xdgmimemagic.c \
xdgmimemagic.h \
xdgmimeparent.c \
xdgmimeparent.h

View File

@ -24,7 +24,7 @@ import gtk
from hardware import hardwaremanager from hardware import hardwaremanager
from model.shellmodel import ShellModel from model.shellmodel import ShellModel
from sugar._sugarext import KeyGrabber from sugar._sugaruiext import KeyGrabber
_BRIGHTNESS_STEP = 2 _BRIGHTNESS_STEP = 2
_VOLUME_STEP = 10 _VOLUME_STEP = 10

2
sugar/.gitignore vendored
View File

@ -1,2 +1,2 @@
_sugarext.c _sugarext.c
_sugaruiext.c

View File

@ -17,11 +17,11 @@ INCLUDES = \
$(LIB_BINDINGS_CFLAGS) \ $(LIB_BINDINGS_CFLAGS) \
$(PYTHON_INCLUDES) \ $(PYTHON_INCLUDES) \
-I$(top_srcdir)/lib \ -I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/xdgmime -I$(top_srcdir)/lib/ui
pkgpyexecdir = $(pythondir)/sugar pkgpyexecdir = $(pythondir)/sugar
pkgpyexec_LTLIBRARIES = _sugarext.la pkgpyexec_LTLIBRARIES = _sugarext.la _sugaruiext.la
_sugarext_la_LDFLAGS = -module -avoid-version _sugarext_la_LDFLAGS = -module -avoid-version
_sugarext_la_LIBADD = \ _sugarext_la_LIBADD = \
@ -36,8 +36,28 @@ nodist__sugarext_la_SOURCES = _sugarext.c
_sugarext.c: _sugarext.defs _sugarext.override _sugarext.c: _sugarext.defs _sugarext.override
CLEANFILES = _sugarext.c _sugaruiext_la_LDFLAGS = -module -avoid-version
EXTRA_DIST = _sugarext.override _sugarext.defs _sugaruiext_la_LIBADD = \
$(LIB_BINDINGS_LIBS) \
$(LIB_LIBS) \
$(top_builddir)/lib/ui/libsugarui.la
_sugaruiext_la_SOURCES = \
_sugaruiextmodule.c
nodist__sugaruiext_la_SOURCES = _sugaruiext.c
_sugaruiext.c: _sugaruiext.defs _sugaruiext.override
CLEANFILES = \
_sugarext.c \
_sugaruiext.c
EXTRA_DIST = \
_sugarext.override \
_sugarext.defs \
_sugaruiext.defs \
_sugaruiext.override
.defs.c: .defs.c:
(cd $(srcdir)\ (cd $(srcdir)\

View File

@ -1,81 +1,3 @@
;; -*- 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")
)
;; Enumerations and flags ...
;; From sugar-menu.h
(define-method set_min_width
(of-object "SugarMenu")
(c-name "sugar_menu_set_min_width")
(return-type "none")
(parameters
'("gint" "width")
)
)
(define-method popup
(of-object "SugarMenu")
(c-name "sugar_menu_popup")
(return-type "none")
(parameters
'("gint" "x")
'("gint" "y")
)
)
(define-method popdown
(of-object "SugarMenu")
(c-name "sugar_menu_popdown")
(return-type "none")
)
;; 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
(of-object "SugarKeyGrabber")
(c-name "sugar_key_grabber_grab")
(return-type "none")
(parameters
'("const-char*" "key")
)
)
(define-method get_key
(of-object "SugarKeyGrabber")
(c-name "sugar_key_grabber_get_key")
(return-type "char*")
(parameters
'("guint" "keycode")
'("guint" "state")
)
)
; functions ; functions
(define-function get_mime_type_from_file_name (define-function get_mime_type_from_file_name
@ -94,24 +16,6 @@
) )
) )
(define-function x11_set_string_property
(c-name "sugar_x11_util_set_string_property")
(parameters
'("GdkWindow*" "window")
'("const-char*" "property")
'("const-char*" "value")
)
)
(define-function x11_get_string_property
(c-name "sugar_x11_util_get_string_property")
(return-type "char*")
(parameters
'("GdkWindow*" "window")
'("const-char*" "property")
)
)
(define-function get_prgname (define-function get_prgname
(c-name "g_get_prgname") (c-name "g_get_prgname")
(return-type "const-char*") (return-type "const-char*")

View File

@ -2,25 +2,11 @@
%% %%
headers headers
#include <Python.h> #include <Python.h>
#include "pygobject.h"
#include "sugar-address-entry.h"
#include "sugar-key-grabber.h"
#include "sugar-menu.h"
#include "sugar-x11-util.h"
#include "xdgmime.h" #include "xdgmime.h"
#include <pygtk/pygtk.h>
#include <glib.h> #include <glib.h>
%% %%
modulename _sugarext modulename _sugarext
%% %%
import gobject.GObject as PyGObject_Type
import gtk.Entry as PyGtkEntry_Type
import gtk.Menu as PyGtkMenu_Type
import gtk.gdk.Window as PyGdkWindow_Type
%%
ignore-glob ignore-glob
*_get_type *_get_type
_* _*

View File

@ -24,8 +24,6 @@
/* include this first, before NO_IMPORT_PYGOBJECT is defined */ /* include this first, before NO_IMPORT_PYGOBJECT is defined */
#include <pygobject.h> #include <pygobject.h>
void py_sugarext_register_classes (PyObject *d);
extern PyMethodDef py_sugarext_functions[]; extern PyMethodDef py_sugarext_functions[];
DL_EXPORT(void) DL_EXPORT(void)
@ -38,8 +36,6 @@ init_sugarext(void)
m = Py_InitModule ("_sugarext", py_sugarext_functions); m = Py_InitModule ("_sugarext", py_sugarext_functions);
d = PyModule_GetDict (m); d = PyModule_GetDict (m);
py_sugarext_register_classes (d);
if (PyErr_Occurred ()) { if (PyErr_Occurred ()) {
Py_FatalError ("can't initialise module _sugarext"); Py_FatalError ("can't initialise module _sugarext");
} }

97
sugar/_sugaruiext.defs Normal file
View File

@ -0,0 +1,97 @@
;; -*- 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")
)
;; Enumerations and flags ...
;; From sugar-menu.h
(define-method set_min_width
(of-object "SugarMenu")
(c-name "sugar_menu_set_min_width")
(return-type "none")
(parameters
'("gint" "width")
)
)
(define-method popup
(of-object "SugarMenu")
(c-name "sugar_menu_popup")
(return-type "none")
(parameters
'("gint" "x")
'("gint" "y")
)
)
(define-method popdown
(of-object "SugarMenu")
(c-name "sugar_menu_popdown")
(return-type "none")
)
;; 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
(of-object "SugarKeyGrabber")
(c-name "sugar_key_grabber_grab")
(return-type "none")
(parameters
'("const-char*" "key")
)
)
(define-method get_key
(of-object "SugarKeyGrabber")
(c-name "sugar_key_grabber_get_key")
(return-type "char*")
(parameters
'("guint" "keycode")
'("guint" "state")
)
)
; functions
(define-function x11_set_string_property
(c-name "sugar_x11_util_set_string_property")
(parameters
'("GdkWindow*" "window")
'("const-char*" "property")
'("const-char*" "value")
)
)
(define-function x11_get_string_property
(c-name "sugar_x11_util_get_string_property")
(return-type "char*")
(parameters
'("GdkWindow*" "window")
'("const-char*" "property")
)
)

View File

@ -0,0 +1,26 @@
/* -*- Mode: C; c-basic-offset: 4 -*- */
%%
headers
#include <Python.h>
#include "pygobject.h"
#include "sugar-address-entry.h"
#include "sugar-key-grabber.h"
#include "sugar-menu.h"
#include "sugar-x11-util.h"
#include <pygtk/pygtk.h>
#include <glib.h>
%%
modulename _sugarext
%%
import gobject.GObject as PyGObject_Type
import gtk.Entry as PyGtkEntry_Type
import gtk.Menu as PyGtkMenu_Type
import gtk.gdk.Window as PyGdkWindow_Type
%%
ignore-glob
*_get_type
_*
%%

46
sugar/_sugaruiextmodule.c Normal file
View File

@ -0,0 +1,46 @@
/*
* 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>
extern PyMethodDef py_sugaruiext_functions[];
void py_sugaruiext_register_classes (PyObject *d);
DL_EXPORT(void)
init_sugaruiext(void)
{
PyObject *m, *d;
init_pygobject ();
m = Py_InitModule ("_sugaruiext", py_sugaruiext_functions);
d = PyModule_GetDict (m);
py_sugaruiext_register_classes (d);
if (PyErr_Occurred ()) {
Py_FatalError ("can't initialise module _sugaruiext");
}
}

View File

@ -40,7 +40,7 @@ from sugar.graphics.toolcombobox import ToolComboBox
from sugar.datastore import datastore from sugar.datastore import datastore
from sugar import wm from sugar import wm
from sugar import profile from sugar import profile
from sugar import _sugarext from sugar import _sugaruiext
class ActivityToolbar(gtk.Toolbar): class ActivityToolbar(gtk.Toolbar):
SHARE_PRIVATE = 0 SHARE_PRIVATE = 0
@ -289,7 +289,7 @@ class Activity(Window, gtk.Container):
return self._activity_id return self._activity_id
def get_service_name(self): def get_service_name(self):
return _sugarext.get_prgname() return _sugaruiext.get_prgname()
def set_canvas(self, canvas): def set_canvas(self, canvas):
Window.set_canvas(self, canvas) Window.set_canvas(self, canvas)
@ -469,7 +469,7 @@ class Activity(Window, gtk.Container):
def get_bundle_name(): def get_bundle_name():
"""Return the bundle name for the current process' bundle """Return the bundle name for the current process' bundle
""" """
return _sugarext.get_application_name() return _sugaruiext.get_application_name()
def get_bundle_path(): def get_bundle_path():
"""Return the bundle path for the current process' bundle """Return the bundle path for the current process' bundle

View File

@ -17,4 +17,4 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA. # Boston, MA 02111-1307, USA.
from sugar._sugarext import AddressEntry from sugar._sugaruiext import AddressEntry

View File

@ -26,7 +26,7 @@ from sugar.graphics import palettegroup
from sugar.graphics import animator from sugar.graphics import animator
from sugar.graphics import units from sugar.graphics import units
from sugar.graphics import style from sugar.graphics import style
from sugar import _sugarext from sugar import _sugaruiext
_BOTTOM_LEFT = 0 _BOTTOM_LEFT = 0
_BOTTOM_RIGHT = 1 _BOTTOM_RIGHT = 1
@ -87,7 +87,7 @@ class Palette(gobject.GObject):
self._popdown_anim = animator.Animator(0.6, 10) self._popdown_anim = animator.Animator(0.6, 10)
self._popdown_anim.add(_PopdownAnimation(self)) self._popdown_anim.add(_PopdownAnimation(self))
self._menu = _sugarext.Menu() self._menu = _sugaruiext.Menu()
self._menu.set_min_width(units.grid_to_pixels(1)) self._menu.set_min_width(units.grid_to_pixels(1))
self._primary = _PrimaryMenuItem(label, accel_path) self._primary = _PrimaryMenuItem(label, accel_path)

View File

@ -17,22 +17,22 @@
import gtk import gtk
import _sugarext import _sugaruiext
def get_activity_id(wnck_window): def get_activity_id(wnck_window):
window = gtk.gdk.window_foreign_new(wnck_window.get_xid()) window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
return _sugarext.x11_get_string_property( return _sugaruiext.x11_get_string_property(
window, '_SUGAR_ACTIVITY_ID') window, '_SUGAR_ACTIVITY_ID')
def get_bundle_id(wnck_window): def get_bundle_id(wnck_window):
window = gtk.gdk.window_foreign_new(wnck_window.get_xid()) window = gtk.gdk.window_foreign_new(wnck_window.get_xid())
return _sugarext.x11_get_string_property( return _sugaruiext.x11_get_string_property(
window, '_SUGAR_BUNDLE_ID') window, '_SUGAR_BUNDLE_ID')
def set_activity_id(window, activity_id): def set_activity_id(window, activity_id):
_sugarext.x11_set_string_property( _sugaruiext.x11_set_string_property(
window, '_SUGAR_ACTIVITY_ID', activity_id) window, '_SUGAR_ACTIVITY_ID', activity_id)
def set_bundle_id(window, bundle_id): def set_bundle_id(window, bundle_id):
_sugarext.x11_set_string_property( _sugaruiext.x11_set_string_property(
window, '_SUGAR_BUNDLE_ID', bundle_id) window, '_SUGAR_BUNDLE_ID', bundle_id)