diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-05-19 14:10:05 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-05-19 14:10:05 (GMT) |
commit | e77e975333ac47677c48b57cea0ef6f785609941 (patch) | |
tree | 81490b4c694c490a115d67e7f07947672b5342c5 |
Initial checkin
-rw-r--r-- | .gitignore | 18 | ||||
-rw-r--r-- | Makefile.am | 1 | ||||
-rwxr-xr-x | autogen.sh | 5 | ||||
-rw-r--r-- | components/Makefile.am | 1 | ||||
-rw-r--r-- | components/browserhelper/Makefile.am | 32 | ||||
-rw-r--r-- | components/browserhelper/nsBrowserHelper.js | 100 | ||||
-rw-r--r-- | components/browserhelper/nsIBrowserHelper.idl | 13 | ||||
-rw-r--r-- | configure.ac | 43 | ||||
-rw-r--r-- | m4/gecko.m4 | 623 | ||||
-rw-r--r-- | m4/python.m4 | 62 | ||||
-rw-r--r-- | src/.gitignore | 1 | ||||
-rw-r--r-- | src/HulahopDirectoryProvider.cpp | 51 | ||||
-rw-r--r-- | src/HulahopDirectoryProvider.h | 29 | ||||
-rw-r--r-- | src/Makefile.am | 48 | ||||
-rw-r--r-- | src/__init__.py | 6 | ||||
-rw-r--r-- | src/hulahop-browser.cpp | 135 | ||||
-rw-r--r-- | src/hulahop-browser.h | 41 | ||||
-rw-r--r-- | src/hulahop.defs | 9 | ||||
-rw-r--r-- | src/hulahop.override | 17 | ||||
-rw-r--r-- | src/hulahopmodule.c | 26 | ||||
-rw-r--r-- | tests/test-browser.py | 12 |
21 files changed, 1273 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f36761d --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +*~ +Makefile +Makefile.in + +config.guess +config.log +config.status +config.sub +configure +depcomp +install-sh +libtool +ltmain.sh +missing +py-compile +.deps +aclocal.m4 +autom4te.cache diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..979e82b --- /dev/null +++ b/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = components src diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..1cd5db4 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,5 @@ +#!/bin/sh +export ACLOCAL="aclocal -I m4" + +autoreconf -i +./configure "$@" diff --git a/components/Makefile.am b/components/Makefile.am new file mode 100644 index 0000000..4385e25 --- /dev/null +++ b/components/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = browserhelper diff --git a/components/browserhelper/Makefile.am b/components/browserhelper/Makefile.am new file mode 100644 index 0000000..e33b907 --- /dev/null +++ b/components/browserhelper/Makefile.am @@ -0,0 +1,32 @@ +sessionstoredir = $(pkgdatadir)/components + +sessionstore_DATA = \ + nsIBrowserHelper.xpt \ + nsBrowserHelper.js + +BUILT_SOURCES = \ + nsIBrowserHelper.xpt \ + nsIBrowserHelper.h + +stamp_files = \ + stamp-nsIBrowserHelper.xpt \ + stamp-nsIBrowserHelper.h + +nsIBrowserHelper.xpt: stamp-nsIBrowserHelper.xpt + @true +stamp-nsIBrowserHelper.xpt: nsIBrowserHelper.idl + $(XPIDL) -m typelib -w -v -I $(XPIDL_IDLDIR) -e nsIBrowserHelper.xpt \ + $(srcdir)/nsIBrowserHelper.idl \ + && echo timestamp > $(@F) + +nsIBrowserHelper.h: stamp-nsIBrowserHelper.h + @true +stamp-nsIBrowserHelper.h: nsIBrowserHelper.idl + $(XPIDL) -m header -w -v -I $(XPIDL_IDLDIR) -e nsIBrowserHelper.h \ + $(srcdir)/nsIBrowserHelper.idl \ + && echo timestamp > $(@F) + +CLEANFILES = $(stamp_files) $(BUILT_SOURCES) +DISTCLEANFILES = $(stamp_files) $(BUILT_SOURCES) +MAINTAINERCLEANFILES = $(stamp_files) $(BUILT_SOURCES) +EXTRA_DIST = nsIBrowserHelper.idl nsBrowserHelper.js diff --git a/components/browserhelper/nsBrowserHelper.js b/components/browserhelper/nsBrowserHelper.js new file mode 100644 index 0000000..f726ddf --- /dev/null +++ b/components/browserhelper/nsBrowserHelper.js @@ -0,0 +1,100 @@ +const Cc = Components.classes; +const Ci = Components.interfaces; +const Cr = Components.results; + +const CID = Components.ID("{475e1194-92bc-4e03-92f3-5ad6ccddaca3}"); +const CONTRACT_ID = "@laptop.org/browser/browserhelper;1"; +const CLASS_NAME = "Browser Helper"; + +var browsers = []; + +function BrowserHelperService() { +} + +BrowserHelperService.prototype = { + +/* ........ nsIBrowserHelper API .............. */ + + getBrowser: function bh_getBrowser(aId) { + return browsers[aId] + }, + + registerBrowser: function bh_registerBrowser(aId, aBrowser) { + browsers[aId] = aBrowser; + }, + + unregisterBrowser: function bh_unregisterBrowser(aId) { + browsers.pop(aId) + }, + + QueryInterface: function(aIID) { + if (!aIID.equals(Ci.nsISupports) && + !aIID.equals(Ci.nsIBrowserHelper)) { + Components.returnCode = Cr.NS_ERROR_NO_INTERFACE; + return null; + } + + return this; + } +} + +/* :::::::: Service Registration & Initialization ::::::::::::::: */ + +/* ........ nsIModule .............. */ + +const BrowserHelperModule = { + + getClassObject: function(aCompMgr, aCID, aIID) { + if (aCID.equals(CID)) { + return BrowserHelperFactory; + } + + Components.returnCode = Cr.NS_ERROR_NOT_REGISTERED; + return null; + }, + + registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) { + aCompMgr.QueryInterface(Ci.nsIComponentRegistrar); + aCompMgr.registerFactoryLocation(CID, CLASS_NAME, CONTRACT_ID, aFileSpec, aLocation, aType); + }, + + unregisterSelf: function(aCompMgr, aLocation, aType) { + aCompMgr.QueryInterface(Ci.nsIComponentRegistrar); + aCompMgr.unregisterFactoryLocation(CID, aLocation); + }, + + canUnload: function(aCompMgr) { + return true; + } +} + +/* ........ nsIFactory .............. */ + +const BrowserHelperFactory = { + + createInstance: function(aOuter, aIID) { + if (aOuter != null) { + Components.returnCode = Cr.NS_ERROR_NO_AGGREGATION; + return null; + } + + return (new BrowserHelperService()).QueryInterface(aIID); + }, + + lockFactory: function(aLock) { }, + + QueryInterface: function(aIID) { + if (!aIID.equals(Ci.nsISupports) && !aIID.equals(Ci.nsIModule) && + !aIID.equals(Ci.nsIFactory) && !aIID.equals(Ci.nsIBrowserHelper)) { + Components.returnCode = Cr.NS_ERROR_NO_INTERFACE; + return null; + } + + return this; + } +}; + +function NSGetModule(aComMgr, aFileSpec) { + dump("nsBrowserHelper: NSGetModule\n") + return BrowserHelperModule; +} diff --git a/components/browserhelper/nsIBrowserHelper.idl b/components/browserhelper/nsIBrowserHelper.idl new file mode 100644 index 0000000..abe52b3 --- /dev/null +++ b/components/browserhelper/nsIBrowserHelper.idl @@ -0,0 +1,13 @@ +#include "nsISupports.idl" + +interface nsIWebBrowser; + +[scriptable, uuid(475e1194-92bc-4e03-92f3-5ad6ccddaca3)] +interface nsIBrowserHelper : nsISupports +{ + nsIWebBrowser getBrowser(in long id); + + void registerBrowser(in long id, in nsIWebBrowser browser); + + void unregisterBrowser(in long id); +}; diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..5957fb0 --- /dev/null +++ b/configure.ac @@ -0,0 +1,43 @@ +AC_INIT([hulahop],[0.1],[],[hulahop]) + +AC_PREREQ([2.59]) + +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_SRCDIR([configure.ac]) + +AM_INIT_AUTOMAKE([1.9 foreign dist-bzip2 no-dist-gzip]) + +AC_PROG_LIBTOOL + +PKG_CHECK_MODULES(DEPS, gtk+-2.0) + +AM_PATH_PYTHON +AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)]) + +AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, no) + +PKG_CHECK_MODULES(PYGTK, pygtk-2.0) + +PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0` +AC_SUBST(PYGTK_DEFSDIR) + +GECKO_INIT([MOZILLA]) +AC_SUBST(MOZILLA_INCLUDE_ROOT) +AC_SUBST([MOZILLA_HOME]) +AC_SUBST([MOZILLA_EXTRA_LIBS]) +AC_SUBST([MOZILLA_GLUE_LIBS]) + +GECKO_XPIDL() +AC_SUBST([XPIDL]) +AC_SUBST([XPIDL_IDLDIR]) + +PKG_CHECK_MODULES([GECKO],[${gecko_cv_gecko}-xpcom >= 1.9 ${gecko_cv_gecko}-js $gecko_cv_extra_pkg_dependencies]) +AC_SUBST([GECKO_CFLAGS]) +AC_SUBST([GECKO_LIBS]) + +AC_OUTPUT([ +Makefile +components/Makefile +components/browserhelper/Makefile +src/Makefile +]) diff --git a/m4/gecko.m4 b/m4/gecko.m4 new file mode 100644 index 0000000..c537e02 --- /dev/null +++ b/m4/gecko.m4 @@ -0,0 +1,623 @@ +# Copyright © 2000-2004 Marco Pesenti Gritti +# Copyright © 2003, 2004, 2005, 2006 Christian Persch +# +# This program 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. +# +# This program 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +# GECKO_INIT(VARIABLE,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) +# +# Checks for gecko, and aborts if it's not found +# +# Checks for -fshort-wchar compiler variable, and adds it to +# AM_CXXFLAGS if found +# +# Checks whether RTTI is enabled, and adds -fno-rtti to +# AM_CXXFLAGS otherwise +# +# Checks whether the gecko build is a debug build, and adds +# debug flags to AM_CXXFLAGS if it is. +# +# Expanded variables: +# VARIABLE: Which gecko was found (e.g. "xulrunnner", "seamonkey", ...) +# VARIABLE_FLAVOUR: The flavour of the gecko that was found +# VARIABLE_HOME: +# VARIABLE_PREFIX: +# VARIABLE_INCLUDE_ROOT: +# VARIABLE_VERSION: The version of the gecko that was found +# VARIABLE_VERSION: +# VARIABLE_VERSION_INT: + +AC_DEFUN([GECKO_INIT], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_REQUIRE([AC_PROG_AWK])dnl + +AC_PROG_AWK + +# ************************ +# Check which gecko to use +# ************************ + +AC_MSG_CHECKING([which gecko to use]) + +AC_ARG_WITH([gecko], + AS_HELP_STRING([--with-gecko@<:@=mozilla|firefox|seamonkey|xulrunner@:>@], + [Which gecko engine to use (autodetected by default)])) + +# Backward compat +AC_ARG_WITH([mozilla],[],[with_gecko=$withval],[]) + +gecko_cv_gecko=$with_gecko + +# Autodetect gecko +_geckos="xulrunner firefox mozilla-firefox seamonkey mozilla" +if test -z "$gecko_cv_gecko"; then + for lizard in $_geckos; do + if $PKG_CONFIG --exists $lizard-xpcom; then + gecko_cv_gecko=$lizard + break; + fi + done +fi + +AC_MSG_RESULT([$gecko_cv_gecko]) + +if test "x$gecko_cv_gecko" = "x"; then + ifelse([$3],,[AC_MSG_ERROR([No gecko found; you may need to adjust PKG_CONFIG_PATH or install a mozilla/firefox/xulrunner -devel package])],[$3]) + gecko_cv_have_gecko=no +elif ! ( echo "$_geckos" | egrep "(^| )$gecko_cv_gecko(\$| )" > /dev/null); then + AC_MSG_ERROR([Unknown gecko "$gecko_cv_gecko" specified]) +else + ifelse([$2],,[],[$2]) + gecko_cv_have_gecko=yes +fi + +# **************** +# Define variables +# **************** + +if test "$gecko_cv_have_gecko" = "yes"; then + +case "$gecko_cv_gecko" in +mozilla) gecko_cv_gecko_flavour=mozilla ;; +seamonkey) gecko_cv_gecko_flavour=mozilla ;; +*firefox) gecko_cv_gecko_flavour=toolkit ;; +xulrunner) gecko_cv_gecko_flavour=toolkit ;; +esac + +_GECKO_INCLUDE_ROOT="`$PKG_CONFIG --variable=includedir ${gecko_cv_gecko}-xpcom`" +_GECKO_LIBDIR="`$PKG_CONFIG --variable=libdir ${gecko_cv_gecko}-xpcom`" +_GECKO_HOME="`$PKG_CONFIG --variable=libdir ${gecko_cv_gecko}-xpcom`" +_GECKO_PREFIX="`$PKG_CONFIG --variable=prefix ${gecko_cv_gecko}-xpcom`" + +fi # if gecko_cv_have_gecko + +if test "$gecko_cv_gecko_flavour" = "toolkit"; then + AC_DEFINE([HAVE_MOZILLA_TOOLKIT],[1],[Define if mozilla is of the toolkit flavour]) +fi + +AM_CONDITIONAL([HAVE_MOZILLA_TOOLKIT],[test "$gecko_cv_gecko_flavour" = "toolkit"]) + +$1[]=$gecko_cv_gecko +$1[]_FLAVOUR=$gecko_cv_gecko_flavour +$1[]_INCLUDE_ROOT=$_GECKO_INCLUDE_ROOT +$1[]_LIBDIR=$_GECKO_LIBDIR +$1[]_HOME=$_GECKO_HOME +$1[]_PREFIX=$_GECKO_PREFIX + +# ************************************************************** +# This is really gcc-only +# Do this test using CXX only since some versions of gcc +# 2.95-2.97 have a signed wchar_t in c++ only and some versions +# only have short-wchar support for c++. +# ************************************************************** + +_GECKO_EXTRA_CPPFLAGS= +_GECKO_EXTRA_CFLAGS= +_GECKO_EXTRA_CXXFLAGS= +_GECKO_EXTRA_LDFLAGS= + +if test "$gecko_cv_have_gecko" = "yes"; then + +AC_LANG_PUSH([C++]) + +_SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS="$CXXFLAGS $_GECKO_EXTRA_CXXFLAGS -fshort-wchar" + +AC_CACHE_CHECK([for compiler -fshort-wchar option], + gecko_cv_have_usable_wchar_option, + [AC_RUN_IFELSE([AC_LANG_SOURCE( + [[#include <stddef.h> + int main () { + return (sizeof(wchar_t) != 2) || (wchar_t)-1 < (wchar_t) 0 ; + } ]])], + [gecko_cv_have_usable_wchar_option="yes"], + [gecko_cv_have_usable_wchar_option="no"], + [gecko_cv_have_usable_wchar_option="maybe (cross-compiling)"])]) + +CXXFLAGS="$_SAVE_CXXFLAGS" + +AC_LANG_POP([C++]) + +if test "$gecko_cv_have_usable_wchar_option" = "yes"; then + _GECKO_EXTRA_CXXFLAGS="-fshort-wchar" + AM_CXXFLAGS="$AM_CXXFLAGS -fshort-wchar" +fi + +fi # if gecko_cv_have_gecko + +# ************** +# Check for RTTI +# ************** + +if test "$gecko_cv_have_gecko" = "yes"; then + +AC_MSG_CHECKING([whether to enable C++ RTTI]) +AC_ARG_ENABLE([cpp-rtti], + AS_HELP_STRING([--enable-cpp-rtti],[Enable C++ RTTI]), + [],[enable_cpp_rtti=no]) +AC_MSG_RESULT([$enable_cpp_rtti]) + +if test "$enable_cpp_rtti" = "no"; then + _GECKO_EXTRA_CXXFLAGS="-fno-rtti $_GECKO_EXTRA_CXXFLAGS" + AM_CXXFLAGS="-fno-rtti $AM_CXXFLAGS" +fi + +fi # if gecko_cv_have_gecko + +# ************* +# Various tests +# ************* + +if test "$gecko_cv_have_gecko" = "yes"; then + +AC_LANG_PUSH([C++]) + +_SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $_GECKO_EXTRA_CPPFLAGS -I$_GECKO_INCLUDE_ROOT" + +AC_MSG_CHECKING([[whether we have a gtk 2 gecko build]]) +AC_RUN_IFELSE( + [AC_LANG_SOURCE( + [[#include <mozilla-config.h> + #include <string.h> + #include <stdlib.h> + int main(void) { + if (strcmp (MOZ_DEFAULT_TOOLKIT, "gtk2") == 0 || + strcmp (MOZ_DEFAULT_TOOLKIT, "cairo-gtk2") == 0) + return EXIT_SUCCESS; + + return EXIT_FAILURE; + } ]] + )], + [result=yes], + [AC_MSG_ERROR([[This program needs a gtk 2 gecko build]])], + [result=maybe]) +AC_MSG_RESULT([$result]) + +AC_MSG_CHECKING([[whether we have a gecko debug build]]) +AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#include <mozilla-config.h> + #if !defined(MOZ_REFLOW_PERF) || !defined(MOZ_REFLOW_PERF_DSP) + #error No + #endif]] + )], + [gecko_cv_have_debug=yes], + [gecko_cv_have_debug=no]) +AC_MSG_RESULT([$gecko_cv_have_debug]) + +CPPFLAGS="$_SAVE_CPPFLAGS" + +AC_LANG_POP([C++]) + +if test "$gecko_cv_have_debug" = "yes"; then + _GECKO_EXTRA_CXXFLAGS="$_GECKO_EXTRA_CXXFLAGS -DDEBUG -D_DEBUG" + AM_CXXFLAGS="-DDEBUG -D_DEBUG $AM_CXXFLAGS" + + AC_DEFINE([HAVE_GECKO_DEBUG],[1],[Define if gecko is a debug build]) +fi + +fi # if gecko_cv_have_gecko + +AM_CONDITIONAL([HAVE_GECKO_DEBUG],[test "$gecko_cv_have_debug" = "yes"]) + +# *********************** +# Check for gecko version +# *********************** + +if test "$gecko_cv_have_gecko" = "yes"; then + +AC_LANG_PUSH([C++]) + +_SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I$_GECKO_INCLUDE_ROOT" + +AC_CACHE_CHECK([for gecko version], + [gecko_cv_gecko_version], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ +#include <mozilla-config.h> +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <locale.h> +]],[[ +FILE *stream; +const char *version = ""; + +if (!setlocale (LC_ALL, "C")) return 127; + +stream = fopen ("conftest.data", "w"); +if (!stream) return 126; + +#ifdef MOZILLA_1_8_BRANCH +version = "1.8.1"; +#else +if (strncmp (MOZILLA_VERSION, "1.9", strlen ("1.9")) == 0) { + version = "1.9"; +} else if (strncmp (MOZILLA_VERSION, "1.8", strlen ("1.8")) == 0) { + version = "1.8"; +} else { + version = "1.7"; +} +#endif +fprintf (stream, "%s\n", version); +if (fclose (stream) != 0) return 125; + +return EXIT_SUCCESS; +]])], + [gecko_cv_gecko_version="$(cat conftest.data)"], + [AC_MSG_FAILURE([could not determine gecko version])], + [gecko_cv_gecko_version="1.7"]) +]) + +CPPFLAGS="$_SAVE_CPPFLAGS" + +AC_LANG_POP([C++]) + +gecko_cv_gecko_version_int="$(echo "$gecko_cv_gecko_version" | $AWK -F . '{print [$]1 * 1000000 + [$]2 * 1000 + [$]3}')" + +if test "$gecko_cv_gecko_version_int" -lt "1007000" -o "$gecko_cv_gecko_version_int" -gt "1009000"; then + AC_MSG_ERROR([Gecko version $gecko_cv_gecko_version is not supported!]) +fi + +if test "$gecko_cv_gecko_version_int" -ge "1007000"; then + AC_DEFINE([HAVE_GECKO_1_7],[1],[Define if we have gecko 1.7]) + gecko_cv_have_gecko_1_7=yes +fi +if test "$gecko_cv_gecko_version_int" -ge "1008000"; then + AC_DEFINE([HAVE_GECKO_1_8],[1],[Define if we have gecko 1.8]) + gecko_cv_have_gecko_1_8=yes +fi +if test "$gecko_cv_gecko_version_int" -ge "1008001"; then + AC_DEFINE([HAVE_GECKO_1_8_1],[1],[Define if we have gecko 1.8.1]) + gecko_cv_have_gecko_1_8_1=yes +fi +if test "$gecko_cv_gecko_version_int" -ge "1009000"; then + AC_DEFINE([HAVE_GECKO_1_9],[1],[Define if we have gecko 1.9]) + gecko_cv_have_gecko_1_9=yes +fi + +fi # if gecko_cv_have_gecko + +AM_CONDITIONAL([HAVE_GECKO_1_7],[test "$gecko_cv_gecko_version_int" -ge "1007000"]) +AM_CONDITIONAL([HAVE_GECKO_1_8],[test "$gecko_cv_gecko_version_int" -ge "1008000"]) +AM_CONDITIONAL([HAVE_GECKO_1_8_1],[test "$gecko_cv_gecko_version_int" -ge "1008001"]) +AM_CONDITIONAL([HAVE_GECKO_1_9],[test "$gecko_cv_gecko_version_int" -ge "1009000"]) + +$1[]_VERSION=$gecko_cv_gecko_version +$1[]_VERSION_INT=$gecko_cv_gecko_version_int + +# ************************************************** +# Packages that we need to check for with pkg-config +# ************************************************** + +gecko_cv_extra_libs= +gecko_cv_glue_libs= +gecko_cv_extra_pkg_dependencies= + +if test "$gecko_cv_gecko_version_int" -ge "1009000"; then + gecko_cv_extra_libs="-L$_GECKO_LIBDIR -lxul" + gecko_cv_glue_libs="-L$_GECKO_LIBDIR -lxpcomglue_s" +else + gecko_cv_extra_pkg_dependencies="${gecko_cv_gecko}-gtkmozembed" +fi + +$1[]_EXTRA_PKG_DEPENDENCIES="$gecko_cv_extra_pkg_dependencies" +$1[]_EXTRA_LIBS="$gecko_cv_extra_libs" +$1[]_GLUE_LIBS="$gecko_cv_glue_libs" + +]) + +# *************************************************************************** +# *************************************************************************** +# *************************************************************************** + +# _GECKO_DISPATCH(MACRO, INCLUDEDIRS, ...) + +m4_define([_GECKO_DISPATCH], +[ + +if test "$gecko_cv_have_gecko" != "yes"; then + AC_MSG_FAILURE([Gecko not present; can't run this test!]) +fi + +AC_LANG_PUSH([C++]) + +_SAVE_CPPFLAGS="$CPPFLAGS" +_SAVE_CXXFLAGS="$CXXFLAGS" +_SAVE_LDFLAGS="$LDFLAGS" +_SAVE_LIBS="$LIBS" +CPPFLAGS="$CPPFLAGS $_GECKO_EXTRA_CPPFLAGS -I$_GECKO_INCLUDE_ROOT $($PKG_CONFIG --cflags-only-I ${gecko_cv_gecko}-xpcom)" +CXXFLAGS="$CXXFLAGS $_GECKO_EXTRA_CXXFLAGS $($PKG_CONFIG --cflags-only-other ${gecko_cv_gecko}-xpcom)" +LDFLAGS="$LDFLAGS $_GECKO_EXTRA_LDFLAGS -Wl,--rpath=$_GECKO_HOME" +LIBS="$LIBS $($PKG_CONFIG --libs ${gecko_cv_gecko}-xpcom)" + +_GECKO_DISPATCH_INCLUDEDIRS="$2" + +# Sigh Gentoo has a rubbish header layout +# http://bugs.gentoo.org/show_bug.cgi?id=100804 +# Mind you, it's useful to be able to test against uninstalled mozilla builds... +_GECKO_DISPATCH_INCLUDEDIRS="$_GECKO_DISPATCH_INCLUDEDIRS dom necko pref" + +# Now add them to CPPFLAGS +for i in $_GECKO_DISPATCH_INCLUDEDIRS; do + CPPFLAGS="$CPPFLAGS -I$_GECKO_INCLUDE_ROOT/$i" +done + +m4_indir([$1],m4_shiftn(2,$@)) + +CPPFLAGS="$_SAVE_CPPFLAGS" +CXXFLAGS="$_SAVE_CXXFLAGS" +LDFLAGS="$_SAVE_LDFLAGS" +LIBS="$_SAVE_LIBS" + +AC_LANG_POP([C++]) + +])# _GECKO_DISPATCH + +# *************************************************************************** +# *************************************************************************** +# *************************************************************************** + +# GECKO_CHECK_HEADERS(INCLUDEDIRS, HEADERS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES]) + +AC_DEFUN([GECKO_CHECK_HEADERS],[_GECKO_DISPATCH([AC_CHECK_HEADERS],$@)]) + +# GECKO_COMPILE_IFELSE(INCLUDEDIRS, PROGRAM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) + +AC_DEFUN([GECKO_COMPILE_IFELSE],[_GECKO_DISPATCH([AC_COMPILE_IFELSE],$@)]) + +# GECKO_RUN_IFELSE(INCLUDEDIRS, PROGRAM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) + +AC_DEFUN([GECKO_RUN_IFELSE],[_GECKO_DISPATCH([AC_RUN_IFELSE],$@)]) + +# *************************************************************************** +# *************************************************************************** +# *************************************************************************** + +# GECKO_XPCOM_PROGRAM([PROLOGUE], [BODY]) +# +# Produce a template C++ program which starts XPCOM up and shuts it down after +# the BODY part has run. In BODY, the the following variables are predeclared: +# +# nsresult rv +# int status = 1 (EXIT_FAILURE) +# +# The program's exit status will be |status|; set it to 0 (or EXIT_SUCCESS) +# to indicate success and to a value between 1 (EXIT_FAILURE) and 120 to +# indicate failure. +# +# To jump out of the BODY and exit the test program, you can use |break|. + +AC_DEFUN([GECKO_XPCOM_PROGRAM], +[AC_LANG_PROGRAM([[ +#include <mozilla-config.h> +#include <stdlib.h> +#include <stdio.h> +#include <nsXPCOM.h> +#include <nsCOMPtr.h> +#include <nsILocalFile.h> +#include <nsIServiceManager.h> +#ifdef HAVE_GECKO_1_8 +#include <nsStringAPI.h> +#else +#include <nsString.h> +#endif +]] +[$1], +[[ +// redirect unwanted mozilla debug output to the bit bucket +freopen ("/dev/null", "w", stdout); + +nsresult rv; +nsCOMPtr<nsILocalFile> directory; +rv = NS_NewNativeLocalFile (NS_LITERAL_CSTRING("$_GECKO_HOME"), PR_FALSE, + getter_AddRefs (directory)); +if (NS_FAILED (rv) || !directory) { + exit (126); +} + +rv = NS_InitXPCOM2 (nsnull, directory, nsnull); +if (NS_FAILED (rv)) { + exit (125); +} + +int status = EXIT_FAILURE; + +// now put in the BODY, scoped with do...while(0) to ensure we don't hold a +// COMptr after XPCOM shutdown and so we can jump out with a simple |break|. +do { +]] +m4_shiftn(1,$@) +[[ +} while (0); + +NS_ShutdownXPCOM (nsnull); +exit (status); +]]) +]) # GECKO_XPCOM_PROGRAM + +# *************************************************************************** +# *************************************************************************** +# *************************************************************************** + +# GECKO_XPCOM_PROGRAM_CHECK([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [ACTION-IF-CROSS-COMPILING]) +# +# Checks whether we can build and run any XPCOM test programs at all + +AC_DEFUN([GECKO_XPCOM_PROGRAM_CHECK], +[AC_REQUIRE([GECKO_INIT])dnl + +AC_CACHE_CHECK([whether we can compile and run XPCOM programs], +[gecko_cv_xpcom_program_check], +[ +gecko_cv_xpcom_program_check=no + +GECKO_RUN_IFELSE([], + [GECKO_XPCOM_PROGRAM([],[[status = EXIT_SUCCESS;]])], + [gecko_cv_xpcom_program_check=yes], + [gecko_cv_xpcom_program_check=no], + [gecko_cv_xpcom_program_check=maybe]) +]) + +if test "$gecko_cv_xpcom_program_check" = "yes"; then + ifelse([$2],,[:],[$2]) +else + ifelse([$3],,[AC_MSG_FAILURE([Cannot compile and run XPCOM programs])], + [$3]) +fi + +]) # GECKO_XPCOM_PROGRAM_CHECK + +# *************************************************************************** +# *************************************************************************** +# *************************************************************************** + +# GECKO_CHECK_CONTRACTID(CONTRACTID, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Checks wheter CONTRACTID is a registered contract ID + +AC_DEFUN([GECKO_CHECK_CONTRACTID], +[AC_REQUIRE([GECKO_INIT])dnl + +AS_VAR_PUSHDEF([gecko_cv_have_CID],[gecko_cv_have_$1]) + +AC_CACHE_CHECK([for the $1 XPCOM component], +gecko_cv_have_CID, +[ +AS_VAR_SET(gecko_cv_have_CID,[no]) + +GECKO_RUN_IFELSE([], +[GECKO_XPCOM_PROGRAM([[ +#include <nsIComponentRegistrar.h> +]],[[ +status = 99; +nsCOMPtr<nsIComponentRegistrar> registrar; +rv = NS_GetComponentRegistrar (getter_AddRefs (registrar)); +if (NS_FAILED (rv)) break; + +status = 98; +PRBool isRegistered = PR_FALSE; +rv = registrar->IsContractIDRegistered ("$1", &isRegistered); +if (NS_FAILED (rv)) break; + +status = isRegistered ? EXIT_SUCCESS : 97; +]]) +], +[AS_VAR_SET(gecko_cv_have_CID,[yes])], +[AS_VAR_SET(gecko_cv_have_CID,[no])], +[AS_VAR_SET(gecko_cv_have_CID,[maybe])]) + +]) + +if test AS_VAR_GET(gecko_cv_have_CID) = "yes"; then + ifelse([$2],,[:],[$2]) +else + ifelse([$3],,[AC_MSG_ERROR([dnl +Contract ID "$1" is not registered, but $PACKAGE_NAME depends on it.])], + [$3]) +fi + +AS_VAR_POPDEF([gecko_cv_have_CID]) + +]) # GECKO_CHECK_CONTRACTID + +# GECKO_CHECK_CONTRACTIDS(CONTRACTID, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Checks wheter CONTRACTIDs are registered contract IDs. +# If ACTION-IF-NOT-FOUND is given, it is executed when one of the contract IDs +# is not found and the missing contract ID is in the |as_contractid| variable. + +AC_DEFUN([GECKO_CHECK_CONTRACTIDS], +[AC_REQUIRE([GECKO_INIT])dnl + +result=yes +as_contractid= +for as_contractid in $1 +do + GECKO_CHECK_CONTRACTID([$as_contractid],[],[result=no; break;]) +done + +if test "$result" = "yes"; then + ifelse([$2],,[:],[$2]) +else + ifelse([$3],,[AC_MSG_ERROR([dnl +Contract ID "$as_contractid" is not registered, but $PACKAGE_NAME depends on it.])], + [$3]) +fi + +]) # GECKO_CHECK_CONTRACTIDS + +# *************************************************************************** +# *************************************************************************** +# *************************************************************************** + +# GECKO_XPIDL([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) +# +# Checks for xpidl program and include directory +# +# Variables set: +# XPIDL: the xpidl program +# XPIDL_IDLDIR: the xpidl include directory + +AC_DEFUN([GECKO_XPIDL], +[AC_REQUIRE([GECKO_INIT])dnl + +_GECKO_LIBDIR="`$PKG_CONFIG --variable=libdir ${gecko_cv_gecko}-xpcom`" + +AC_PATH_PROG([XPIDL],[xpidl],[no],[$_GECKO_LIBDIR:$PATH]) + +XPIDL_IDLDIR="`$PKG_CONFIG --variable=idldir ${gecko_cv_gecko}-xpcom`" + +# Older geckos don't have this variable, see +# https://bugzilla.mozilla.org/show_bug.cgi?id=240473 + +if test -z "$XPIDL_IDLDIR" -o ! -f "$XPIDL_IDLDIR/nsISupports.idl"; then + XPIDL_IDLDIR="`echo $_GECKO_LIBDIR | sed -e s!lib!share/idl!`" +fi + +# Some distributions (Gentoo) have it in unusual places + +if test -z "$XPIDL_IDLDIR" -o ! -f "$XPIDL_IDLDIR/nsISupports.idl"; then + XPIDL_IDLDIR="$_GECKO_INCLUDE_ROOT/idl" +fi + +if test "$XPIDL" != "no" -a -n "$XPIDL_IDLDIR" -a -f "$XPIDL_IDLDIR/nsISupports.idl"; then + ifelse([$1],,[:],[$1]) +else + ifelse([$2],,[AC_MSG_FAILURE([XPIDL program or include directory not found])],[$2]) +fi + +]) diff --git a/m4/python.m4 b/m4/python.m4 new file mode 100644 index 0000000..e1c5266 --- /dev/null +++ b/m4/python.m4 @@ -0,0 +1,62 @@ +## this one is commonly used with AM_PATH_PYTHONDIR ... +dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]]) +dnl Check if a module containing a given symbol is visible to python. +AC_DEFUN([AM_CHECK_PYMOD], +[AC_REQUIRE([AM_PATH_PYTHON]) +py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'` +AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1) +AC_CACHE_VAL(py_cv_mod_$py_mod_var, [ +ifelse([$2],[], [prog=" +import sys +try: + import $1 +except ImportError: + sys.exit(1) +except: + sys.exit(0) +sys.exit(0)"], [prog=" +import $1 +$1.$2"]) +if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC + then + eval "py_cv_mod_$py_mod_var=yes" + else + eval "py_cv_mod_$py_mod_var=no" + fi +]) +py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"` +if test "x$py_val" != xno; then + AC_MSG_RESULT(yes) + ifelse([$3], [],, [$3 +])dnl +else + AC_MSG_RESULT(no) + ifelse([$4], [],, [$4 +])dnl +fi +]) + +dnl a macro to check for ability to create python extensions +dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) +dnl function also defines PYTHON_INCLUDES +AC_DEFUN([AM_CHECK_PYTHON_HEADERS], +[AC_REQUIRE([AM_PATH_PYTHON]) +AC_MSG_CHECKING(for headers required to compile python extensions) +dnl deduce PYTHON_INCLUDES +py_prefix=`$PYTHON -c "import sys; print sys.prefix"` +py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` +PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" +if test "$py_prefix" != "$py_exec_prefix"; then + PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" +fi +AC_SUBST(PYTHON_INCLUDES) +dnl check if the headers exist: +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" +AC_TRY_CPP([#include <Python.h>],dnl +[AC_MSG_RESULT(found) +$1],dnl +[AC_MSG_RESULT(not found) +$2]) +CPPFLAGS="$save_CPPFLAGS" +]) diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..39a0668 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1 @@ +.deps diff --git a/src/HulahopDirectoryProvider.cpp b/src/HulahopDirectoryProvider.cpp new file mode 100644 index 0000000..dd7bf41 --- /dev/null +++ b/src/HulahopDirectoryProvider.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007, 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 "HulahopDirectoryProvider.h" + +NS_IMPL_QUERY_INTERFACE2(HulahopDirectoryProvider, + nsIDirectoryServiceProvider, + nsIDirectoryServiceProvider2) + +NS_IMETHODIMP_(nsrefcnt) +HulahopDirectoryProvider::AddRef() +{ + return 1; +} + +NS_IMETHODIMP_(nsrefcnt) +HulahopDirectoryProvider::Release() +{ + return 1; +} + +NS_IMETHODIMP +HulahopDirectoryProvider::GetFile(const char *aKey, + PRBool *aPersist, + nsIFile **aResult) +{ + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +HulahopDirectoryProvider::GetFiles(const char *aKey, + nsISimpleEnumerator **aResult) +{ + return NS_ERROR_FAILURE; +} diff --git a/src/HulahopDirectoryProvider.h b/src/HulahopDirectoryProvider.h new file mode 100644 index 0000000..c6b5669 --- /dev/null +++ b/src/HulahopDirectoryProvider.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2007, 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 <nsIDirectoryService.h> + +class HulahopDirectoryProvider : public nsIDirectoryServiceProvider2 +{ + public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDIRECTORYSERVICEPROVIDER + NS_DECL_NSIDIRECTORYSERVICEPROVIDER2 +}; + diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..8abb20b --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,48 @@ +sugardir = $(pythondir)/hulahop +sugar_PYTHON = \ + __init__.py + +INCLUDES = \ + $(DEPS_CFLAGS) \ + $(PYTHON_INCLUDES) \ + $(PYGTK_CFLAGS) \ + $(MOZILLA_CFLAGS) \ + -I$(MOZILLA_INCLUDE_ROOT)/docshell \ + -I$(MOZILLA_INCLUDE_ROOT)/xulapp \ + -I$(MOZILLA_INCLUDE_ROOT)/nspr \ + -I$(MOZILLA_INCLUDE_ROOT)/string \ + -I$(MOZILLA_INCLUDE_ROOT)/webbrwsr \ + -I$(MOZILLA_INCLUDE_ROOT)/widget \ + -I$(MOZILLA_INCLUDE_ROOT)/xpcom + +pkgpyexec_LTLIBRARIES = _hulahop.la + +_hulahop_la_LDFLAGS = -module -avoid-version -R$(MOZILLA_HOME) -dlopen self +_hulahop_la_LIBADD = \ + $(GECKO_LIBS) \ + $(DEPS_LIBS) \ + $(MOZILLA_EXTRA_LIBS) \ + $(MOZILLA_GLUE_LIBS) + +_hulahop_la_SOURCES = \ + HulahopDirectoryProvider.cpp \ + HulahopDirectoryProvider.h \ + hulahop-browser.cpp \ + hulahop-browser.h \ + hulahop.c \ + hulahopmodule.c + +hulahop.c: hulahop.defs hulahop.override + +CLEANFILES = hulahop.c +EXTRA_DIST = hulahop.override hulahop.defs + +.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 diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..9d9afbb --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,6 @@ +from hulahop import _hulahop + +class Browser(_hulahop.Browser): + def __init__(self): + _hulahop.Browser.__init__(self) + diff --git a/src/hulahop-browser.cpp b/src/hulahop-browser.cpp new file mode 100644 index 0000000..b353765 --- /dev/null +++ b/src/hulahop-browser.cpp @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2007, 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 <nsIDocShellTreeItem.h> +#include <nsComponentManagerUtils.h> +#include <nsCOMPtr.h> +#include <nsIWebBrowser.h> +#include <nsIBaseWindow.h> +#include <nsXULAppAPI.h> + +#include "hulahop-browser.h" +#include "HulahopDirectoryProvider.h" + +struct _HulahopBrowser { + GtkBin base_instance; + nsCOMPtr<nsIWebBrowser> browser; + nsCOMPtr<nsIBaseWindow> base_window; +}; + +struct _HulahopBrowserClass { + GtkBinClass base_class; +}; + +G_DEFINE_TYPE(HulahopBrowser, hulahop_browser, GTK_TYPE_BIN) + +static GObjectClass *parent_class = NULL; + +static const HulahopDirectoryProvider kDirectoryProvider; + +static void +hulahop_startup() +{ + XRE_InitEmbedding(nsnull, nsnull, + NS_CONST_CAST(HulahopDirectoryProvider *, + &kDirectoryProvider), nsnull, 0); +} + +static void +hulahop_browser_realize(GtkWidget *widget) +{ + HulahopBrowser *browser = HULAHOP_BROWSER(widget); + GdkWindowAttr attributes; + gint attributes_mask; + + GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); + + attributes.window_type = GDK_WINDOW_CHILD; + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.visual = gtk_widget_get_visual(widget); + attributes.colormap = gtk_widget_get_colormap(widget); + attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK; + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + + widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), + &attributes, attributes_mask); + gdk_window_set_user_data(widget->window, widget); + + widget->style = gtk_style_attach (widget->style, widget->window); + gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL); + + nsresult rv; + + browser->browser = do_CreateInstance + ("@mozilla.org/embedding/browser/nsWebBrowser;1"); + g_assert(browser->browser); + + nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(browser->browser); + item->SetItemType(nsIDocShellTreeItem::typeContentWrapper); + + browser->base_window = do_QueryInterface(browser->browser); + + rv = browser->base_window->InitWindow(widget, nsnull, 0, 0, + widget->allocation.width, + widget->allocation.height); + g_assert(NS_SUCCEEDED(rv)); + + rv = browser->base_window->Create(); + g_assert(NS_SUCCEEDED(rv)); +} + +static void +hulahop_browser_map(GtkWidget *widget) +{ + HulahopBrowser *browser = HULAHOP_BROWSER(widget); + + GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED); + + nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(browser->browser); + + // XXX hack around problem. probably widget/gtk2 window initialization. + baseWindow->SetVisibility(PR_FALSE); + baseWindow->SetVisibility(PR_TRUE); + + gdk_window_show(widget->window); +} + +static void +hulahop_browser_class_init(HulahopBrowserClass *browser_class) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(browser_class); + + parent_class = (GObjectClass *) g_type_class_peek_parent(browser_class); + + widget_class->realize = hulahop_browser_realize; + widget_class->map = hulahop_browser_map; +} + +static void +hulahop_browser_init(HulahopBrowser *browser) +{ + GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(browser), GTK_NO_WINDOW); + + hulahop_startup(); +} diff --git a/src/hulahop-browser.h b/src/hulahop-browser.h new file mode 100644 index 0000000..d4d9215 --- /dev/null +++ b/src/hulahop-browser.h @@ -0,0 +1,41 @@ +/* + * 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. + */ + +#ifndef __HULAHOP_BROWSER_H__ +#define __HULAHOP_BROWSER_H__ + +#include <gtk/gtkbin.h> + +G_BEGIN_DECLS + +typedef struct _HulahopBrowser HulahopBrowser; +typedef struct _HulahopBrowserClass HulahopBrowserClass; + +#define HULAHOP_TYPE_BROWSER (hulahop_browser_get_type()) +#define HULAHOP_BROWSER(object) (G_TYPE_CHECK_INSTANCE_CAST((object), HULAHOP_TYPE_BROWSER, HulahopBrowser)) +#define HULAHOP_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), HULAHOP_TYPE_BROWSER, HulahopBrowserClass)) +#define HULAHOP_IS_BROWSER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), HULAHOP_TYPE_BROWSER)) +#define HULAHOP_IS_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), HULAHOP_TYPE_BROWSER)) +#define HULAHOP_BROWSER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), HULAHOP_TYPE_BROWSER, HulahopBrowserClass)) + +GType hulahop_browser_get_type (void); + +G_END_DECLS + +#endif diff --git a/src/hulahop.defs b/src/hulahop.defs new file mode 100644 index 0000000..c3c2854 --- /dev/null +++ b/src/hulahop.defs @@ -0,0 +1,9 @@ +;; -*- scheme -*- +; object definitions ... + +(define-object Browser + (in-module "Hulahop") + (parent "GtkBin") + (c-name "HulahopBrowser") + (gtype-id "HULAHOP_TYPE_BROWSER") +) diff --git a/src/hulahop.override b/src/hulahop.override new file mode 100644 index 0000000..b232bcb --- /dev/null +++ b/src/hulahop.override @@ -0,0 +1,17 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +headers +#include <Python.h> +#include <pygtk/pygtk.h> + +#include "hulahop-browser.h" + +%% +modulename _hulahop +%% +import gtk.Bin as PyGtkBin_Type +%% +ignore-glob + *_get_type + _* +%% diff --git a/src/hulahopmodule.c b/src/hulahopmodule.c new file mode 100644 index 0000000..ccbb773 --- /dev/null +++ b/src/hulahopmodule.c @@ -0,0 +1,26 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <pygobject.h> + +void py_hulahop_register_classes (PyObject *d); + +extern PyMethodDef pyhulahop_functions[]; + +DL_EXPORT(void) +init_hulahop(void) +{ + PyObject *m, *d; + + init_pygobject (); + + m = Py_InitModule ("_hulahop", pyhulahop_functions); + d = PyModule_GetDict (m); + + pyhulahop_register_classes (d); + + if (PyErr_Occurred ()) { + Py_FatalError ("can't initialise module hulahop"); + } +} diff --git a/tests/test-browser.py b/tests/test-browser.py new file mode 100644 index 0000000..2e3a701 --- /dev/null +++ b/tests/test-browser.py @@ -0,0 +1,12 @@ +import gtk +import hulahop + +window = gtk.Window() + +browser = hulahop.Browser() +window.add(browser) +browser.show() + +window.show() + +gtk.main() |