diff options
author | Christian Persch <chpe@src.gnome.org> | 2007-08-26 04:59:04 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2007-08-26 04:59:04 +0800 |
commit | 6deabce61b1758b0c395678bf5c2769ee4ca17c6 (patch) | |
tree | 27866c89b34cb0fe866753fbef2894e6dfd01785 /embed/xulrunner/bindings | |
parent | d2bc7076ca31996d4a5b80b74e4380e6f2f56321 (diff) | |
download | gsoc2013-epiphany-6deabce61b1758b0c395678bf5c2769ee4ca17c6.tar gsoc2013-epiphany-6deabce61b1758b0c395678bf5c2769ee4ca17c6.tar.gz gsoc2013-epiphany-6deabce61b1758b0c395678bf5c2769ee4ca17c6.tar.bz2 gsoc2013-epiphany-6deabce61b1758b0c395678bf5c2769ee4ca17c6.tar.lz gsoc2013-epiphany-6deabce61b1758b0c395678bf5c2769ee4ca17c6.tar.xz gsoc2013-epiphany-6deabce61b1758b0c395678bf5c2769ee4ca17c6.tar.zst gsoc2013-epiphany-6deabce61b1758b0c395678bf5c2769ee4ca17c6.zip |
Initial checkin: merged embed/gecko from xulrunner branch to embed/xulrunner, and svn copied embed/mozilla to embed/xulrunner/embed. Not integreated with the build yet.
svn path=/trunk/; revision=7297
Diffstat (limited to 'embed/xulrunner/bindings')
-rw-r--r-- | embed/xulrunner/bindings/Makefile.am | 5 | ||||
-rw-r--r-- | embed/xulrunner/bindings/python/Makefile.am | 63 | ||||
-rw-r--r-- | embed/xulrunner/bindings/python/gnomegeckoembed.defs | 294 | ||||
-rw-r--r-- | embed/xulrunner/bindings/python/gnomegeckoembed.override | 19 | ||||
-rw-r--r-- | embed/xulrunner/bindings/python/gnomegeckoembedmodule.c | 29 | ||||
-rw-r--r-- | embed/xulrunner/bindings/python/test.py | 32 |
6 files changed, 442 insertions, 0 deletions
diff --git a/embed/xulrunner/bindings/Makefile.am b/embed/xulrunner/bindings/Makefile.am new file mode 100644 index 000000000..0f4745056 --- /dev/null +++ b/embed/xulrunner/bindings/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS = + +if ENABLE_PYTHON +SUBDIRS += python +endif diff --git a/embed/xulrunner/bindings/python/Makefile.am b/embed/xulrunner/bindings/python/Makefile.am new file mode 100644 index 000000000..68ed1efe9 --- /dev/null +++ b/embed/xulrunner/bindings/python/Makefile.am @@ -0,0 +1,63 @@ +defsdir = $(datadir)/pygtk/2.0/defs +defs_DATA = gnomegeckoembed.defs + +pkgpythondir = $(pyexecdir)/gtk-2.0 +pkgpyexecdir = $(pyexecdir)/gtk-2.0 + +# gnomegeckoembed module +pkgpyexec_LTLIBRARIES = gnomegeckoembed.la + +gnomegeckoembed_la_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/embed/gecko/src \ + -I$(top_builddir)/embed/gecko/src \ + $(AM_CPPFLAGS) + +gnomegeckoembed_la_CFLAGS = \ + $(GGE_DEPENDENCY_CFLAGS) \ + $(GECKO_CFLAGS) \ + $(NO_STRICT_ALIASING_CFLAGS) \ + $(PYGTK_CFLAGS) \ + $(PYTHON_CFLAGS) \ + $(AM_CFLAGS) + +gnomegeckoembed_la_LIBADD = \ + $(top_builddir)/embed/gecko/src/libgnomegeckoembed-0.0.la \ + $(GECKO_LIBS) \ + $(PYTHON_LIBS) \ + $(PYTHON_EXTRA_LIBS) \ + $(PYGTK_LIBS) + +gnomegeckoembed_la_LDFLAGS = \ + -module -avoid-version \ + -export-symbols-regex initgnomegeckoembed \ + -R$(GECKO_HOME) \ + $(AM_LDFLAGS) + +gnomegeckoembed_la_SOURCES = gnomegeckoembedmodule.c +nodist_gnomegeckoembed_la_SOURCES = gnomegeckoembed.c + +gnomegeckoembed.c: gnomegeckoembed.defs gnomegeckoembed.override +CLEANFILES = gnomegeckoembed.c +EXTRA_DIST = gnomegeckoembed.override gnomegeckoembed.defs + +.defs.c: + (cd $(srcdir)\ + && $(PYGTK_CODEGEN) \ + --override $*.override \ + --prefix py$* $*.defs) > gen-$*.c \ + && cp gen-$*.c $*.c \ + && rm -f gen-$*.c + +BINDING_HEADERS_SRCDIR_IN = \ + src/gecko-embed.h \ + src/gecko-embed-single.h \ + src/gecko-embed-types.h + +BINDING_HEADERS_BUILDDIR_IN = + +BINDING_HEADERS_SRCDIR := $(addprefix $(top_srcdir)/,$(BINDING_HEADERS_SRCDIR_IN)) +BINDING_HEADERS_BUILDDIR := $(addprefix $(top_builddir)/,$(BINDING_HEADERS_BUILDDIR_IN)) + +regenerate-python-binding: + $(PYGTK_H2DEF) $(sort $(BINDING_HEADERS_SRCDIR) $(BINDING_HEADERS_BUILDDIR)) > gnomegeckoembed.defs.new diff --git a/embed/xulrunner/bindings/python/gnomegeckoembed.defs b/embed/xulrunner/bindings/python/gnomegeckoembed.defs new file mode 100644 index 000000000..e3c0f10b5 --- /dev/null +++ b/embed/xulrunner/bindings/python/gnomegeckoembed.defs @@ -0,0 +1,294 @@ +;; -*- scheme -*- +; object definitions ... +(define-object Embed + (in-module "Gecko") + (parent "GtkBin") + (c-name "GeckoEmbed") + (gtype-id "GECKO_TYPE_EMBED") +) + +(define-object EmbedSingle + (in-module "Gecko") + (parent "GObject") + (c-name "GeckoEmbedSingle") + (gtype-id "GECKO_TYPE_EMBED_SINGLE") +) + +;; Enumerations and flags ... + +(define-enum EmbedProgressFlags + (in-module "Gecko") + (c-name "GeckoEmbedProgressFlags") + (gtype-id "GECKO_TYPE_EMBED_PROGRESS_FLAGS") + (values + '("start" "GECKO_EMBED_FLAG_START") + '("redirecting" "GECKO_EMBED_FLAG_REDIRECTING") + '("transferring" "GECKO_EMBED_FLAG_TRANSFERRING") + '("negotiating" "GECKO_EMBED_FLAG_NEGOTIATING") + '("stop" "GECKO_EMBED_FLAG_STOP") + '("is-request" "GECKO_EMBED_FLAG_IS_REQUEST") + '("is-document" "GECKO_EMBED_FLAG_IS_DOCUMENT") + '("is-network" "GECKO_EMBED_FLAG_IS_NETWORK") + '("is-window" "GECKO_EMBED_FLAG_IS_WINDOW") + '("restoring" "GECKO_EMBED_FLAG_RESTORING") + ) +) + +(define-enum EmbedStatusEnum + (in-module "Gecko") + (c-name "GeckoEmbedStatusEnum") + (gtype-id "GECKO_TYPE_EMBED_STATUS_ENUM") + (values + '("dns" "GECKO_EMBED_STATUS_FAILED_DNS") + '("connect" "GECKO_EMBED_STATUS_FAILED_CONNECT") + '("timeout" "GECKO_EMBED_STATUS_FAILED_TIMEOUT") + '("usercanceled" "GECKO_EMBED_STATUS_FAILED_USERCANCELED") + ) +) + +(define-enum EmbedReloadFlags + (in-module "Gecko") + (c-name "GeckoEmbedReloadFlags") + (gtype-id "GECKO_TYPE_EMBED_RELOAD_FLAGS") + (values + '("normal" "GECKO_EMBED_FLAG_RELOADNORMAL") + '("bypasscache" "GECKO_EMBED_FLAG_RELOADBYPASSCACHE") + '("bypassproxy" "GECKO_EMBED_FLAG_RELOADBYPASSPROXY") + '("bypassproxyandcache" "GECKO_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE") + '("charsetchange" "GECKO_EMBED_FLAG_RELOADCHARSETCHANGE") + ) +) + +(define-enum EmbedChromeFlags + (in-module "Gecko") + (c-name "GeckoEmbedChromeFlags") + (gtype-id "GECKO_TYPE_EMBED_CHROME_FLAGS") + (values + '("defaultchrome" "GECKO_EMBED_FLAG_DEFAULTCHROME") + '("windowborderson" "GECKO_EMBED_FLAG_WINDOWBORDERSON") + '("windowcloseon" "GECKO_EMBED_FLAG_WINDOWCLOSEON") + '("windowresizeon" "GECKO_EMBED_FLAG_WINDOWRESIZEON") + '("menubaron" "GECKO_EMBED_FLAG_MENUBARON") + '("toolbaron" "GECKO_EMBED_FLAG_TOOLBARON") + '("locationbaron" "GECKO_EMBED_FLAG_LOCATIONBARON") + '("statusbaron" "GECKO_EMBED_FLAG_STATUSBARON") + '("personaltoolbaron" "GECKO_EMBED_FLAG_PERSONALTOOLBARON") + '("scrollbarson" "GECKO_EMBED_FLAG_SCROLLBARSON") + '("titlebaron" "GECKO_EMBED_FLAG_TITLEBARON") + '("extrachromeon" "GECKO_EMBED_FLAG_EXTRACHROMEON") + '("allchrome" "GECKO_EMBED_FLAG_ALLCHROME") + '("windowraised" "GECKO_EMBED_FLAG_WINDOWRAISED") + '("windowlowered" "GECKO_EMBED_FLAG_WINDOWLOWERED") + '("centerscreen" "GECKO_EMBED_FLAG_CENTERSCREEN") + '("dependent" "GECKO_EMBED_FLAG_DEPENDENT") + '("modal" "GECKO_EMBED_FLAG_MODAL") + '("openasdialog" "GECKO_EMBED_FLAG_OPENASDIALOG") + '("openaschrome" "GECKO_EMBED_FLAG_OPENASCHROME") + ) +) + + +;; From ../../src/gecko-embed-single.h + +(define-function gecko_embed_single_get_type + (c-name "gecko_embed_single_get_type") + (return-type "GType") +) + +(define-function gecko_embed_single_get + (c-name "gecko_embed_single_get") + (return-type "GeckoEmbedSingle*") +) + +(define-function gecko_embed_single_push_startup + (c-name "gecko_embed_single_push_startup") + (return-type "none") +) + +(define-function gecko_embed_single_pop_startup + (c-name "gecko_embed_single_pop_startup") + (return-type "none") +) + +(define-function gecko_embed_single_set_comp_path + (c-name "gecko_embed_single_set_comp_path") + (return-type "none") + (parameters + '("const-char*" "aPath") + ) +) + +(define-function gecko_embed_single_set_profile_path + (c-name "gecko_embed_single_set_profile_path") + (return-type "none") + (parameters + '("const-char*" "aDir") + '("const-char*" "aName") + ) +) + + + +;; From ../../src/gecko-embed-types.h + +(define-function gecko_embed_progress_flags_get_type + (c-name "gecko_embed_progress_flags_get_type") + (return-type "GType") +) + +(define-function gecko_embed_status_enum_get_type + (c-name "gecko_embed_status_enum_get_type") + (return-type "GType") +) + +(define-function gecko_embed_reload_flags_get_type + (c-name "gecko_embed_reload_flags_get_type") + (return-type "GType") +) + +(define-function gecko_embed_chrome_flags_get_type + (c-name "gecko_embed_chrome_flags_get_type") + (return-type "GType") +) + + + +;; From ../../src/gecko-embed.h + +(define-function gecko_embed_get_type + (c-name "gecko_embed_get_type") + (return-type "GType") +) + +(define-function gecko_embed_new + (c-name "gecko_embed_new") + (is-constructor-of "GeckoEmbed") + (return-type "GtkWidget*") +) + +(define-method load_url + (of-object "GeckoEmbed") + (c-name "gecko_embed_load_url") + (return-type "none") + (parameters + '("const-char*" "url") + ) +) + +(define-method stop_load + (of-object "GeckoEmbed") + (c-name "gecko_embed_stop_load") + (return-type "none") +) + +(define-method can_go_back + (of-object "GeckoEmbed") + (c-name "gecko_embed_can_go_back") + (return-type "gboolean") +) + +(define-method can_go_forward + (of-object "GeckoEmbed") + (c-name "gecko_embed_can_go_forward") + (return-type "gboolean") +) + +(define-method go_back + (of-object "GeckoEmbed") + (c-name "gecko_embed_go_back") + (return-type "none") +) + +(define-method go_forward + (of-object "GeckoEmbed") + (c-name "gecko_embed_go_forward") + (return-type "none") +) + +(define-method render_data + (of-object "GeckoEmbed") + (c-name "gecko_embed_render_data") + (return-type "none") + (parameters + '("const-char*" "data") + '("guint32" "len") + '("const-char*" "base_uri") + '("const-char*" "mime_type") + ) +) + +(define-method open_stream + (of-object "GeckoEmbed") + (c-name "gecko_embed_open_stream") + (return-type "none") + (parameters + '("const-char*" "base_uri") + '("const-char*" "mime_type") + ) +) + +(define-method append_data + (of-object "GeckoEmbed") + (c-name "gecko_embed_append_data") + (return-type "none") + (parameters + '("const-char*" "data") + '("guint32" "len") + ) +) + +(define-method close_stream + (of-object "GeckoEmbed") + (c-name "gecko_embed_close_stream") + (return-type "none") +) + +(define-method get_link_message + (of-object "GeckoEmbed") + (c-name "gecko_embed_get_link_message") + (return-type "char*") +) + +(define-method get_js_status + (of-object "GeckoEmbed") + (c-name "gecko_embed_get_js_status") + (return-type "char*") +) + +(define-method get_title + (of-object "GeckoEmbed") + (c-name "gecko_embed_get_title") + (return-type "char*") +) + +(define-method get_location + (of-object "GeckoEmbed") + (c-name "gecko_embed_get_location") + (return-type "char*") +) + +(define-method reload + (of-object "GeckoEmbed") + (c-name "gecko_embed_reload") + (return-type "none") + (parameters + '("gint32" "flags") + ) +) + +(define-method set_chrome_mask + (of-object "GeckoEmbed") + (c-name "gecko_embed_set_chrome_mask") + (return-type "none") + (parameters + '("guint32" "flags") + ) +) + +(define-method get_chrome_mask + (of-object "GeckoEmbed") + (c-name "gecko_embed_get_chrome_mask") + (return-type "guint32") +) + + diff --git a/embed/xulrunner/bindings/python/gnomegeckoembed.override b/embed/xulrunner/bindings/python/gnomegeckoembed.override new file mode 100644 index 000000000..e40fb9afe --- /dev/null +++ b/embed/xulrunner/bindings/python/gnomegeckoembed.override @@ -0,0 +1,19 @@ +%% +headers +#include <Python.h> + +#include "pygobject.h" +#include "gecko-embed.h" +#include "gecko-embed-single.h" + +%% +modulename gnomegeckoembed +%% +import gobject.GObject as PyGObject_Type +import gtk.Object as PyGtkObject_Type +import gtk.Bin as PyGtkBin_Type +%% +ignore-glob + *_get_type + _* +%% diff --git a/embed/xulrunner/bindings/python/gnomegeckoembedmodule.c b/embed/xulrunner/bindings/python/gnomegeckoembedmodule.c new file mode 100644 index 000000000..f7786fa17 --- /dev/null +++ b/embed/xulrunner/bindings/python/gnomegeckoembedmodule.c @@ -0,0 +1,29 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* include this first, before NO_IMPORT_PYGOBJECT is defined */ +#include <pygobject.h> + +void pygtkmozembed_register_classes (PyObject *d); +void pygtkmozembed_add_constants(PyObject *module, const gchar *strip_prefix); + +extern PyMethodDef pygnomegeckoembed_functions[]; + +DL_EXPORT(void) +initgnomegeckoembed(void) +{ + PyObject *m, *d; + + init_pygobject (); + + m = Py_InitModule ("gnomegeckoembed", pygnomegeckoembed_functions); + d = PyModule_GetDict (m); + + pygnomegeckoembed_register_classes (d); + /*pygnomegeckoembed_add_constants(m, "GNOME_GECKO_EMBED_");*/ + + if (PyErr_Occurred ()) { + Py_FatalError ("can't initialise module gnomegeckoembed"); + } +} diff --git a/embed/xulrunner/bindings/python/test.py b/embed/xulrunner/bindings/python/test.py new file mode 100644 index 000000000..d06278e5f --- /dev/null +++ b/embed/xulrunner/bindings/python/test.py @@ -0,0 +1,32 @@ +#! /usr/bin/python +import pygtk +pygtk.require("2.0") +import gtk +import gnomegeckoembed +import os + +class Base: + def destroy(self, widget, data=None): + gtk.main_quit() + + def __init__(self): + gnomegeckoembed.gecko_embed_single_set_comp_path("/usr/lib/firefox") + gnomegeckoembed.gecko_embed_single_push_startup() + self.browser = gnomegeckoembed.Embed() + self.browser.load_url("www.gnome.org") + + self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) + self.window.connect("destroy", self.destroy) + self.window.set_default_size(800, 600) + self.window.add(self.browser) + self.browser.show() + self.window.show() + + def main(self): + gtk.main() + +print __name__ +if __name__ == "__main__": + base = Base() + base.main() + |