A bunch of cleanups. Add some useful properties to the browser.
This commit is contained in:
parent
5101efb75b
commit
5a7a2fedc3
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,6 +8,7 @@ Makefile.in
|
|||||||
*.libs
|
*.libs
|
||||||
*.la
|
*.la
|
||||||
*.lo
|
*.lo
|
||||||
|
*.loT
|
||||||
|
|
||||||
# Absolute
|
# Absolute
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class PopupCreator(gobject.GObject):
|
|||||||
return self._embed
|
return self._embed
|
||||||
|
|
||||||
class Browser(_sugar.Browser):
|
class Browser(_sugar.Browser):
|
||||||
__gtype_name__ = "SugarBrowser"
|
__gtype_name__ = "SugarWebBrowser"
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
_sugar.Browser.__init__(self)
|
_sugar.Browser.__init__(self)
|
||||||
self._popup_creators = []
|
self._popup_creators = []
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
#include "pygobject.h"
|
#include "pygobject.h"
|
||||||
#include "gecko-browser.h"
|
#include "sugar-browser.h"
|
||||||
#include "sugar-key-grabber.h"
|
#include "sugar-key-grabber.h"
|
||||||
#include "sugar-address-entry.h"
|
#include "sugar-address-entry.h"
|
||||||
|
|
||||||
@ -25,201 +25,14 @@ static PyTypeObject *_PyGtkMozEmbed_Type;
|
|||||||
|
|
||||||
|
|
||||||
/* ---------- forward type declarations ---------- */
|
/* ---------- forward type declarations ---------- */
|
||||||
PyTypeObject G_GNUC_INTERNAL PyGeckoBrowser_Type;
|
|
||||||
PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type;
|
PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type;
|
||||||
|
PyTypeObject G_GNUC_INTERNAL PySugarBrowser_Type;
|
||||||
PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type;
|
PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type;
|
||||||
|
|
||||||
#line 33 "_sugar.c"
|
#line 33 "_sugar.c"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------- GeckoBrowser ----------- */
|
|
||||||
|
|
||||||
static int
|
|
||||||
_wrap_gecko_browser_new(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
||||||
{
|
|
||||||
static char* kwlist[] = { NULL };
|
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
||||||
":gecko.Browser.__init__",
|
|
||||||
kwlist))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
pygobject_constructv(self, 0, NULL);
|
|
||||||
if (!self->obj) {
|
|
||||||
PyErr_SetString(
|
|
||||||
PyExc_RuntimeError,
|
|
||||||
"could not create gecko.Browser object");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
_wrap_gecko_browser_create_window(PyGObject *self)
|
|
||||||
{
|
|
||||||
GeckoBrowser *ret;
|
|
||||||
|
|
||||||
|
|
||||||
ret = gecko_browser_create_window(GECKO_BROWSER(self->obj));
|
|
||||||
|
|
||||||
/* pygobject_new handles NULL checking */
|
|
||||||
return pygobject_new((GObject *)ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
_wrap_GeckoBrowser__do_create_window(PyObject *cls, PyObject *args, PyObject *kwargs)
|
|
||||||
{
|
|
||||||
gpointer klass;
|
|
||||||
static char *kwlist[] = { "self", NULL };
|
|
||||||
PyGObject *self;
|
|
||||||
GeckoBrowser *ret;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:GeckoBrowser.create_window", kwlist, &PyGeckoBrowser_Type, &self))
|
|
||||||
return NULL;
|
|
||||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
|
||||||
if (GECKO_BROWSER_CLASS(klass)->create_window)
|
|
||||||
ret = GECKO_BROWSER_CLASS(klass)->create_window(GECKO_BROWSER(self->obj));
|
|
||||||
else {
|
|
||||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GeckoBrowser.create_window not implemented");
|
|
||||||
g_type_class_unref(klass);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
g_type_class_unref(klass);
|
|
||||||
/* pygobject_new handles NULL checking */
|
|
||||||
return pygobject_new((GObject *)ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const PyMethodDef _PyGeckoBrowser_methods[] = {
|
|
||||||
{ "create_window", (PyCFunction)_wrap_gecko_browser_create_window, METH_NOARGS,
|
|
||||||
NULL },
|
|
||||||
{ "do_create_window", (PyCFunction)_wrap_GeckoBrowser__do_create_window, METH_VARARGS|METH_KEYWORDS|METH_CLASS,
|
|
||||||
NULL },
|
|
||||||
{ NULL, NULL, 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
PyTypeObject G_GNUC_INTERNAL PyGeckoBrowser_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*)_PyGeckoBrowser_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)_wrap_gecko_browser_new, /* tp_init */
|
|
||||||
(allocfunc)0, /* tp_alloc */
|
|
||||||
(newfunc)0, /* tp_new */
|
|
||||||
(freefunc)0, /* tp_free */
|
|
||||||
(inquiry)0 /* tp_is_gc */
|
|
||||||
};
|
|
||||||
|
|
||||||
static GeckoBrowser*
|
|
||||||
_wrap_GeckoBrowser__proxy_do_create_window(GeckoBrowser *self)
|
|
||||||
{
|
|
||||||
PyGILState_STATE __py_state;
|
|
||||||
PyObject *py_self;
|
|
||||||
GeckoBrowser* retval;
|
|
||||||
PyObject *py_retval;
|
|
||||||
PyObject *py_method;
|
|
||||||
|
|
||||||
__py_state = pyg_gil_state_ensure();
|
|
||||||
py_self = pygobject_new((GObject *) self);
|
|
||||||
if (!py_self) {
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
PyErr_Print();
|
|
||||||
pyg_gil_state_release(__py_state);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
py_method = PyObject_GetAttrString(py_self, "do_create_window");
|
|
||||||
if (!py_method) {
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
PyErr_Print();
|
|
||||||
Py_DECREF(py_self);
|
|
||||||
pyg_gil_state_release(__py_state);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
py_retval = PyObject_CallObject(py_method, NULL);
|
|
||||||
if (!py_retval) {
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
PyErr_Print();
|
|
||||||
Py_DECREF(py_method);
|
|
||||||
Py_DECREF(py_self);
|
|
||||||
pyg_gil_state_release(__py_state);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!PyObject_TypeCheck(py_retval, &PyGObject_Type)) {
|
|
||||||
PyErr_SetString(PyExc_TypeError, "retval should be a GObject");
|
|
||||||
PyErr_Print();
|
|
||||||
Py_DECREF(py_retval);
|
|
||||||
Py_DECREF(py_method);
|
|
||||||
Py_DECREF(py_self);
|
|
||||||
pyg_gil_state_release(__py_state);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
retval = (GeckoBrowser*) pygobject_get(py_retval);
|
|
||||||
g_object_ref((GObject *) retval);
|
|
||||||
|
|
||||||
|
|
||||||
Py_DECREF(py_retval);
|
|
||||||
Py_DECREF(py_method);
|
|
||||||
Py_DECREF(py_self);
|
|
||||||
pyg_gil_state_release(__py_state);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
__GeckoBrowser_class_init(gpointer gclass, PyTypeObject *pyclass)
|
|
||||||
{
|
|
||||||
PyObject *o;
|
|
||||||
GeckoBrowserClass *klass = GECKO_BROWSER_CLASS(gclass);
|
|
||||||
PyObject *gsignals = PyDict_GetItemString(pyclass->tp_dict, "__gsignals__");
|
|
||||||
|
|
||||||
o = PyObject_GetAttrString((PyObject *) pyclass, "do_create_window");
|
|
||||||
if (o == NULL)
|
|
||||||
PyErr_Clear();
|
|
||||||
else {
|
|
||||||
if (!PyObject_TypeCheck(o, &PyCFunction_Type)
|
|
||||||
&& !(gsignals && PyDict_GetItemString(gsignals, "create_window")))
|
|
||||||
klass->create_window = _wrap_GeckoBrowser__proxy_do_create_window;
|
|
||||||
Py_DECREF(o);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------- SugarAddressEntry ----------- */
|
/* ----------- SugarAddressEntry ----------- */
|
||||||
|
|
||||||
PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type = {
|
PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type = {
|
||||||
@ -269,38 +82,85 @@ PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------- SugarKeyGrabber ----------- */
|
/* ----------- SugarBrowser ----------- */
|
||||||
|
|
||||||
static int
|
static PyObject *
|
||||||
_wrap_sugar_key_grabber_new(PyGObject *self, PyObject *args, PyObject *kwargs)
|
_wrap_sugar_browser_create_window(PyGObject *self)
|
||||||
{
|
{
|
||||||
static char* kwlist[] = { NULL };
|
SugarBrowser *ret;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
||||||
":gecko.KeyGrabber.__init__",
|
|
||||||
kwlist))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
pygobject_constructv(self, 0, NULL);
|
ret = sugar_browser_create_window(SUGAR_BROWSER(self->obj));
|
||||||
if (!self->obj) {
|
|
||||||
PyErr_SetString(
|
/* pygobject_new handles NULL checking */
|
||||||
PyExc_RuntimeError,
|
return pygobject_new((GObject *)ret);
|
||||||
"could not create gecko.KeyGrabber object");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 *
|
static PyObject *
|
||||||
_wrap_sugar_key_grabber_grab(PyGObject *self, PyObject *args, PyObject *kwargs)
|
_wrap_sugar_key_grabber_grab(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
static char *kwlist[] = { "address", NULL };
|
static char *kwlist[] = { "key", NULL };
|
||||||
char *address;
|
char *key;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:SugarKeyGrabber.grab", kwlist, &address))
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:SugarKeyGrabber.grab", kwlist, &key))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
sugar_key_grabber_grab(SUGAR_KEY_GRABBER(self->obj), address);
|
sugar_key_grabber_grab(SUGAR_KEY_GRABBER(self->obj), key);
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
@ -350,7 +210,7 @@ PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_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_key_grabber_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 */
|
||||||
@ -362,17 +222,17 @@ PyTypeObject G_GNUC_INTERNAL PySugarKeyGrabber_Type = {
|
|||||||
/* ----------- functions ----------- */
|
/* ----------- functions ----------- */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_wrap_gecko_browser_startup(PyObject *self)
|
_wrap_sugar_browser_startup(PyObject *self)
|
||||||
{
|
{
|
||||||
|
|
||||||
gecko_browser_startup();
|
sugar_browser_startup();
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PyMethodDef py_sugar_functions[] = {
|
const PyMethodDef py_sugar_functions[] = {
|
||||||
{ "startup_browser", (PyCFunction)_wrap_gecko_browser_startup, METH_NOARGS,
|
{ "startup_browser", (PyCFunction)_wrap_sugar_browser_startup, METH_NOARGS,
|
||||||
NULL },
|
NULL },
|
||||||
{ NULL, NULL, 0, NULL }
|
{ NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
@ -421,11 +281,9 @@ py_sugar_register_classes(PyObject *d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#line 425 "_sugar.c"
|
#line 285 "_sugar.c"
|
||||||
pygobject_register_class(d, "GeckoBrowser", GECKO_TYPE_BROWSER, &PyGeckoBrowser_Type, Py_BuildValue("(O)", &PyGtkMozEmbed_Type));
|
|
||||||
pyg_set_object_has_new_constructor(GECKO_TYPE_BROWSER);
|
|
||||||
pyg_register_class_init(GECKO_TYPE_BROWSER, __GeckoBrowser_class_init);
|
|
||||||
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, "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));
|
||||||
pyg_set_object_has_new_constructor(SUGAR_TYPE_KEY_GRABBER);
|
pyg_set_object_has_new_constructor(SUGAR_TYPE_KEY_GRABBER);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
;; -*- scheme -*-
|
;; -*- scheme -*-
|
||||||
; object definitions ...
|
; object definitions ...
|
||||||
(define-object Browser
|
|
||||||
(in-module "Gecko")
|
|
||||||
(parent "GtkMozEmbed")
|
|
||||||
(c-name "GeckoBrowser")
|
|
||||||
(gtype-id "GECKO_TYPE_BROWSER")
|
|
||||||
)
|
|
||||||
|
|
||||||
(define-object AddressEntry
|
(define-object AddressEntry
|
||||||
(in-module "Sugar")
|
(in-module "Sugar")
|
||||||
(parent "GtkEntry")
|
(parent "GtkEntry")
|
||||||
@ -14,53 +7,57 @@
|
|||||||
(gtype-id "SUGAR_TYPE_ADDRESS_ENTRY")
|
(gtype-id "SUGAR_TYPE_ADDRESS_ENTRY")
|
||||||
)
|
)
|
||||||
|
|
||||||
;; Enumerations and flags ...
|
(define-object Browser
|
||||||
|
(in-module "Sugar")
|
||||||
|
(parent "GtkMozEmbed")
|
||||||
;; From gecko-browser.h
|
(c-name "SugarBrowser")
|
||||||
|
(gtype-id "SUGAR_TYPE_BROWSER")
|
||||||
(define-function get_type
|
|
||||||
(c-name "gecko_browser_get_type")
|
|
||||||
(return-type "GType")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-function startup_browser
|
|
||||||
(c-name "gecko_browser_startup")
|
|
||||||
(return-type "none")
|
|
||||||
)
|
|
||||||
|
|
||||||
(define-function new
|
|
||||||
(c-name "gecko_browser_new")
|
|
||||||
(is-constructor-of "GeckoBrowser")
|
|
||||||
(return-type "GeckoBrowser*")
|
|
||||||
)
|
|
||||||
|
|
||||||
(define-method create_window
|
|
||||||
(of-object "GeckoBrowser")
|
|
||||||
(c-name "gecko_browser_create_window")
|
|
||||||
(return-type "GeckoBrowser*")
|
|
||||||
)
|
|
||||||
|
|
||||||
(define-virtual create_window
|
|
||||||
(of-object "GeckoBrowser")
|
|
||||||
(return-type "GeckoBrowser*")
|
|
||||||
)
|
|
||||||
(define-object KeyGrabber
|
(define-object KeyGrabber
|
||||||
(in-module "globalkeys")
|
(in-module "Sugar")
|
||||||
(parent "GObject")
|
(parent "GObject")
|
||||||
(c-name "SugarKeyGrabber")
|
(c-name "SugarKeyGrabber")
|
||||||
(gtype-id "SUGAR_TYPE_KEY_GRABBER")
|
(gtype-id "SUGAR_TYPE_KEY_GRABBER")
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-function sugar_key_grabber_get_type
|
;; Enumerations and flags ...
|
||||||
(c-name "sugar_key_grabber_get_type")
|
|
||||||
|
|
||||||
|
;; From sugar-address-entry.h
|
||||||
|
|
||||||
|
(define-function sugar_address_entry_get_type
|
||||||
|
(c-name "sugar_address_entry_get_type")
|
||||||
(return-type "GType")
|
(return-type "GType")
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-function sugar_key_grabber_new
|
|
||||||
(c-name "sugar_key_grabber_new")
|
|
||||||
(is-constructor-of "SugarKeyGrabber")
|
;; From sugar-browser.h
|
||||||
(return-type "GObject*")
|
|
||||||
|
(define-function sugar_browser_get_type
|
||||||
|
(c-name "sugar_browser_get_type")
|
||||||
|
(return-type "GType")
|
||||||
|
)
|
||||||
|
|
||||||
|
(define-function startup_browser
|
||||||
|
(c-name "sugar_browser_startup")
|
||||||
|
(return-type "none")
|
||||||
|
)
|
||||||
|
|
||||||
|
(define-method create_window
|
||||||
|
(of-object "SugarBrowser")
|
||||||
|
(c-name "sugar_browser_create_window")
|
||||||
|
(return-type "SugarBrowser*")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;; 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
|
(define-method grab
|
||||||
@ -68,6 +65,8 @@
|
|||||||
(c-name "sugar_key_grabber_grab")
|
(c-name "sugar_key_grabber_grab")
|
||||||
(return-type "none")
|
(return-type "none")
|
||||||
(parameters
|
(parameters
|
||||||
'("const-char*" "address")
|
'("const-char*" "key")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ headers
|
|||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
#include "pygobject.h"
|
#include "pygobject.h"
|
||||||
#include "gecko-browser.h"
|
#include "sugar-browser.h"
|
||||||
#include "sugar-key-grabber.h"
|
#include "sugar-key-grabber.h"
|
||||||
#include "sugar-address-entry.h"
|
#include "sugar-address-entry.h"
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ libsugarprivate_la_LIBADD = $(GECKO_LIBS)
|
|||||||
libsugarprivate_la_SOURCES = \
|
libsugarprivate_la_SOURCES = \
|
||||||
eggaccelerators.h \
|
eggaccelerators.h \
|
||||||
eggaccelerators.c \
|
eggaccelerators.c \
|
||||||
gecko-browser.h \
|
sugar-browser.h \
|
||||||
gecko-browser.cpp \
|
sugar-browser.cpp \
|
||||||
sugar-address-entry.h \
|
sugar-address-entry.h \
|
||||||
sugar-address-entry.c \
|
sugar-address-entry.c \
|
||||||
sugar-key-grabber.h \
|
sugar-key-grabber.h \
|
||||||
|
@ -1,158 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2006 Red Hat, Inc
|
|
||||||
*
|
|
||||||
* Sugar is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Sugar 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
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gecko-browser.h"
|
|
||||||
|
|
||||||
#include <nsCOMPtr.h>
|
|
||||||
#include <nsIPrefService.h>
|
|
||||||
#include <nsServiceManagerUtils.h>
|
|
||||||
|
|
||||||
enum {
|
|
||||||
PROP_0,
|
|
||||||
PROP_PROGRESS
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
gecko_browser_startup(void)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIPrefService> prefService;
|
|
||||||
|
|
||||||
prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
||||||
NS_ENSURE_TRUE(prefService, );
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranch> pref;
|
|
||||||
prefService->GetBranch("", getter_AddRefs(pref));
|
|
||||||
NS_ENSURE_TRUE(pref, );
|
|
||||||
|
|
||||||
pref->SetBoolPref ("dom.disable_open_during_load", TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DEFINE_TYPE(GeckoBrowser, gecko_browser, GTK_TYPE_MOZ_EMBED)
|
|
||||||
|
|
||||||
//static guint signals[N_SIGNALS];
|
|
||||||
|
|
||||||
GeckoBrowser *
|
|
||||||
gecko_browser_new(void)
|
|
||||||
{
|
|
||||||
return GECKO_BROWSER(g_object_new(GECKO_TYPE_BROWSER, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gecko_browser_get_property(GObject *object,
|
|
||||||
guint prop_id,
|
|
||||||
GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
GeckoBrowser *browser = GECKO_BROWSER(object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_PROGRESS:
|
|
||||||
g_value_set_double(value, browser->progress);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gecko_browser_class_init(GeckoBrowserClass *browser_class)
|
|
||||||
{
|
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS(browser_class);
|
|
||||||
|
|
||||||
gobject_class->get_property = gecko_browser_get_property;
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_PROGRESS,
|
|
||||||
g_param_spec_double ("progress",
|
|
||||||
"Progress",
|
|
||||||
"Progress",
|
|
||||||
0.0, 1.0, 0.0,
|
|
||||||
G_PARAM_READABLE));
|
|
||||||
}
|
|
||||||
|
|
||||||
GeckoBrowser *
|
|
||||||
gecko_browser_create_window(GeckoBrowser *browser)
|
|
||||||
{
|
|
||||||
return GECKO_BROWSER_GET_CLASS(browser)->create_window(browser);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
new_window_cb(GtkMozEmbed *embed,
|
|
||||||
GtkMozEmbed **newEmbed,
|
|
||||||
guint chromemask)
|
|
||||||
{
|
|
||||||
GeckoBrowser *browser;
|
|
||||||
|
|
||||||
browser = gecko_browser_create_window(GECKO_BROWSER(embed));
|
|
||||||
|
|
||||||
*newEmbed = GTK_MOZ_EMBED(browser);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gecko_browser_set_progress(GeckoBrowser *browser, float progress)
|
|
||||||
{
|
|
||||||
g_return_if_fail(GECKO_IS_BROWSER(browser));
|
|
||||||
|
|
||||||
browser->progress = progress;
|
|
||||||
g_object_notify (G_OBJECT(browser), "progress");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
net_state_cb(GtkMozEmbed *embed, const char *aURI, gint state, guint status)
|
|
||||||
{
|
|
||||||
GeckoBrowser *browser = GECKO_BROWSER(embed);
|
|
||||||
|
|
||||||
if (state & GTK_MOZ_EMBED_FLAG_IS_NETWORK) {
|
|
||||||
if (state & GTK_MOZ_EMBED_FLAG_START) {
|
|
||||||
browser->total_requests = 0;
|
|
||||||
browser->current_requests = 0;
|
|
||||||
browser->progress = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state & GTK_MOZ_EMBED_FLAG_IS_REQUEST) {
|
|
||||||
float progress;
|
|
||||||
|
|
||||||
if (state & GTK_MOZ_EMBED_FLAG_START) {
|
|
||||||
browser->total_requests++;
|
|
||||||
}
|
|
||||||
else if (state & GTK_MOZ_EMBED_FLAG_STOP)
|
|
||||||
{
|
|
||||||
browser->current_requests++;
|
|
||||||
}
|
|
||||||
|
|
||||||
progress = float(browser->current_requests) /
|
|
||||||
float(browser->total_requests);
|
|
||||||
if (progress > browser->progress) {
|
|
||||||
gecko_browser_set_progress(browser, progress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gecko_browser_init(GeckoBrowser *browser)
|
|
||||||
{
|
|
||||||
browser->progress = 0.0;
|
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(browser), "new-window",
|
|
||||||
G_CALLBACK(new_window_cb), NULL);
|
|
||||||
g_signal_connect(G_OBJECT(browser), "net-state-all",
|
|
||||||
G_CALLBACK(net_state_cb), NULL);
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2006 Red Hat, Inc
|
|
||||||
*
|
|
||||||
* Sugar is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Sugar 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
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GECKO_BROWSER_H__
|
|
||||||
#define __GECKO_BROWSER_H__
|
|
||||||
|
|
||||||
#include <gtkmozembed.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef struct _GeckoBrowser GeckoBrowser;
|
|
||||||
typedef struct _GeckoBrowserClass GeckoBrowserClass;
|
|
||||||
|
|
||||||
#define GECKO_TYPE_BROWSER (gecko_browser_get_type())
|
|
||||||
#define GECKO_BROWSER(object) (G_TYPE_CHECK_INSTANCE_CAST((object), GECKO_TYPE_BROWSER, GeckoBrowser))
|
|
||||||
#define GECKO_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GECKO_TYPE_BROWSER, GeckoBrowserClass))
|
|
||||||
#define GECKO_IS_BROWSER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), GECKO_TYPE_BROWSER))
|
|
||||||
#define GECKO_IS_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GECKO_TYPE_BROWSER))
|
|
||||||
#define GECKO_BROWSER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), GECKO_TYPE_BROWSER, GeckoBrowserClass))
|
|
||||||
|
|
||||||
struct _GeckoBrowser {
|
|
||||||
GtkMozEmbed base_instance;
|
|
||||||
|
|
||||||
int total_requests;
|
|
||||||
int current_requests;
|
|
||||||
float progress;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GeckoBrowserClass {
|
|
||||||
GtkMozEmbedClass base_class;
|
|
||||||
|
|
||||||
GeckoBrowser * (* create_window) (GeckoBrowser *browser);
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gecko_browser_get_type (void);
|
|
||||||
void gecko_browser_startup (void);
|
|
||||||
GeckoBrowser *gecko_browser_new (void);
|
|
||||||
GeckoBrowser *gecko_browser_create_window (GeckoBrowser *browser);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
235
lib/src/sugar-browser.cpp
Normal file
235
lib/src/sugar-browser.cpp
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Red Hat, Inc
|
||||||
|
*
|
||||||
|
* Sugar is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Sugar 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
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sugar-browser.h"
|
||||||
|
|
||||||
|
#include <nsCOMPtr.h>
|
||||||
|
#include <nsIPrefService.h>
|
||||||
|
#include <nsServiceManagerUtils.h>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_PROGRESS,
|
||||||
|
PROP_TITLE,
|
||||||
|
PROP_ADDRESS,
|
||||||
|
PROP_CAN_GO_BACK,
|
||||||
|
PROP_CAN_GO_FORWARD
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
sugar_browser_startup(void)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIPrefService> prefService;
|
||||||
|
|
||||||
|
prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||||
|
NS_ENSURE_TRUE(prefService, );
|
||||||
|
|
||||||
|
nsCOMPtr<nsIPrefBranch> pref;
|
||||||
|
prefService->GetBranch("", getter_AddRefs(pref));
|
||||||
|
NS_ENSURE_TRUE(pref, );
|
||||||
|
|
||||||
|
pref->SetBoolPref ("dom.disable_open_during_load", TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_DEFINE_TYPE(SugarBrowser, sugar_browser, GTK_TYPE_MOZ_EMBED)
|
||||||
|
|
||||||
|
static void
|
||||||
|
sugar_browser_get_property(GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SugarBrowser *browser = SUGAR_BROWSER(object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PROGRESS:
|
||||||
|
g_value_set_double(value, browser->progress);
|
||||||
|
break;
|
||||||
|
case PROP_ADDRESS:
|
||||||
|
g_value_set_string(value, browser->address);
|
||||||
|
break;
|
||||||
|
case PROP_TITLE:
|
||||||
|
g_value_set_string(value, browser->title);
|
||||||
|
break;
|
||||||
|
case PROP_CAN_GO_BACK:
|
||||||
|
g_value_set_boolean(value, browser->can_go_back);
|
||||||
|
break;
|
||||||
|
case PROP_CAN_GO_FORWARD:
|
||||||
|
g_value_set_boolean(value, browser->can_go_forward);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
sugar_browser_class_init(SugarBrowserClass *browser_class)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS(browser_class);
|
||||||
|
|
||||||
|
gobject_class->get_property = sugar_browser_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property(gobject_class, PROP_PROGRESS,
|
||||||
|
g_param_spec_double ("progress",
|
||||||
|
"Progress",
|
||||||
|
"Progress",
|
||||||
|
0.0, 1.0, 0.0,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_ADDRESS,
|
||||||
|
g_param_spec_string ("address",
|
||||||
|
"Address",
|
||||||
|
"Address",
|
||||||
|
"",
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_TITLE,
|
||||||
|
g_param_spec_string ("title",
|
||||||
|
"Title",
|
||||||
|
"Title",
|
||||||
|
"",
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_CAN_GO_BACK,
|
||||||
|
g_param_spec_boolean ("can-go-back",
|
||||||
|
"Can go back",
|
||||||
|
"Can go back",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_CAN_GO_FORWARD,
|
||||||
|
g_param_spec_boolean ("can-go-forward",
|
||||||
|
"Can go forward",
|
||||||
|
"Can go forward",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
SugarBrowser *
|
||||||
|
sugar_browser_create_window(SugarBrowser *browser)
|
||||||
|
{
|
||||||
|
return SUGAR_BROWSER_GET_CLASS(browser)->create_window(browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_navigation_properties(SugarBrowser *browser)
|
||||||
|
{
|
||||||
|
GtkMozEmbed *embed = GTK_MOZ_EMBED(browser);
|
||||||
|
|
||||||
|
browser->can_go_back = gtk_moz_embed_can_go_back(embed);
|
||||||
|
g_object_notify (G_OBJECT(browser), "can_go_back");
|
||||||
|
|
||||||
|
browser->can_go_forward = gtk_moz_embed_can_go_forward(embed);
|
||||||
|
g_object_notify (G_OBJECT(browser), "can_go_forward");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
new_window_cb(GtkMozEmbed *embed,
|
||||||
|
GtkMozEmbed **newEmbed,
|
||||||
|
guint chromemask)
|
||||||
|
{
|
||||||
|
SugarBrowser *browser;
|
||||||
|
|
||||||
|
browser = sugar_browser_create_window(SUGAR_BROWSER(embed));
|
||||||
|
|
||||||
|
*newEmbed = GTK_MOZ_EMBED(browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sugar_browser_set_progress(SugarBrowser *browser, float progress)
|
||||||
|
{
|
||||||
|
g_return_if_fail(SUGAR_IS_BROWSER(browser));
|
||||||
|
|
||||||
|
browser->progress = progress;
|
||||||
|
g_object_notify (G_OBJECT(browser), "progress");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
net_state_cb(GtkMozEmbed *embed, const char *aURI, gint state, guint status)
|
||||||
|
{
|
||||||
|
SugarBrowser *browser = SUGAR_BROWSER(embed);
|
||||||
|
|
||||||
|
if (state & GTK_MOZ_EMBED_FLAG_IS_NETWORK) {
|
||||||
|
if (state & GTK_MOZ_EMBED_FLAG_START) {
|
||||||
|
browser->total_requests = 0;
|
||||||
|
browser->current_requests = 0;
|
||||||
|
browser->progress = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
update_navigation_properties(browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state & GTK_MOZ_EMBED_FLAG_IS_REQUEST) {
|
||||||
|
float progress;
|
||||||
|
|
||||||
|
if (state & GTK_MOZ_EMBED_FLAG_START) {
|
||||||
|
browser->total_requests++;
|
||||||
|
}
|
||||||
|
else if (state & GTK_MOZ_EMBED_FLAG_STOP)
|
||||||
|
{
|
||||||
|
browser->current_requests++;
|
||||||
|
}
|
||||||
|
|
||||||
|
progress = float(browser->current_requests) /
|
||||||
|
float(browser->total_requests);
|
||||||
|
if (progress > browser->progress) {
|
||||||
|
sugar_browser_set_progress(browser, progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
title_cb(GtkMozEmbed *embed)
|
||||||
|
{
|
||||||
|
SugarBrowser *browser = SUGAR_BROWSER(embed);
|
||||||
|
|
||||||
|
g_free(browser->title);
|
||||||
|
browser->title = gtk_moz_embed_get_title(embed);
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT(browser), "title");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
location_cb(GtkMozEmbed *embed)
|
||||||
|
{
|
||||||
|
SugarBrowser *browser = SUGAR_BROWSER(embed);
|
||||||
|
|
||||||
|
g_free(browser->address);
|
||||||
|
browser->address = gtk_moz_embed_get_location(embed);
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT(browser), "address");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sugar_browser_init(SugarBrowser *browser)
|
||||||
|
{
|
||||||
|
browser->title = NULL;
|
||||||
|
browser->address = NULL;
|
||||||
|
browser->progress = 0.0;
|
||||||
|
|
||||||
|
g_signal_connect(G_OBJECT(browser), "new-window",
|
||||||
|
G_CALLBACK(new_window_cb), NULL);
|
||||||
|
g_signal_connect(G_OBJECT(browser), "net-state-all",
|
||||||
|
G_CALLBACK(net_state_cb), NULL);
|
||||||
|
g_signal_connect(G_OBJECT(browser), "title",
|
||||||
|
G_CALLBACK(title_cb), NULL);
|
||||||
|
g_signal_connect(G_OBJECT(browser), "location",
|
||||||
|
G_CALLBACK(location_cb), NULL);
|
||||||
|
}
|
60
lib/src/sugar-browser.h
Normal file
60
lib/src/sugar-browser.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Red Hat, Inc
|
||||||
|
*
|
||||||
|
* Sugar is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Sugar 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
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __SUGAR_BROWSER_H__
|
||||||
|
#define __SUGAR_BROWSER_H__
|
||||||
|
|
||||||
|
#include <gtkmozembed.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct _SugarBrowser SugarBrowser;
|
||||||
|
typedef struct _SugarBrowserClass SugarBrowserClass;
|
||||||
|
|
||||||
|
#define SUGAR_TYPE_BROWSER (sugar_browser_get_type())
|
||||||
|
#define SUGAR_BROWSER(object) (G_TYPE_CHECK_INSTANCE_CAST((object), SUGAR_TYPE_BROWSER, SugarBrowser))
|
||||||
|
#define SUGAR_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SUGAR_TYPE_BROWSER, SugarBrowserClass))
|
||||||
|
#define SUGAR_IS_BROWSER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), SUGAR_TYPE_BROWSER))
|
||||||
|
#define SUGAR_IS_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SUGAR_TYPE_BROWSER))
|
||||||
|
#define SUGAR_BROWSER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), SUGAR_TYPE_BROWSER, SugarBrowserClass))
|
||||||
|
|
||||||
|
struct _SugarBrowser {
|
||||||
|
GtkMozEmbed base_instance;
|
||||||
|
|
||||||
|
int total_requests;
|
||||||
|
int current_requests;
|
||||||
|
float progress;
|
||||||
|
char *address;
|
||||||
|
char *title;
|
||||||
|
gboolean can_go_back;
|
||||||
|
gboolean can_go_forward;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _SugarBrowserClass {
|
||||||
|
GtkMozEmbedClass base_class;
|
||||||
|
|
||||||
|
SugarBrowser * (* create_window) (SugarBrowser *browser);
|
||||||
|
};
|
||||||
|
|
||||||
|
GType sugar_browser_get_type (void);
|
||||||
|
void sugar_browser_startup (void);
|
||||||
|
SugarBrowser *sugar_browser_create_window (SugarBrowser *browser);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
@ -33,22 +33,6 @@
|
|||||||
* for these set */
|
* for these set */
|
||||||
#define USED_MODS (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
|
#define USED_MODS (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
|
||||||
|
|
||||||
struct _SugarKeyGrabber {
|
|
||||||
GObject base_instance;
|
|
||||||
|
|
||||||
GdkWindow *root;
|
|
||||||
GList *keys;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _SugarKeyGrabberClass {
|
|
||||||
GObjectClass base_class;
|
|
||||||
|
|
||||||
void (* key_pressed) (SugarKeyGrabber *grabber,
|
|
||||||
const char *key);
|
|
||||||
void (* key_released) (SugarKeyGrabber *grabber,
|
|
||||||
const char *key);
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
KEY_PRESSED,
|
KEY_PRESSED,
|
||||||
KEY_RELEASED,
|
KEY_RELEASED,
|
||||||
|
@ -34,8 +34,23 @@ typedef struct _SugarKeyGrabberPrivate SugarKeyGrabberPrivate;
|
|||||||
#define SUGAR_IS_KEYGRABBER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SUGAR_TYPE_KEY_GRABBER))
|
#define SUGAR_IS_KEYGRABBER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SUGAR_TYPE_KEY_GRABBER))
|
||||||
#define SUGAR_KEY_GRABBER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), SUGAR_TYPE_KEY_GRABBER, SugarKeyGrabberClass))
|
#define SUGAR_KEY_GRABBER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), SUGAR_TYPE_KEY_GRABBER, SugarKeyGrabberClass))
|
||||||
|
|
||||||
|
struct _SugarKeyGrabber {
|
||||||
|
GObject base_instance;
|
||||||
|
|
||||||
|
GdkWindow *root;
|
||||||
|
GList *keys;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _SugarKeyGrabberClass {
|
||||||
|
GObjectClass base_class;
|
||||||
|
|
||||||
|
void (* key_pressed) (SugarKeyGrabber *grabber,
|
||||||
|
const char *key);
|
||||||
|
void (* key_released) (SugarKeyGrabber *grabber,
|
||||||
|
const char *key);
|
||||||
|
};
|
||||||
|
|
||||||
GType sugar_key_grabber_get_type (void);
|
GType sugar_key_grabber_get_type (void);
|
||||||
GObject *sugar_key_grabber_new (void);
|
|
||||||
void sugar_key_grabber_grab (SugarKeyGrabber *grabber,
|
void sugar_key_grabber_grab (SugarKeyGrabber *grabber,
|
||||||
const char *key);
|
const char *key);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user