Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2008-11-11 21:20:56 (GMT)
committer Jonas Smedegaard <dr@jones.dk>2008-11-11 21:20:56 (GMT)
commit4b2ab14cdbb0ed04d2a3c0510fba78644223fa1d (patch)
tree876b38b40f1b98ae033bb60b25bf0ea8778a5dff
parent55653714f68d8e88e4726a40424c3804db3309e0 (diff)
parent69c890e6731e3ef7ecb3dc2bf96711ff402403aa (diff)
Merge commit 'upstream/0.4.7.dfsg'
-rw-r--r--components/xulappinfo.js2
-rwxr-xr-xconfigure22
-rw-r--r--configure.ac2
-rw-r--r--python/__init__.py41
-rw-r--r--python/hulahop.defs12
-rw-r--r--python/webview.py33
-rw-r--r--src/hulahop-web-view.cpp45
-rw-r--r--src/hulahop-web-view.h8
-rw-r--r--src/hulahop.cpp37
-rw-r--r--src/hulahop.h11
10 files changed, 131 insertions, 82 deletions
diff --git a/components/xulappinfo.js b/components/xulappinfo.js
index 0c694d9..d472dd1 100644
--- a/components/xulappinfo.js
+++ b/components/xulappinfo.js
@@ -2,7 +2,7 @@
const APPLICATION_ID = '{ab9fc198-f515-477b-843f-8fb52810a3e0}'
const APPLICATION_VENDOR = 'Sugar'
const APPLICATION_NAME = 'Browser Activity'
-const APPLICATION_VERSION = '0.4.5'
+const APPLICATION_VERSION = '0.4.7'
const APPLICATION_BUILD_ID = '2008072400'
const PLATFORM_VERSION = '1.9'
diff --git a/configure b/configure
index c9c956b..a0553d2 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for hulahop 0.4.5.
+# Generated by GNU Autoconf 2.61 for hulahop 0.4.7.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -726,8 +726,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='hulahop'
PACKAGE_TARNAME='hulahop'
-PACKAGE_VERSION='0.4.5'
-PACKAGE_STRING='hulahop 0.4.5'
+PACKAGE_VERSION='0.4.7'
+PACKAGE_STRING='hulahop 0.4.7'
PACKAGE_BUGREPORT=''
ac_unique_file="configure.ac"
@@ -1421,7 +1421,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures hulahop 0.4.5 to adapt to many kinds of systems.
+\`configure' configures hulahop 0.4.7 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1491,7 +1491,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of hulahop 0.4.5:";;
+ short | recursive ) echo "Configuration of hulahop 0.4.7:";;
esac
cat <<\_ACEOF
@@ -1601,7 +1601,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-hulahop configure 0.4.5
+hulahop configure 0.4.7
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1615,7 +1615,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by hulahop $as_me 0.4.5, which was
+It was created by hulahop $as_me 0.4.7, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -1969,7 +1969,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-HULAHOP_VERSION=0.4.5
+HULAHOP_VERSION=0.4.7
HULAHOP_BUILD_ID=2008072400
@@ -2404,7 +2404,7 @@ fi
# Define the identity of the package.
PACKAGE='hulahop'
- VERSION='0.4.5'
+ VERSION='0.4.7'
cat >>confdefs.h <<_ACEOF
@@ -20520,7 +20520,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by hulahop $as_me 0.4.5, which was
+This file was extended by hulahop $as_me 0.4.7, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -20567,7 +20567,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-hulahop config.status 0.4.5
+hulahop config.status 0.4.7
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.ac b/configure.ac
index 6d81b09..63da75f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
m4_define([hulahop_build_id],[2008072400]) # FIXME: when should we update this?
-m4_define([hulahop_version],[0.4.5])
+m4_define([hulahop_version],[0.4.7])
AC_INIT([hulahop],[hulahop_version],[],[hulahop])
diff --git a/python/__init__.py b/python/__init__.py
index 6065ebe..a1fde26 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -16,6 +16,7 @@
# Boston, MA 02111-1307, USA.
import os
+import logging
import sys
import ConfigParser
@@ -26,6 +27,7 @@ from hulahop import config
sys.path.insert(0, os.path.join(config.libxul_dir, 'python'))
from hulahop._hulahop import shutdown
+from hulahop._hulahop import get_view_for_window
from hulahop import _hulahop
_XO_DPI = 200
@@ -60,33 +62,36 @@ def startup(profile_path, components_dirs=[]):
def _check_compreg(profile_path):
comp_path = os.path.join(profile_path, 'compatibility.ini')
- existant = True
- valid = True
try:
cp = ConfigParser.ConfigParser(defaults={'app_version' : ''})
if not cp.read(comp_path):
- existant = False
+ valid = False
else:
valid = cp.get('main', 'app_version') == _app_version and \
cp.get('main', 'libxul_dir') == config.libxul_dir
except ConfigParser.Error:
valid = False
-
- if not valid and existant:
- compreg = os.path.join(profile_path, 'compreg.dat')
-
- os.unlink(comp_path)
- os.unlink(compreg)
-
- cp = ConfigParser.ConfigParser()
- cp.add_section('main')
- cp.set('main', 'app_version', _app_version)
- cp.set('main', 'libxul_dir', config.libxul_dir)
-
- f = open(comp_path, 'w')
- cp.write(f)
- f.close()
+
+ if not valid:
+ compreg = os.path.join(profile_path, 'compreg.dat')
+ if os.path.exists(compreg):
+ try:
+ os.unlink(compreg)
+ except OSError, e:
+ logging.error('Unlink error: %s' % e)
+
+ cp = ConfigParser.ConfigParser()
+ cp.add_section('main')
+ cp.set('main', 'app_version', _app_version)
+ cp.set('main', 'libxul_dir', config.libxul_dir)
+
+ f = open(comp_path, 'w')
+ try:
+ cp.write(f)
+ except ConfigParser.Error, e:
+ logging.error('Can not write %s error: %s' % (comp_path, e))
+ f.close()
def _get_layout_dpi():
gtk_xft_dpi = gtk.settings_get_default().get_property('gtk-xft-dpi')
diff --git a/python/hulahop.defs b/python/hulahop.defs
index 55c1733..d07bf16 100644
--- a/python/hulahop.defs
+++ b/python/hulahop.defs
@@ -5,9 +5,9 @@
(gtype-id "HULAHOP_TYPE_WEB_VIEW")
)
-(define-method create_window
+(define-virtual setup
(of-object "HulahopWebView")
- (c-name "hulahop_web_view_create_window")
+ (c-name "hulahop_web_view_setup")
(return-type "none")
)
@@ -76,3 +76,11 @@
(return-type "none")
)
+(define-function get_view_for_window
+ (c-name "hulahop_get_view_for_window")
+ (return-type "HulahopWebView*")
+ (parameters
+ '("PyObject*" "dom_window")
+ )
+)
+
diff --git a/python/webview.py b/python/webview.py
index b4dc51f..3cccde6 100644
--- a/python/webview.py
+++ b/python/webview.py
@@ -25,8 +25,6 @@ from xpcom import components
from xpcom.components import interfaces
from xpcom.nsError import *
-_views = []
-
class _Chrome:
_com_interfaces_ = interfaces.nsIWebBrowserChrome, \
interfaces.nsIWebBrowserChrome2, \
@@ -147,6 +145,9 @@ class _Chrome:
#logging.debug("nsIEmbeddingSiteWindow.get_visibility: %r" % self.web_view.get_toplevel().props.visible)
return self.web_view.get_toplevel().props.visible
+ def get_webBrowser(self):
+ return self.web_view.browser
+
def get_chromeFlags(self):
return self._chrome_flags
@@ -206,6 +207,7 @@ class WebView(_hulahop.WebView):
'status' : (str, None, None, None,
gobject.PARAM_READABLE)
}
+
def __init__(self):
_hulahop.WebView.__init__(self)
@@ -225,15 +227,13 @@ class WebView(_hulahop.WebView):
interfaces.nsIWebProgressListener)
self._status = ''
+ self._first_uri = None
- self.create_window()
+ def do_setup(self):
+ _hulahop.WebView.do_setup(self)
- self.connect('destroy', self.__destroy_cb)
-
- _views.append(self)
-
- def __destroy_cb(self):
- _views.remove(self)
+ if self._first_uri:
+ self.load_uri(self._first_uri)
def _notify_title_changed(self):
self.notify('title')
@@ -268,9 +268,12 @@ class WebView(_hulahop.WebView):
return self.browser.contentDOMWindow
def load_uri(self, uri):
- self.web_navigation.loadURI(
- uri, interfaces.nsIWebNavigation.LOAD_FLAGS_NONE,
- None, None, None)
+ try:
+ self.web_navigation.loadURI(
+ uri, interfaces.nsIWebNavigation.LOAD_FLAGS_NONE,
+ None, None, None)
+ except xpcom.Exception:
+ self._first_uri = uri
dom_window = property(get_dom_window)
browser = property(get_browser)
@@ -278,9 +281,3 @@ class WebView(_hulahop.WebView):
doc_shell = property(get_doc_shell)
web_progress = property(get_web_progress)
web_navigation = property(get_web_navigation)
-
-def lookup_view(chrome):
- for view in _views:
- if view._chrome == chrome:
- return view
- return None
diff --git a/src/hulahop-web-view.cpp b/src/hulahop-web-view.cpp
index eee333d..9104b20 100644
--- a/src/hulahop-web-view.cpp
+++ b/src/hulahop-web-view.cpp
@@ -49,10 +49,6 @@ struct _HulahopWebView {
GtkWidget *mozilla_widget;
};
-struct _HulahopWebViewClass {
- GtkBinClass base_class;
-};
-
G_DEFINE_TYPE(HulahopWebView, hulahop_web_view, GTK_TYPE_BIN)
static GObjectClass *parent_class = NULL;
@@ -95,6 +91,13 @@ hulahop_web_view_unrealize(GtkWidget *widget)
GTK_WIDGET_CLASS(parent_class)->unrealize(widget);
}
+void
+hulahop_web_view_setup(HulahopWebView *web_view)
+{
+ web_view->base_window->Create();
+ web_view->mozilla_widget = GTK_BIN(web_view)->child;
+}
+
static void
hulahop_web_view_realize(GtkWidget *widget)
{
@@ -123,9 +126,13 @@ hulahop_web_view_realize(GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
- g_assert(GTK_IS_WIDGET(web_view->mozilla_widget));
+ if (web_view->mozilla_widget) {
+ gtk_widget_reparent(web_view->mozilla_widget, widget);
+ } else {
+ HULAHOP_WEB_VIEW_GET_CLASS(web_view)->setup(web_view);
+ }
- gtk_widget_reparent(web_view->mozilla_widget, widget);
+ g_assert(web_view->mozilla_widget);
g_signal_connect_object(web_view->mozilla_widget,
"focus-in-event",
@@ -228,7 +235,9 @@ hulahop_web_view_class_init(HulahopWebViewClass *web_view_class)
widget_class->unmap = hulahop_web_view_unmap;
widget_class->size_allocate = hulahop_web_view_size_allocate;
- gobject_class->dispose = hulahop_web_view_dispose;
+ gobject_class->dispose = hulahop_web_view_dispose;
+
+ web_view_class->setup = hulahop_web_view_setup;
}
static void
@@ -236,8 +245,6 @@ hulahop_web_view_init(HulahopWebView *web_view)
{
web_view->offscreen_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_realize(web_view->offscreen_window);
-
- nsresult rv;
web_view->browser = do_CreateInstance
("@mozilla.org/embedding/browser/nsWebBrowser;1");
@@ -247,10 +254,13 @@ hulahop_web_view_init(HulahopWebView *web_view)
item->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
web_view->base_window = do_QueryInterface(web_view->browser);
+ g_assert(web_view->base_window);
- rv = web_view->base_window->InitWindow(web_view->offscreen_window,
- nsnull, 0, 0, 100, 100);
+ nsresult rv;
+ rv = web_view->base_window->InitWindow(web_view, nsnull, 0, 0, 100, 100);
g_assert(NS_SUCCEEDED(rv));
+
+ GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(web_view), GTK_NO_WINDOW);
}
PyObject *
@@ -281,19 +291,6 @@ hulahop_web_view_get_window_root(HulahopWebView *web_view)
}
void
-hulahop_web_view_create_window(HulahopWebView *web_view)
-{
- nsresult rv;
-
- rv = web_view->base_window->Create();
- g_assert(NS_SUCCEEDED(rv));
-
- web_view->mozilla_widget = GTK_BIN(web_view->offscreen_window)->child;
-
- GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(web_view), GTK_NO_WINDOW);
-}
-
-void
hulahop_web_view_grab_focus(HulahopWebView *web_view)
{
if (web_view->mozilla_widget) {
diff --git a/src/hulahop-web-view.h b/src/hulahop-web-view.h
index f832b7a..cd3b710 100644
--- a/src/hulahop-web-view.h
+++ b/src/hulahop-web-view.h
@@ -35,10 +35,15 @@ typedef struct _HulahopWebViewClass HulahopWebViewClass;
#define HULAHOP_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), HULAHOP_TYPE_WEB_VIEW))
#define HULAHOP_WEB_VIEW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), HULAHOP_TYPE_WEB_VIEW, HulahopWebViewClass))
+struct _HulahopWebViewClass {
+ GtkBinClass base_class;
+
+ void (* setup) (HulahopWebView *web_view);
+};
+
GType hulahop_web_view_get_type (void);
void hulahop_web_view_grab_focus (HulahopWebView *web_view);
-void hulahop_web_view_create_window (HulahopWebView *web_view);
PyObject *hulahop_web_view_get_browser (HulahopWebView *web_view);
PyObject *hulahop_web_view_get_window_root (HulahopWebView *web_view);
@@ -48,7 +53,6 @@ void hulahop_web_view_pop_js_context (HulahopWebView *web_view);
void hulahop_web_view_evaluate_script (HulahopWebView *web_view,
const char *script);
-
G_END_DECLS
#endif
diff --git a/src/hulahop.cpp b/src/hulahop.cpp
index 3e3b963..6adc2e3 100644
--- a/src/hulahop.cpp
+++ b/src/hulahop.cpp
@@ -20,6 +20,12 @@
#include <nsCOMPtr.h>
#include <nsILocalFile.h>
#include <nsXULAppAPI.h>
+#include <nsIWindowWatcher.h>
+#include <nsIWebBrowser.h>
+#include <nsIWebBrowserChrome.h>
+#include <nsIDOMWindow.h>
+#include <nsIBaseWindow.h>
+#include <PyXPCOM.h>
#include "HulahopDirectoryProvider.h"
#include "hulahop.h"
@@ -87,3 +93,34 @@ hulahop_add_components_path(const char *path)
{
kDirectoryProvider.AddComponentsPath(path);
}
+
+HulahopWebView *
+hulahop_get_view_for_window(PyObject *dom_window)
+{
+ nsCOMPtr<nsIDOMWindow> domWindow;
+ Py_nsISupports::InterfaceFromPyObject(dom_window,
+ NS_GET_IID(nsIDOMWindow),
+ getter_AddRefs(domWindow),
+ PR_FALSE);
+ NS_ENSURE_TRUE(domWindow, NULL);
+
+ nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService
+ ("@mozilla.org/embedcomp/window-watcher;1");
+ NS_ENSURE_TRUE(wwatch, NULL);
+
+ nsCOMPtr<nsIWebBrowserChrome> chrome;
+ wwatch->GetChromeForWindow(domWindow, getter_AddRefs(chrome));
+ NS_ENSURE_TRUE(chrome, NULL);
+
+ nsCOMPtr<nsIWebBrowser> browser;
+ chrome->GetWebBrowser(getter_AddRefs(browser));
+ NS_ENSURE_TRUE(browser, NULL);
+
+ nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(browser);
+ NS_ENSURE_TRUE(baseWindow, NULL);
+
+ gpointer native_parent;
+ baseWindow->GetParentNativeWindow(&native_parent);
+
+ return HULAHOP_WEB_VIEW(native_parent);
+}
diff --git a/src/hulahop.h b/src/hulahop.h
index b678d7e..c8649ce 100644
--- a/src/hulahop.h
+++ b/src/hulahop.h
@@ -20,14 +20,15 @@
#ifndef __HULAHOP_H__
#define __HULAHOP_H__
-#include <glib.h>
+#include "hulahop-web-view.h"
G_BEGIN_DECLS
-gboolean hulahop_startup (void);
-void hulahop_shutdown (void);
-void hulahop_set_profile_path (const char *path);
-void hulahop_add_components_path (const char *path);
+gboolean hulahop_startup (void);
+void hulahop_shutdown (void);
+void hulahop_set_profile_path (const char *path);
+void hulahop_add_components_path (const char *path);
+HulahopWebView *hulahop_get_view_for_window (PyObject *dom_window);
G_END_DECLS