Get the tray icon to sort of work.

This commit is contained in:
Marco Pesenti Gritti 2006-10-16 18:43:04 +02:00
parent 0d2caab8a1
commit 5e503f77d1
5 changed files with 70 additions and 31 deletions

View File

@ -26,6 +26,7 @@ EXTRA_DIST = _sugar.override _sugar.defs
.defs.c: .defs.c:
(cd $(srcdir)\ (cd $(srcdir)\
&& $(PYGTK_CODEGEN) \ && $(PYGTK_CODEGEN) \
--register $(PYGTK_DEFSDIR)/gdk-types.defs \
--register $(PYGTK_DEFSDIR)/gtk-types.defs \ --register $(PYGTK_DEFSDIR)/gtk-types.defs \
--register $(GNOMEPYTHONEXTRAS_DEFSDIR)/gtkmozembed.defs \ --register $(GNOMEPYTHONEXTRAS_DEFSDIR)/gtkmozembed.defs \
--override $*.override \ --override $*.override \

View File

@ -23,6 +23,8 @@ static PyTypeObject *_PyGtkEntry_Type;
#define PyGtkEntry_Type (*_PyGtkEntry_Type) #define PyGtkEntry_Type (*_PyGtkEntry_Type)
static PyTypeObject *_PyGtkMozEmbed_Type; static PyTypeObject *_PyGtkMozEmbed_Type;
#define PyGtkMozEmbed_Type (*_PyGtkMozEmbed_Type) #define PyGtkMozEmbed_Type (*_PyGtkMozEmbed_Type)
static PyTypeObject *_PyGdkScreen_Type;
#define PyGdkScreen_Type (*_PyGdkScreen_Type)
/* ---------- forward type declarations ---------- */ /* ---------- forward type declarations ---------- */
@ -31,7 +33,7 @@ PyTypeObject G_GNUC_INTERNAL PySugarBrowser_Type;
PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type; PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type;
PyTypeObject G_GNUC_INTERNAL PySugarTrayManager_Type; PyTypeObject G_GNUC_INTERNAL PySugarTrayManager_Type;
#line 35 "_sugar.c" #line 37 "_sugar.c"
@ -223,24 +225,20 @@ PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type = {
/* ----------- SugarTrayManager ----------- */ /* ----------- SugarTrayManager ----------- */
static int static PyObject *
_wrap_sugar_tray_manager_new(PyGObject *self, PyObject *args, PyObject *kwargs) _wrap_sugar_tray_manager_manage_screen(PyGObject *self, PyObject *args, PyObject *kwargs)
{ {
static char* kwlist[] = { NULL }; static char *kwlist[] = { "screen", NULL };
PyGObject *screen;
int ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:SugarTrayManager.manage_screen", kwlist, &PyGdkScreen_Type, &screen))
":gecko.TrayManager.__init__", return NULL;
kwlist))
return -1; ret = sugar_tray_manager_manage_screen(SUGAR_TRAY_MANAGER(self->obj), GDK_SCREEN(screen->obj));
return PyBool_FromLong(ret);
pygobject_constructv(self, 0, NULL);
if (!self->obj) {
PyErr_SetString(
PyExc_RuntimeError,
"could not create gecko.TrayManager object");
return -1;
}
return 0;
} }
static PyObject * static PyObject *
@ -273,6 +271,8 @@ _wrap_sugar_tray_manager_get_orientation(PyGObject *self)
} }
static const PyMethodDef _PySugarTrayManager_methods[] = { static const PyMethodDef _PySugarTrayManager_methods[] = {
{ "manage_screen", (PyCFunction)_wrap_sugar_tray_manager_manage_screen, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "set_orientation", (PyCFunction)_wrap_sugar_tray_manager_set_orientation, METH_VARARGS|METH_KEYWORDS, { "set_orientation", (PyCFunction)_wrap_sugar_tray_manager_set_orientation, METH_VARARGS|METH_KEYWORDS,
NULL }, NULL },
{ "get_orientation", (PyCFunction)_wrap_sugar_tray_manager_get_orientation, METH_NOARGS, { "get_orientation", (PyCFunction)_wrap_sugar_tray_manager_get_orientation, METH_NOARGS,
@ -318,7 +318,7 @@ PyTypeObject G_GNUC_INTERNAL PySugarTrayManager_Type = {
(descrgetfunc)0, /* tp_descr_get */ (descrgetfunc)0, /* tp_descr_get */
(descrsetfunc)0, /* tp_descr_set */ (descrsetfunc)0, /* tp_descr_set */
offsetof(PyGObject, inst_dict), /* tp_dictoffset */ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
(initproc)_wrap_sugar_tray_manager_new, /* tp_init */ (initproc)0, /* tp_init */
(allocfunc)0, /* tp_alloc */ (allocfunc)0, /* tp_alloc */
(newfunc)0, /* tp_new */ (newfunc)0, /* tp_new */
(freefunc)0, /* tp_free */ (freefunc)0, /* tp_free */
@ -339,9 +339,27 @@ _wrap_sugar_browser_startup(PyObject *self)
return Py_None; return Py_None;
} }
static PyObject *
_wrap_sugar_tray_manager_check_running(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "screen", NULL };
PyGObject *screen;
int ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:tray_manager_check_running", kwlist, &PyGdkScreen_Type, &screen))
return NULL;
ret = sugar_tray_manager_check_running(GDK_SCREEN(screen->obj));
return PyBool_FromLong(ret);
}
const PyMethodDef py_sugar_functions[] = { const PyMethodDef py_sugar_functions[] = {
{ "startup_browser", (PyCFunction)_wrap_sugar_browser_startup, METH_NOARGS, { "startup_browser", (PyCFunction)_wrap_sugar_browser_startup, METH_NOARGS,
NULL }, NULL },
{ "tray_manager_check_running", (PyCFunction)_wrap_sugar_tray_manager_check_running, METH_VARARGS|METH_KEYWORDS,
NULL },
{ NULL, NULL, 0, NULL } { NULL, NULL, 0, NULL }
}; };
@ -387,9 +405,21 @@ py_sugar_register_classes(PyObject *d)
"could not import gtk"); "could not import gtk");
return ; return ;
} }
if ((module = PyImport_ImportModule("gtk.gdk")) != NULL) {
_PyGdkScreen_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Screen");
if (_PyGdkScreen_Type == NULL) {
PyErr_SetString(PyExc_ImportError,
"cannot import name Screen from gtk.gdk");
return ;
}
} else {
PyErr_SetString(PyExc_ImportError,
"could not import gtk.gdk");
return ;
}
#line 393 "_sugar.c" #line 423 "_sugar.c"
pygobject_register_class(d, "SugarAddressEntry", SUGAR_TYPE_ADDRESS_ENTRY, &PySugarAddressEntry_Type, Py_BuildValue("(O)", &PyGtkEntry_Type)); pygobject_register_class(d, "SugarAddressEntry", SUGAR_TYPE_ADDRESS_ENTRY, &PySugarAddressEntry_Type, Py_BuildValue("(O)", &PyGtkEntry_Type));
pygobject_register_class(d, "SugarBrowser", SUGAR_TYPE_BROWSER, &PySugarBrowser_Type, Py_BuildValue("(O)", &PyGtkMozEmbed_Type)); pygobject_register_class(d, "SugarBrowser", SUGAR_TYPE_BROWSER, &PySugarBrowser_Type, Py_BuildValue("(O)", &PyGtkMozEmbed_Type));
pygobject_register_class(d, "SugarKeyGrabber", SUGAR_TYPE_KEY_GRABBER, &PySugarKeyGrabber_Type, Py_BuildValue("(O)", &PyGObject_Type)); pygobject_register_class(d, "SugarKeyGrabber", SUGAR_TYPE_KEY_GRABBER, &PySugarKeyGrabber_Type, Py_BuildValue("(O)", &PyGObject_Type));

