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
+1 -1
View File
@@ -1,2 +1,2 @@
_sugarext.c
_sugaruiext.c
+27 -7
View File
@@ -17,16 +17,16 @@ INCLUDES = \
$(LIB_BINDINGS_CFLAGS) \
$(PYTHON_INCLUDES) \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/xdgmime
-I$(top_srcdir)/lib/ui
pkgpyexecdir = $(pythondir)/sugar
pkgpyexec_LTLIBRARIES = _sugarext.la
pkgpyexec_LTLIBRARIES = _sugarext.la _sugaruiext.la
_sugarext_la_LDFLAGS = -module -avoid-version
_sugarext_la_LIBADD = \
$(LIB_BINDINGS_LIBS) \
$(LIB_LIBS) \
_sugarext_la_LIBADD = \
$(LIB_BINDINGS_LIBS) \
$(LIB_LIBS) \
$(top_builddir)/lib/libsugar.la
_sugarext_la_SOURCES = \
@@ -36,8 +36,28 @@ nodist__sugarext_la_SOURCES = _sugarext.c
_sugarext.c: _sugarext.defs _sugarext.override
CLEANFILES = _sugarext.c
EXTRA_DIST = _sugarext.override _sugarext.defs
_sugaruiext_la_LDFLAGS = -module -avoid-version
_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:
(cd $(srcdir)\
-96
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
(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
(c-name "g_get_prgname")
(return-type "const-char*")
-14
View File
@@ -2,25 +2,11 @@
%%
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 "xdgmime.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
_*
-4
View File
@@ -24,8 +24,6 @@
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
#include <pygobject.h>
void py_sugarext_register_classes (PyObject *d);
extern PyMethodDef py_sugarext_functions[];
DL_EXPORT(void)
@@ -38,8 +36,6 @@ init_sugarext(void)
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");
}
+97
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")
)
)
+26
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
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");
}
}
+3 -3
View File
@@ -40,7 +40,7 @@ from sugar.graphics.toolcombobox import ToolComboBox
from sugar.datastore import datastore
from sugar import wm
from sugar import profile
from sugar import _sugarext
from sugar import _sugaruiext
class ActivityToolbar(gtk.Toolbar):
SHARE_PRIVATE = 0
@@ -289,7 +289,7 @@ class Activity(Window, gtk.Container):
return self._activity_id
def get_service_name(self):
return _sugarext.get_prgname()
return _sugaruiext.get_prgname()
def set_canvas(self, canvas):
Window.set_canvas(self, canvas)
@@ -469,7 +469,7 @@ class Activity(Window, gtk.Container):
def get_bundle_name():
"""Return the bundle name for the current process' bundle
"""
return _sugarext.get_application_name()
return _sugaruiext.get_application_name()
def get_bundle_path():
"""Return the bundle path for the current process' bundle
+1 -1
View File
@@ -17,4 +17,4 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
from sugar._sugarext import AddressEntry
from sugar._sugaruiext import AddressEntry
+2 -2
View File
@@ -26,7 +26,7 @@ from sugar.graphics import palettegroup
from sugar.graphics import animator
from sugar.graphics import units
from sugar.graphics import style
from sugar import _sugarext
from sugar import _sugaruiext
_BOTTOM_LEFT = 0
_BOTTOM_RIGHT = 1
@@ -87,7 +87,7 @@ class Palette(gobject.GObject):
self._popdown_anim = animator.Animator(0.6, 10)
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._primary = _PrimaryMenuItem(label, accel_path)
+5 -5
View File
@@ -17,22 +17,22 @@
import gtk
import _sugarext
import _sugaruiext
def get_activity_id(wnck_window):
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')
def get_bundle_id(wnck_window):
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')
def set_activity_id(window, activity_id):
_sugarext.x11_set_string_property(
_sugaruiext.x11_set_string_property(
window, '_SUGAR_ACTIVITY_ID', activity_id)
def set_bundle_id(window, bundle_id):
_sugarext.x11_set_string_property(
_sugaruiext.x11_set_string_property(
window, '_SUGAR_BUNDLE_ID', bundle_id)