Cut and paste the mozembed bindings instead of depending on the

external ones. This is necessary to be able to support 1.9.
This commit is contained in:
Marco Pesenti Gritti 2007-01-23 20:33:56 +01:00
parent 0d4e7cdb0a
commit 1d6f0a11c4
10 changed files with 564 additions and 13 deletions

1
.gitignore vendored
View File

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

View File

@ -45,9 +45,6 @@ AC_SUBST(MOZILLA_HOME)
MOZILLA_INCLUDE_DIR="`$PKG_CONFIG --variable=includedir $mozpackage-gtkmozembed`" MOZILLA_INCLUDE_DIR="`$PKG_CONFIG --variable=includedir $mozpackage-gtkmozembed`"
AC_SUBST(MOZILLA_INCLUDE_DIR) AC_SUBST(MOZILLA_INCLUDE_DIR)
GNOMEPYTHONEXTRAS_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
AC_SUBST(GNOMEPYTHONEXTRAS_DEFSDIR)
PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0` PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
AC_SUBST(PYGTK_DEFSDIR) AC_SUBST(PYGTK_DEFSDIR)

View File

@ -20,17 +20,16 @@ _sugar_la_SOURCES = \
nodist__sugar_la_SOURCES = _sugar.c nodist__sugar_la_SOURCES = _sugar.c
_sugar.c: _sugar.defs _sugar.override _sugar.c: _sugar.defs gtkmozembed.defs _sugar.override gtkmozembed.override
CLEANFILES = _sugar.c CLEANFILES = _sugar.c
EXTRA_DIST = _sugar.override _sugar.defs EXTRA_DIST = _sugar.override _sugar.defs gtkmozembed.defs gtkmozembed.override
.defs.c: .defs.c:
(cd $(srcdir)\ (cd $(srcdir)\
&& $(PYGTK_CODEGEN) \ && $(PYGTK_CODEGEN) \
--register $(PYGTK_DEFSDIR)/gdk-types.defs \ --register $(PYGTK_DEFSDIR)/gdk-types.defs \
--register $(PYGTK_DEFSDIR)/gtk-types.defs \ --register $(PYGTK_DEFSDIR)/gtk-types.defs \
--register $(GNOMEPYTHONEXTRAS_DEFSDIR)/gtkmozembed.defs \
--override $*.override \ --override $*.override \
--prefix py$* $*.defs) > gen-$*.c \ --prefix py$* $*.defs) > gen-$*.c \
&& cp gen-$*.c $*.c \ && cp gen-$*.c $*.c \

View File

@ -76,11 +76,20 @@
(return-type "GType") (return-type "GType")
) )
(define-function startup_browser (define-function browser_startup
(c-name "sugar_browser_startup") (c-name "sugar_browser_startup")
(parameters
'("const-char*" "profile_path")
'("const-char*" "profile_name")
)
(return-type "gboolean") (return-type "gboolean")
) )
(define-function browser_shutdown
(c-name "sugar_browser_shutdown")
(return-type "none")
)
(define-method grab_focus (define-method grab_focus
(of-object "SugarBrowser") (of-object "SugarBrowser")
(c-name "sugar_browser_grab_focus") (c-name "sugar_browser_grab_focus")
@ -275,4 +284,4 @@
) )
) )
(include "gtkmozembed.defs")

View File

@ -27,7 +27,6 @@ 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 gtk.gdk.Screen as PyGdkScreen_Type import gtk.gdk.Screen as PyGdkScreen_Type
import gtk.gdk.Pixbuf as PyGdkPixbuf_Type import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
import hippo.CanvasImage as HippoCanvasImage_Type import hippo.CanvasImage as HippoCanvasImage_Type
@ -36,6 +35,9 @@ ignore-glob
*_get_type *_get_type
_* _*
%% %%
include
gtkmozembed.override
%%
override sugar_hippo_canvas_image_set_image_from_gdk_pixbuf kwargs override sugar_hippo_canvas_image_set_image_from_gdk_pixbuf kwargs
static cairo_surface_t * static cairo_surface_t *
_cairo_surface_from_pixbuf (GdkPixbuf *pixbuf) _cairo_surface_from_pixbuf (GdkPixbuf *pixbuf)

475
lib/python/gtkmozembed.defs Normal file
View File

@ -0,0 +1,475 @@
;; -*- scheme -*-
; object definitions ...
(define-object MozEmbed
(in-module "Gtk")
(parent "GtkBin")
(c-name "GtkMozEmbed")
(gtype-id "GTK_TYPE_MOZ_EMBED")
)
; (define-object MozEmbedSingle
; (in-module "Gtk")
; (parent "GtkObject")
; (c-name "GtkMozEmbedSingle")
; (gtype-id "GTK_TYPE_MOZ_EMBED_SINGLE")
; )
;; Enumerations and flags ...
(define-enum MozEmbedProgressFlags
(in-module "Gtk")
(c-name "GtkMozEmbedProgressFlags")
(values
'("start" "GTK_MOZ_EMBED_FLAG_START")
'("redirecting" "GTK_MOZ_EMBED_FLAG_REDIRECTING")
'("transferring" "GTK_MOZ_EMBED_FLAG_TRANSFERRING")
'("negotiating" "GTK_MOZ_EMBED_FLAG_NEGOTIATING")
'("stop" "GTK_MOZ_EMBED_FLAG_STOP")
'("is-request" "GTK_MOZ_EMBED_FLAG_IS_REQUEST")
'("is-document" "GTK_MOZ_EMBED_FLAG_IS_DOCUMENT")
'("is-network" "GTK_MOZ_EMBED_FLAG_IS_NETWORK")
'("is-window" "GTK_MOZ_EMBED_FLAG_IS_WINDOW")
)
)
(define-enum MozEmbedStatusFlags
(in-module "Gtk")
(c-name "GtkMozEmbedStatusFlags")
(values
'("dns" "GTK_MOZ_EMBED_STATUS_FAILED_DNS")
'("connect" "GTK_MOZ_EMBED_STATUS_FAILED_CONNECT")
'("timeout" "GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT")
'("usercanceled" "GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED")
)
)
(define-enum MozEmbedReloadFlags
(in-module "Gtk")
(c-name "GtkMozEmbedReloadFlags")
(values
'("normal" "GTK_MOZ_EMBED_FLAG_RELOADNORMAL")
'("bypasscache" "GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE")
'("bypassproxy" "GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXY")
'("bypassproxyandcache" "GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE")
'("charsetchange" "GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE")
)
)
(define-enum MozEmbedChromeFlags
(in-module "Gtk")
(c-name "GtkMozEmbedChromeFlags")
(values
'("defaultchrome" "GTK_MOZ_EMBED_FLAG_DEFAULTCHROME")
'("windowborderson" "GTK_MOZ_EMBED_FLAG_WINDOWBORDERSON")
'("windowcloseon" "GTK_MOZ_EMBED_FLAG_WINDOWCLOSEON")
'("windowresizeon" "GTK_MOZ_EMBED_FLAG_WINDOWRESIZEON")
'("menubaron" "GTK_MOZ_EMBED_FLAG_MENUBARON")
'("toolbaron" "GTK_MOZ_EMBED_FLAG_TOOLBARON")
'("locationbaron" "GTK_MOZ_EMBED_FLAG_LOCATIONBARON")
'("statusbaron" "GTK_MOZ_EMBED_FLAG_STATUSBARON")
'("personaltoolbaron" "GTK_MOZ_EMBED_FLAG_PERSONALTOOLBARON")
'("scrollbarson" "GTK_MOZ_EMBED_FLAG_SCROLLBARSON")
'("titlebaron" "GTK_MOZ_EMBED_FLAG_TITLEBARON")
'("extrachromeon" "GTK_MOZ_EMBED_FLAG_EXTRACHROMEON")
'("allchrome" "GTK_MOZ_EMBED_FLAG_ALLCHROME")
'("windowraised" "GTK_MOZ_EMBED_FLAG_WINDOWRAISED")
'("windowlowered" "GTK_MOZ_EMBED_FLAG_WINDOWLOWERED")
'("centerscreen" "GTK_MOZ_EMBED_FLAG_CENTERSCREEN")
'("dependent" "GTK_MOZ_EMBED_FLAG_DEPENDENT")
'("modal" "GTK_MOZ_EMBED_FLAG_MODAL")
'("openasdialog" "GTK_MOZ_EMBED_FLAG_OPENASDIALOG")
'("openaschrome" "GTK_MOZ_EMBED_FLAG_OPENASCHROME")
)
)
;; From /usr/include/mozilla-1.2b/gtkembedmoz/gtkmozembed.h
(define-function gtk_moz_embed_get_type
(c-name "gtk_moz_embed_get_type")
(return-type "GtkType")
)
(define-function gtk_moz_embed_new
(c-name "gtk_moz_embed_new")
(is-constructor-of "GtkMozEmbed")
(return-type "GtkWidget*")
)
(define-function push_startup
(c-name "gtk_moz_embed_push_startup")
(return-type "none")
)
(define-function pop_startup
(c-name "gtk_moz_embed_pop_startup")
(return-type "none")
)
(define-function gtk_moz_embed_set_comp_path
(c-name "gtk_moz_embed_set_comp_path_deprecated")
(return-type "none")
(parameters
'("char*" "aPath")
)
(deprecated "renamed to gtkmozembed.set_comp_path")
)
(define-function set_comp_path
(c-name "gtk_moz_embed_set_comp_path")
(return-type "none")
(parameters
'("char*" "aPath")
)
)
(define-function gtk_moz_embed_set_profile_path
(c-name "gtk_moz_embed_set_profile_path_deprecated")
(return-type "none")
(parameters
'("char*" "aDir")
'("char*" "aName")
)
(deprecated "renamed to gtkmozembed.set_profile_path")
)
(define-function set_profile_path
(c-name "gtk_moz_embed_set_profile_path")
(return-type "none")
(parameters
'("char*" "aDir")
'("char*" "aName")
)
)
(define-method load_url
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_load_url")
(return-type "none")
(parameters
'("const-char*" "url")
)
)
(define-method stop_load
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_stop_load")
(return-type "none")
)
(define-method can_go_back
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_can_go_back")
(return-type "gboolean")
)
(define-method can_go_forward
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_can_go_forward")
(return-type "gboolean")
)
(define-method go_back
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_go_back")
(return-type "none")
)
(define-method go_forward
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_go_forward")
(return-type "none")
)
(define-method render_data
(of-object "GtkMozEmbed")
(c-name "gtk_moz_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 "GtkMozEmbed")
(c-name "gtk_moz_embed_open_stream")
(return-type "none")
(parameters
'("const-char*" "base_uri")
'("const-char*" "mime_type")
)
)
(define-method append_data
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_append_data")
(return-type "none")
(parameters
'("const-char*" "data")
'("guint32" "len")
)
)
(define-method close_stream
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_close_stream")
(return-type "none")
)
(define-method get_link_message
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_get_link_message")
(return-type "char*")
)
(define-method get_js_status
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_get_js_status")
(return-type "char*")
)
(define-method get_title
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_get_title")
(return-type "char*")
)
(define-method get_location
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_get_location")
(return-type "char*")
)
(define-method reload
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_reload")
(return-type "none")
(parameters
'("gint32" "flags")
)
)
(define-method set_chrome_mask
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_set_chrome_mask")
(return-type "none")
(parameters
'("guint32" "flags")
)
)
(define-method get_chrome_mask
(of-object "GtkMozEmbed")
(c-name "gtk_moz_embed_get_chrome_mask")
(return-type "guint32")
)
; (define-function gtk_moz_embed_progress_flags_get_type
; (c-name "gtk_moz_embed_progress_flags_get_type")
; (return-type "GtkType")
; )
; (define-function gtk_moz_embed_status_enums_get_type
; (c-name "gtk_moz_embed_status_enums_get_type")
; (return-type "GtkType")
; )
; (define-function gtk_moz_embed_reload_flags_get_type
; (c-name "gtk_moz_embed_reload_flags_get_type")
; (return-type "GtkType")
; )
; (define-function gtk_moz_embed_chrome_flags_get_type
; (c-name "gtk_moz_embed_chrome_flags_get_type")
; (return-type "GtkType")
; )
(define-function gtk_moz_embed_single_get
(c-name "gtk_moz_embed_single_get")
(return-type "GtkMozEmbedSingle*")
)
(define-virtual link_message
(of-object "GtkMozEmbed")
(return-type "none")
)
(define-virtual js_status
(of-object "GtkMozEmbed")
(return-type "none")
)
(define-virtual location
(of-object "GtkMozEmbed")
(return-type "none")
)
(define-virtual title
(of-object "GtkMozEmbed")
(return-type "none")
)
(define-virtual progress
(of-object "GtkMozEmbed")
(return-type "none")
(parameters
'("gint" "curprogress")
'("gint" "maxprogress")
)
)
(define-virtual progress_all
(of-object "GtkMozEmbed")
(return-type "none")
(parameters
'("const-char*" "aURI")
'("gint" "curprogress")
'("gint" "maxprogress")
)
)
(define-virtual net_state
(of-object "GtkMozEmbed")
(return-type "none")
(parameters
'("gint" "state")
'("guint" "status")
)
)
(define-virtual net_state_all
(of-object "GtkMozEmbed")
(return-type "none")
(parameters
'("const-char*" "aURI")
'("gint" "state")
'("guint" "status")
)
)
(define-virtual net_start
(of-object "GtkMozEmbed")
(return-type "none")
)
(define-virtual net_stop
(of-object "GtkMozEmbed")
(return-type "none")
)
(define-virtual new_window
(of-object "GtkMozEmbed")
(return-type "none")
(parameters
'("GtkMozEmbed**" "newEmbed")
'("guint" "chromemask")
)
)
(define-virtual visibility
(of-object "GtkMozEmbed")
(return-type "none")
(parameters
'("gboolean" "visibility")
)
)
(define-virtual destroy_brsr
(of-object "GtkMozEmbed")
(return-type "none")
)
(define-virtual open_uri
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("const-char*" "aURI")
)
)
(define-virtual size_to
(of-object "GtkMozEmbed")
(return-type "none")
(parameters
'("gint" "width")
'("gint" "height")
)
)
(define-virtual dom_key_down
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("gpointer" "dom_event")
)
)
(define-virtual dom_key_press
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("gpointer" "dom_event")
)
)
(define-virtual dom_key_up
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("gpointer" "dom_event")
)
)
(define-virtual dom_mouse_down
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("gpointer" "dom_event")
)
)
(define-virtual dom_mouse_up
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("gpointer" "dom_event")
)
)
(define-virtual dom_mouse_click
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("gpointer" "dom_event")
)
)
(define-virtual dom_mouse_dbl_click
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("gpointer" "dom_event")
)
)
(define-virtual dom_mouse_over
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("gpointer" "dom_event")
)
)
(define-virtual dom_mouse_out
(of-object "GtkMozEmbed")
(return-type "gint")
(parameters
'("gpointer" "dom_event")
)
)
(define-virtual security_change
(of-object "GtkMozEmbed")
(return-type "none")
(parameters
'("gpointer" "request")
'("guint" "state")
)
)
(define-virtual status_change
(of-object "GtkMozEmbed")
(return-type "none")
(parameters
'("gpointer" "request")
'("gint" "status")
'("gpointer" "message")
)
)
(define-virtual new_window_orphan
(of-object "GtkMozEmbedSingle")
(return-type "none")
(parameters
'("GtkMozEmbed**" "newEmbed")
'("guint" "chromemask")
)
)

View File

@ -0,0 +1,52 @@
/* -*- Mode: C; c-basic-offset: 4 -*- */
%%
headers
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include <pygobject.h>
#include <gtkmozembed.h>
%%
modulename gtkmozembed
%%
import gobject.GObject as PyGObject_Type
import gtk.Object as PyGtkObject_Type
import gtk.Bin as PyGtkBin_Type
%%
ignore-glob
*_get_type
_*
%%
override gtk_moz_embed_set_comp_path_deprecated kwargs
static PyObject *
_wrap_gtk_moz_embed_set_comp_path_deprecated(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "aPath", NULL };
char *aPath;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:gtk_moz_embed_set_comp_path", kwlist, &aPath))
return NULL;
if (PyErr_Warn(PyExc_DeprecationWarning, "renamed to gtkmozembed.set_comp_path") < 0)
return NULL;
gtk_moz_embed_set_comp_path(aPath);
Py_INCREF(Py_None);
return Py_None;
}
%%
override gtk_moz_embed_set_profile_path_deprecated kwargs
static PyObject *
_wrap_gtk_moz_embed_set_profile_path_deprecated(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "aDir", "aName", NULL };
char *aDir, *aName;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss:gtk_moz_embed_set_profile_path", kwlist, &aDir, &aName))
return NULL;
if (PyErr_Warn(PyExc_DeprecationWarning, "renamed to gtkmozembed.set_profile_path") < 0)
return NULL;
gtk_moz_embed_set_profile_path(aDir, aName);
Py_INCREF(Py_None);
return Py_None;
}

View File

@ -64,10 +64,14 @@ static const nsModuleComponentInfo sSugarComponents[] = {
}; };
gboolean gboolean
sugar_browser_startup(void) sugar_browser_startup(const char *profile_path, const char *profile_name)
{ {
nsresult rv; nsresult rv;
gtk_moz_embed_set_profile_path(profile_path, profile_name);
gtk_moz_embed_push_startup();
nsCOMPtr<nsIPrefService> prefService; nsCOMPtr<nsIPrefService> prefService;
prefService = do_GetService(NS_PREFSERVICE_CONTRACTID); prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
NS_ENSURE_TRUE(prefService, FALSE); NS_ENSURE_TRUE(prefService, FALSE);
@ -135,6 +139,12 @@ sugar_browser_startup(void)
return TRUE; return TRUE;
} }
void
sugar_browser_shutdown(void)
{
gtk_moz_embed_pop_startup();
}
G_DEFINE_TYPE(SugarBrowser, sugar_browser, GTK_TYPE_MOZ_EMBED) G_DEFINE_TYPE(SugarBrowser, sugar_browser, GTK_TYPE_MOZ_EMBED)
static void static void

View File

@ -54,13 +54,17 @@ struct _SugarBrowserClass {
}; };
GType sugar_browser_get_type (void); GType sugar_browser_get_type (void);
gboolean sugar_browser_startup (void);
SugarBrowser *sugar_browser_create_window (SugarBrowser *browser); SugarBrowser *sugar_browser_create_window (SugarBrowser *browser);
void sugar_browser_scroll_pixels (SugarBrowser *browser, void sugar_browser_scroll_pixels (SugarBrowser *browser,
int dx, int dx,
int dy); int dy);
void sugar_browser_grab_focus (SugarBrowser *browser); void sugar_browser_grab_focus (SugarBrowser *browser);
gboolean sugar_browser_startup (const char *profile_path,
const char *profile_name);
void sugar_browser_shutdown (void);
G_END_DECLS G_END_DECLS
#endif #endif

View File

@ -16,17 +16,19 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk import gtk
import _sugar import _sugar
# Main window # Main window
window = gtk.Window() window = gtk.Window()
window.connect("destroy", lambda w: gtk.main_quit()) window.connect("destroy", lambda w: gtk.main_quit())
_sugar.startup_browser() _sugar.browser_startup(os.path.expanduser('~/.sugar-browser-test'), 'test')
browser = _sugar.Browser() browser = _sugar.Browser()
window.add(browser) window.add(browser)