View File

@ -21,6 +21,13 @@
(gtype-id "SUGAR_TYPE_KEY_GRABBER") (gtype-id "SUGAR_TYPE_KEY_GRABBER")
) )
(define-object TrayManager
(in-module "Sugar")
(parent "GObject")
(c-name "SugarTrayManager")
(gtype-id "SUGAR_TYPE_TRAY_MANAGER")
)
;; Enumerations and flags ... ;; Enumerations and flags ...
@ -69,19 +76,6 @@
) )
) )
;; -*- scheme -*-
; object definitions ...
(define-object TrayManager
(in-module "Sugar")
(parent "GObject")
(c-name "SugarTrayManager")
(gtype-id "SUGAR_TYPE_TRAY_MANAGER")
)
;; Enumerations and flags ...
;; From sugar-tray-manager.h ;; From sugar-tray-manager.h
(define-function tray_manager_get_type (define-function tray_manager_get_type

View File

@ -12,9 +12,13 @@ headers
%% %%
modulename gecko modulename gecko
%% %%
ignore
sugar_tray_manager_new
%%
import gobject.GObject as PyGObject_Type import gobject.GObject as PyGObject_Type
import gtk.Entry as PyGtkEntry_Type import gtk.Entry as PyGtkEntry_Type
import gtkmozembed.MozEmbed as PyGtkMozEmbed_Type import gtkmozembed.MozEmbed as PyGtkMozEmbed_Type
import gtk.gdk.Screen as PyGdkScreen_Type
%% %%
ignore-glob ignore-glob
*_get_type *_get_type

View File

@ -23,6 +23,7 @@ from view.frame.ActivitiesBox import ActivitiesBox
from view.frame.ZoomBox import ZoomBox from view.frame.ZoomBox import ZoomBox
from view.frame.FriendsBox import FriendsBox from view.frame.FriendsBox import FriendsBox
from view.frame.PanelWindow import PanelWindow from view.frame.PanelWindow import PanelWindow
from view.frame.notificationtray import NotificationTray
from sugar.graphics.timeline import Timeline from sugar.graphics.timeline import Timeline
from sugar.graphics.menushell import MenuShell from sugar.graphics.menushell import MenuShell
from sugar.graphics.grid import Grid from sugar.graphics.grid import Grid
@ -152,6 +153,15 @@ class Frame:
[x, y] = grid.point(1, 0) [x, y] = grid.point(1, 0)
top_panel.move(box, x, y) top_panel.move(box, x, y)
tray = NotificationTray()
box = hippo.CanvasWidget()
box.props.widget = tray
top_panel.append(box, hippo.PACK_FIXED)
[x, y] = grid.point(5, 0)
top_panel.move(box, x, y)
bottom_panel = self._create_panel(grid, 0, 11, 16, 1) bottom_panel = self._create_panel(grid, 0, 11, 16, 1)
box = ActivitiesBox(self._shell) box = ActivitiesBox(self._shell)