Make browser a modules inside sugar library

This commit is contained in:
Marco Pesenti Gritti
2007-04-07 13:17:36 +02:00
parent 4828870afd
commit 5343752c35
33 changed files with 173 additions and 344 deletions
+47
View File
@@ -0,0 +1,47 @@
sugardir = $(pythondir)/sugar/browser
sugar_PYTHON = \
__init__.py
INCLUDES = \
$(PYTHON_INCLUDES) \
$(PYGTK_CFLAGS) \
$(PYCAIRO_CFLAGS) \
$(LIB_CFLAGS) \
$(GECKO_CFLAGS) \
$(NSPR_CFLAGS) \
-I$(MOZILLA_INCLUDE_DIR)/gtkembedmoz \
-I$(top_srcdir)/browser
pkgpyexecdir = $(pythondir)/sugar/browser
pkgpyexec_LTLIBRARIES = _sugarbrowser.la
_sugarbrowser_la_LDFLAGS = -module -avoid-version $(GECKO_LDFLAGS)
_sugarbrowser_la_LIBADD = \
$(LIB_LIBS) \
$(PYCAIRO_LIBS) \
$(GECKO_LIBS) \
$(XPCOMGLUE_LIBS) \
$(top_builddir)/browser/libsugarbrowser.la
_sugarbrowser_la_SOURCES = \
_sugarbrowsermodule.c \
xulrunner.cpp \
xulrunner.h
nodist__sugarbrowser_la_SOURCES = _sugarbrowser.c
_sugar.c: _sugarbrowser.defs gtkmozembed.defs _sugarbrowser.override gtkmozembed.override
CLEANFILES = _sugar.c
EXTRA_DIST = _sugarbrowser.override _sugarbrowser.defs gtkmozembed.defs gtkmozembed.override
.defs.c:
(cd $(srcdir)\
&& $(PYGTK_CODEGEN) \
--register $(PYGTK_DEFSDIR)/gdk-types.defs \
--register $(PYGTK_DEFSDIR)/gtk-types.defs \
--override $*.override \
--prefix py$* $*.defs) > gen-$*.c \
&& cp gen-$*.c $*.c \
&& rm -f gen-$*.c
+185
View File
@@ -0,0 +1,185 @@
;; -*- scheme -*-
; object definitions ...
(define-boxed SugarBrowserEvent
(in-module "Sugar")
(c-name "SugarBrowserEvent")
(gtype-id "SUGAR_TYPE_BROWSER_EVENT")
(copy-func "sugar_browser_event_copy")
(release-func "sugar_browser_event_free")
)
(define-boxed SugarBrowserMetadata
(in-module "Sugar")
(c-name "SugarBrowserMetadata")
(gtype-id "SUGAR_TYPE_BROWSER_METADATA")
(copy-func "sugar_browser_metadata_copy")
(release-func "sugar_browser_metadata_free")
)
(define-object AddressEntry
(in-module "Sugar")
(parent "GtkEntry")
(c-name "SugarAddressEntry")
(gtype-id "SUGAR_TYPE_ADDRESS_ENTRY")
)
(define-object Browser
(in-module "Sugar")
(parent "GtkMozEmbed")
(c-name "SugarBrowser")
(gtype-id "SUGAR_TYPE_BROWSER")
)
(define-object DownloadManager
(in-module "Sugar")
(parent "GObject")
(c-name "SugarDownloadManager")
(gtype-id "SUGAR_TYPE_DOWNLOAD_MANAGER")
)
(define-object Download
(in-module "Sugar")
(parent "GObject")
(c-name "SugarDownload")
(gtype-id "SUGAR_TYPE_DOWNLOAD")
)
;; Enumerations and flags ...
;; From sugar-address-entry.h
(define-function sugar_address_entry_get_type
(c-name "sugar_address_entry_get_type")
(return-type "GType")
)
;; From sugar-browser.h
(define-function sugar_browser_get_type
(c-name "sugar_browser_get_type")
(return-type "GType")
)
(define-function startup
(c-name "sugar_browser_startup")
(parameters
'("const-char*" "profile_path")
'("const-char*" "profile_name")
)
(return-type "gboolean")
)
(define-function shutdown
(c-name "sugar_browser_shutdown")
(return-type "none")
)
(define-method grab_focus
(of-object "SugarBrowser")
(c-name "sugar_browser_grab_focus")
(return-type "none")
)
(define-method save_uri
(of-object "SugarBrowser")
(c-name "sugar_browser_save_uri")
(return-type "gboolean")
(parameters
'("const-char*" "uri")
'("const-char*" "filename")
)
)
(define-method save_document
(of-object "SugarBrowser")
(c-name "sugar_browser_save_document")
(return-type "gboolean")
(parameters
'("const-char*" "filename")
)
)
(define-method create_window
(of-object "SugarBrowser")
(c-name "sugar_browser_create_window")
(return-type "SugarBrowser*")
)
(define-virtual 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
(of-object "SugarKeyGrabber")
(c-name "sugar_key_grabber_grab")
(return-type "none")
(parameters
'("const-char*" "key")
)
)
(define-method get_key
(of-object "SugarKeyGrabber")
(c-name "sugar_key_grabber_get_key")
(return-type "char*")
(parameters
'("guint" "keycode")
'("guint" "state")
)
)
;; From sugar-download-manager.h
(define-function sugar_download_manager_get_type
(c-name "sugar_download_manager_get_type")
(return-type "GType")
)
(define-function get_download_manager
(c-name "sugar_get_download_manager")
(return-type "SugarDownloadManager*")
)
;; From sugar-download.h
(define-function sugar_download_get_type
(c-name "sugar_download_get_type")
(return-type "GType")
)
(define-method get_file_name
(of-object "SugarDownload")
(c-name "sugar_download_get_file_name")
(return-type "const-gchar*")
)
(define-method get_url
(of-object "SugarDownload")
(c-name "sugar_download_get_url")
(return-type "const-gchar*")
)
(define-method get_mime_type
(of-object "SugarDownload")
(c-name "sugar_download_get_mime_type")
(return-type "const-gchar*")
)
(define-method get_percent
(of-object "SugarDownload")
(c-name "sugar_download_get_percent")
(return-type "gint")
)
(include "gtkmozembed.defs")
+80
View File
@@ -0,0 +1,80 @@
/* -*- Mode: C; c-basic-offset: 4 -*- */
%%
headers
#include <Python.h>
#include "pygobject.h"
#include "sugar-browser.h"
#include "sugar-address-entry.h"
#include "sugar-download-manager.h"
#include "sugar-download.h"
#include <pygtk/pygtk.h>
#include <glib.h>
%%
modulename _sugarbrowser
%%
import gobject.GObject as PyGObject_Type
import gtk.Entry as PyGtkEntry_Type
import gtk.gdk.Screen as PyGdkScreen_Type
import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
import hippo.CanvasImage as HippoCanvasImage_Type
%%
ignore-glob
*_get_type
_*
%%
include
gtkmozembed.override
%%
override-slot SugarBrowserMetadata.tp_getattr
static PyObject *
_wrap_sugar_browser_metadata_tp_getattr(PyObject *self, char *attr)
{
SugarBrowserMetadata *metadata = pyg_boxed_get(self, SugarBrowserMetadata);
if (!strcmp(attr, "__members__"))
return Py_BuildValue("[s]", "filename");
else if (!strcmp(attr, "filename")) {
if (metadata->filename) {
return PyString_FromString(metadata->filename);
} else {
Py_INCREF(Py_None);
return Py_None;
}
}
return NULL;
}
%%
override-slot SugarBrowserEvent.tp_getattr
static PyObject *
_wrap_sugar_browser_event_tp_getattr(PyObject *self, char *attr)
{
SugarBrowserEvent *event = pyg_boxed_get(self, SugarBrowserEvent);
if (!strcmp(attr, "__members__"))
return Py_BuildValue("[sss]", "image_uri", "button", "image_name");
else if (!strcmp(attr, "image_uri")) {
if (event->image_uri) {
return PyString_FromString(event->image_uri);
} else {
Py_INCREF(Py_None);
return Py_None;
}
}
else if (!strcmp(attr, "image_name")) {
if (event->image_name) {
return PyString_FromString(event->image_name);
} else {
Py_INCREF(Py_None);
return Py_None;
}
}
else if (!strcmp(attr, "button"))
return PyInt_FromLong(event->button);
return NULL;
}
%%
+32
View File
@@ -0,0 +1,32 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "xulrunner.h"
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
#include <pygobject.h>
void py_sugarbrowser_register_classes (PyObject *d);
extern PyMethodDef py_sugarbrowser_functions[];
DL_EXPORT(void)
init_sugarbrowser(void)
{
PyObject *m, *d;
xulrunner_startup();
init_pygobject ();
m = Py_InitModule ("_sugarbrowser", py_sugarbrowser_functions);
d = PyModule_GetDict (m);
py_sugarbrowser_register_classes (d);
py_sugarbrowser_add_constants(m, "GTK_MOZ_EMBED_");
if (PyErr_Occurred ()) {
Py_FatalError ("can't initialise module _sugarbrowser");
}
}
+475
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")
)
)
+50
View File
@@ -0,0 +1,50 @@
/* -*- Mode: C; c-basic-offset: 4 -*- */
%%
headers
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include <pygobject.h>
#include <gtkmozembed.h>
%%
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;
}
+65
View File
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2006, Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <string.h>
#ifdef HAVE_GECKO_1_9
#include "gtkmozembed_glue.cpp"
#endif
extern "C" int
xulrunner_startup(void)
{
#ifdef HAVE_GECKO_1_9
static const GREVersionRange greVersion = {
"1.9a", PR_TRUE,
"2", PR_TRUE
};
char xpcomPath[PATH_MAX];
nsresult rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
xpcomPath, sizeof(xpcomPath));
if (NS_FAILED(rv)) {
fprintf(stderr, "Couldn't find a compatible GRE.\n");
return 1;
}
rv = XPCOMGlueStartup(xpcomPath);
if (NS_FAILED(rv)) {
fprintf(stderr, "Couldn't start XPCOM.");
return 1;
}
rv = GTKEmbedGlueStartup();
if (NS_FAILED(rv)) {
fprintf(stderr, "Couldn't find GTKMozEmbed symbols.");
return 1;
}
char *lastSlash = strrchr(xpcomPath, '/');
if (lastSlash)
*lastSlash = '\0';
gtk_moz_embed_set_path(xpcomPath);
#endif
}
+20
View File
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2006, Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
int xulrunner_startup (void);