Fix popups

This commit is contained in:
Marco Pesenti Gritti 2006-10-20 00:32:54 +02:00
parent d784a906e4
commit 85bf5e0e84
4 changed files with 8 additions and 523 deletions

2
.gitignore vendored
View File

@ -46,7 +46,7 @@ depcomp
libtool
ltmain.sh
m4/intltool.m4
lib/src/_sugar.c
lib/python/_sugar.c
lib/src/sugar-marshal.c
lib/src/sugar-marshal.h
lib/src/stamp-sugar-marshal.c

View File

@ -16,6 +16,7 @@
import gobject
import gtk
import logging
from _sugar import Browser
from _sugar import PushScroller
@ -78,6 +79,7 @@ class WebBrowser(Browser):
def __init__(self):
Browser.__init__(self)
self._popup_creators = []
def do_create_window(self):
popup_creator = _PopupCreator(self.get_toplevel())

View File

@ -1,521 +0,0 @@
/* -- THIS FILE IS GENERATED - DO NOT EDIT *//* -*- Mode: C; c-basic-offset: 4 -*- */
#include <Python.h>
#line 4 "_sugar.override"
#include <Python.h>
#include "pygobject.h"
#include "sugar-browser.h"
#include "sugar-key-grabber.h"
#include "sugar-address-entry.h"
#include "sugar-tray-manager.h"
#include "sugar-push-scroller.h"
#line 18 "_sugar.c"
/* ---------- types from other modules ---------- */
static PyTypeObject *_PyGObject_Type;
#define PyGObject_Type (*_PyGObject_Type)
static PyTypeObject *_PyGtkEntry_Type;
#define PyGtkEntry_Type (*_PyGtkEntry_Type)
static PyTypeObject *_PyGtkMozEmbed_Type;
#define PyGtkMozEmbed_Type (*_PyGtkMozEmbed_Type)
static PyTypeObject *_PyGdkScreen_Type;
#define PyGdkScreen_Type (*_PyGdkScreen_Type)
/* ---------- forward type declarations ---------- */
PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type;
PyTypeObject G_GNUC_INTERNAL PySugarBrowser_Type;
PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type;
PyTypeObject G_GNUC_INTERNAL PySugarTrayManager_Type;
PyTypeObject G_GNUC_INTERNAL PySugarPushScroller_Type;
#line 39 "_sugar.c"
/* ----------- SugarAddressEntry ----------- */
PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"gecko.AddressEntry", /* tp_name */
sizeof(PyGObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)0, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)0, /* tp_compare */
(reprfunc)0, /* tp_repr */
(PyNumberMethods*)0, /* tp_as_number */
(PySequenceMethods*)0, /* tp_as_sequence */
(PyMappingMethods*)0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)0, /* tp_str */
(getattrofunc)0, /* tp_getattro */
(setattrofunc)0, /* tp_setattro */
(PyBufferProcs*)0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
NULL, /* Documentation string */
(traverseproc)0, /* tp_traverse */
(inquiry)0, /* tp_clear */
(richcmpfunc)0, /* tp_richcompare */
offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
(getiterfunc)0, /* tp_iter */
(iternextfunc)0, /* tp_iternext */
(struct PyMethodDef*)NULL, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
(struct PyGetSetDef*)0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)0, /* tp_descr_get */
(descrsetfunc)0, /* tp_descr_set */
offsetof(PyGObject, inst_dict), /* tp_dictoffset */
(initproc)0, /* tp_init */
(allocfunc)0, /* tp_alloc */
(newfunc)0, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)0 /* tp_is_gc */
};
/* ----------- SugarBrowser ----------- */
static PyObject *
_wrap_sugar_browser_create_window(PyGObject *self)
{
SugarBrowser *ret;
ret = sugar_browser_create_window(SUGAR_BROWSER(self->obj));
/* pygobject_new handles NULL checking */
return pygobject_new((GObject *)ret);
}
static const PyMethodDef _PySugarBrowser_methods[] = {
{ "create_window", (PyCFunction)_wrap_sugar_browser_create_window, METH_NOARGS,
NULL },
{ NULL, NULL, 0, NULL }
};
PyTypeObject G_GNUC_INTERNAL PySugarBrowser_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"gecko.Browser", /* tp_name */
sizeof(PyGObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)0, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)0, /* tp_compare */
(reprfunc)0, /* tp_repr */
(PyNumberMethods*)0, /* tp_as_number */
(PySequenceMethods*)0, /* tp_as_sequence */
(PyMappingMethods*)0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)0, /* tp_str */
(getattrofunc)0, /* tp_getattro */
(setattrofunc)0, /* tp_setattro */
(PyBufferProcs*)0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
NULL, /* Documentation string */
(traverseproc)0, /* tp_traverse */
(inquiry)0, /* tp_clear */
(richcmpfunc)0, /* tp_richcompare */
offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
(getiterfunc)0, /* tp_iter */
(iternextfunc)0, /* tp_iternext */
(struct PyMethodDef*)_PySugarBrowser_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
(struct PyGetSetDef*)0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)0, /* tp_descr_get */
(descrsetfunc)0, /* tp_descr_set */
offsetof(PyGObject, inst_dict), /* tp_dictoffset */
(initproc)0, /* tp_init */
(allocfunc)0, /* tp_alloc */
(newfunc)0, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)0 /* tp_is_gc */
};
/* ----------- SugarKeyGrabber ----------- */
static PyObject *
_wrap_sugar_key_grabber_grab(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "key", NULL };
char *key;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:SugarKeyGrabber.grab", kwlist, &key))
return NULL;
sugar_key_grabber_grab(SUGAR_KEY_GRABBER(self->obj), key);
Py_INCREF(Py_None);
return Py_None;
}
static const PyMethodDef _PySugarKeyGrabber_methods[] = {
{ "grab", (PyCFunction)_wrap_sugar_key_grabber_grab, METH_VARARGS|METH_KEYWORDS,
NULL },
{ NULL, NULL, 0, NULL }
};
PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"gecko.KeyGrabber", /* tp_name */
sizeof(PyGObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)0, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)0, /* tp_compare */
(reprfunc)0, /* tp_repr */
(PyNumberMethods*)0, /* tp_as_number */
(PySequenceMethods*)0, /* tp_as_sequence */
(PyMappingMethods*)0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)0, /* tp_str */
(getattrofunc)0, /* tp_getattro */
(setattrofunc)0, /* tp_setattro */
(PyBufferProcs*)0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
NULL, /* Documentation string */
(traverseproc)0, /* tp_traverse */
(inquiry)0, /* tp_clear */
(richcmpfunc)0, /* tp_richcompare */
offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
(getiterfunc)0, /* tp_iter */
(iternextfunc)0, /* tp_iternext */
(struct PyMethodDef*)_PySugarKeyGrabber_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
(struct PyGetSetDef*)0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)0, /* tp_descr_get */
(descrsetfunc)0, /* tp_descr_set */
offsetof(PyGObject, inst_dict), /* tp_dictoffset */
(initproc)0, /* tp_init */
(allocfunc)0, /* tp_alloc */
(newfunc)0, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)0 /* tp_is_gc */
};
/* ----------- SugarTrayManager ----------- */
static PyObject *
_wrap_sugar_tray_manager_manage_screen(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "screen", NULL };
PyGObject *screen;
int ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:SugarTrayManager.manage_screen", kwlist, &PyGdkScreen_Type, &screen))
return NULL;
ret = sugar_tray_manager_manage_screen(SUGAR_TRAY_MANAGER(self->obj), GDK_SCREEN(screen->obj));
return PyBool_FromLong(ret);
}
static PyObject *
_wrap_sugar_tray_manager_set_orientation(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "orientation", NULL };
GtkOrientation orientation;
PyObject *py_orientation = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:SugarTrayManager.set_orientation", kwlist, &py_orientation))
return NULL;
if (pyg_enum_get_value(GTK_TYPE_ORIENTATION, py_orientation, (gpointer)&orientation))
return NULL;
sugar_tray_manager_set_orientation(SUGAR_TRAY_MANAGER(self->obj), orientation);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_sugar_tray_manager_get_orientation(PyGObject *self)
{
gint ret;
ret = sugar_tray_manager_get_orientation(SUGAR_TRAY_MANAGER(self->obj));
return pyg_enum_from_gtype(GTK_TYPE_ORIENTATION, ret);
}
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,
NULL },
{ "get_orientation", (PyCFunction)_wrap_sugar_tray_manager_get_orientation, METH_NOARGS,
NULL },
{ NULL, NULL, 0, NULL }
};
PyTypeObject G_GNUC_INTERNAL PySugarTrayManager_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"gecko.TrayManager", /* tp_name */
sizeof(PyGObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)0, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)0, /* tp_compare */
(reprfunc)0, /* tp_repr */
(PyNumberMethods*)0, /* tp_as_number */
(PySequenceMethods*)0, /* tp_as_sequence */
(PyMappingMethods*)0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)0, /* tp_str */
(getattrofunc)0, /* tp_getattro */
(setattrofunc)0, /* tp_setattro */
(PyBufferProcs*)0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
NULL, /* Documentation string */
(traverseproc)0, /* tp_traverse */
(inquiry)0, /* tp_clear */
(richcmpfunc)0, /* tp_richcompare */
offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
(getiterfunc)0, /* tp_iter */
(iternextfunc)0, /* tp_iternext */
(struct PyMethodDef*)_PySugarTrayManager_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
(struct PyGetSetDef*)0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)0, /* tp_descr_get */
(descrsetfunc)0, /* tp_descr_set */
offsetof(PyGObject, inst_dict), /* tp_dictoffset */
(initproc)0, /* tp_init */
(allocfunc)0, /* tp_alloc */
(newfunc)0, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)0 /* tp_is_gc */
};
/* ----------- SugarPushScroller ----------- */
static PyObject *
_wrap_sugar_push_scroller_start(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "browser", "x", "y", NULL };
PyGObject *browser;
int x, y;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!ii:SugarPushScroller.start", kwlist, &PySugarBrowser_Type, &browser, &x, &y))
return NULL;
sugar_push_scroller_start(SUGAR_PUSH_SCROLLER(self->obj), SUGAR_BROWSER(browser->obj), x, y);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_sugar_push_scroller_stop(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "timestamp", NULL };
unsigned long timestamp;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"k:SugarPushScroller.stop", kwlist, &timestamp))
return NULL;
sugar_push_scroller_stop(SUGAR_PUSH_SCROLLER(self->obj), timestamp);
Py_INCREF(Py_None);
return Py_None;
}
static const PyMethodDef _PySugarPushScroller_methods[] = {
{ "start", (PyCFunction)_wrap_sugar_push_scroller_start, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "stop", (PyCFunction)_wrap_sugar_push_scroller_stop, METH_VARARGS|METH_KEYWORDS,
NULL },
{ NULL, NULL, 0, NULL }
};
PyTypeObject G_GNUC_INTERNAL PySugarPushScroller_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"gecko.PushScroller", /* tp_name */
sizeof(PyGObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)0, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)0, /* tp_compare */
(reprfunc)0, /* tp_repr */
(PyNumberMethods*)0, /* tp_as_number */
(PySequenceMethods*)0, /* tp_as_sequence */
(PyMappingMethods*)0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)0, /* tp_str */
(getattrofunc)0, /* tp_getattro */
(setattrofunc)0, /* tp_setattro */
(PyBufferProcs*)0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
NULL, /* Documentation string */
(traverseproc)0, /* tp_traverse */
(inquiry)0, /* tp_clear */
(richcmpfunc)0, /* tp_richcompare */
offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
(getiterfunc)0, /* tp_iter */
(iternextfunc)0, /* tp_iternext */
(struct PyMethodDef*)_PySugarPushScroller_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
(struct PyGetSetDef*)0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)0, /* tp_descr_get */
(descrsetfunc)0, /* tp_descr_set */
offsetof(PyGObject, inst_dict), /* tp_dictoffset */
(initproc)0, /* tp_init */
(allocfunc)0, /* tp_alloc */
(newfunc)0, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)0 /* tp_is_gc */
};
/* ----------- functions ----------- */
static PyObject *
_wrap_sugar_browser_startup(PyObject *self)
{
sugar_browser_startup();
Py_INCREF(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[] = {
{ "startup_browser", (PyCFunction)_wrap_sugar_browser_startup, METH_NOARGS,
NULL },
{ "tray_manager_check_running", (PyCFunction)_wrap_sugar_tray_manager_check_running, METH_VARARGS|METH_KEYWORDS,
NULL },
{ NULL, NULL, 0, NULL }
};
/* initialise stuff extension classes */
void
py_sugar_register_classes(PyObject *d)
{
PyObject *module;
if ((module = PyImport_ImportModule("gobject")) != NULL) {
_PyGObject_Type = (PyTypeObject *)PyObject_GetAttrString(module, "GObject");
if (_PyGObject_Type == NULL) {
PyErr_SetString(PyExc_ImportError,
"cannot import name GObject from gobject");
return ;
}
} else {
PyErr_SetString(PyExc_ImportError,
"could not import gobject");
return ;
}
if ((module = PyImport_ImportModule("gtkmozembed")) != NULL) {
_PyGtkMozEmbed_Type = (PyTypeObject *)PyObject_GetAttrString(module, "MozEmbed");
if (_PyGtkMozEmbed_Type == NULL) {
PyErr_SetString(PyExc_ImportError,
"cannot import name MozEmbed from gtkmozembed");
return ;
}
} else {
PyErr_SetString(PyExc_ImportError,
"could not import gtkmozembed");
return ;
}
if ((module = PyImport_ImportModule("gtk")) != NULL) {
_PyGtkEntry_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Entry");
if (_PyGtkEntry_Type == NULL) {
PyErr_SetString(PyExc_ImportError,
"cannot import name Entry from gtk");
return ;
}
} else {
PyErr_SetString(PyExc_ImportError,
"could not import gtk");
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 513 "_sugar.c"
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, "SugarKeyGrabber", SUGAR_TYPE_KEY_GRABBER, &PySugarKeyGrabber_Type, Py_BuildValue("(O)", &PyGObject_Type));
pyg_set_object_has_new_constructor(SUGAR_TYPE_KEY_GRABBER);
pygobject_register_class(d, "SugarTrayManager", SUGAR_TYPE_TRAY_MANAGER, &PySugarTrayManager_Type, Py_BuildValue("(O)", &PyGObject_Type));
pyg_set_object_has_new_constructor(SUGAR_TYPE_TRAY_MANAGER);
pygobject_register_class(d, "SugarPushScroller", SUGAR_TYPE_PUSH_SCROLLER, &PySugarPushScroller_Type, Py_BuildValue("(O)", &PyGObject_Type));
pyg_set_object_has_new_constructor(SUGAR_TYPE_PUSH_SCROLLER);
}

View File

@ -65,7 +65,11 @@
(return-type "SugarBrowser*")
)
(define-virtual create_window
(of-object "SugarBrowser")
(c-name "sugar_browser_create_window")
(return-type "SugarBrowser*")
)
;; From sugar-key-grabber.h