diff options
-rw-r--r-- | python/hulahop.defs | 6 | ||||
-rw-r--r-- | python/hulahop.override | 7 | ||||
-rw-r--r-- | python/webview.py | 18 | ||||
-rw-r--r-- | src/hulahop-web-view.cpp | 14 | ||||
-rw-r--r-- | src/hulahop-web-view.h | 1 |
5 files changed, 43 insertions, 3 deletions
diff --git a/python/hulahop.defs b/python/hulahop.defs index 811b6c5..49dff91 100644 --- a/python/hulahop.defs +++ b/python/hulahop.defs @@ -17,6 +17,12 @@ (return-type "none") ) +(define-method get_doc_shell + (of-object "HulahopWebView") + (c-name "hulahop_web_view_get_doc_shell") + (return-type "none") +) + (define-function startup (c-name "hulahop_startup") (return-type "gboolean") diff --git a/python/hulahop.override b/python/hulahop.override index d846c64..4353268 100644 --- a/python/hulahop.override +++ b/python/hulahop.override @@ -29,3 +29,10 @@ _wrap_hulahop_web_view_get_window_root(PyGObject *self) return hulahop_web_view_get_window_root(HULAHOP_WEB_VIEW(self->obj)); } %% +override hulahop_web_view_get_doc_shell noargs +static PyObject * +_wrap_hulahop_web_view_get_doc_shell(PyGObject *self) +{ + return hulahop_web_view_get_doc_shell(HULAHOP_WEB_VIEW(self->obj)); +} +%% diff --git a/python/webview.py b/python/webview.py index 3b5e380..81465fe 100644 --- a/python/webview.py +++ b/python/webview.py @@ -30,14 +30,26 @@ class WebView(_hulahop.WebView): def get_browser(self): return _hulahop.WebView.get_browser(self) + def get_doc_shell(self): + return _hulahop.WebView.get_doc_shell(self) + + def get_web_progress(self): + return self.doc_shell.queryInterface(interfaces.nsIWebProgress) + + def get_web_navigation(self): + return self.browser.queryInterface(interfaces.nsIWebNavigation) + def get_window(self): return self.browser.contentDOMWindow def load_uri(self, uri): - web_nav = self.browser.queryInterface(interfaces.nsIWebNavigation) - web_nav.loadURI(uri, interfaces.nsIWebNavigation.LOAD_FLAGS_NONE, - None, None, None) + self.web_navigation.loadURI( + uri, interfaces.nsIWebNavigation.LOAD_FLAGS_NONE, + None, None, None) window = property(get_window) browser = property(get_browser) window_root = property(get_window_root) + doc_shell = property(get_doc_shell) + web_progress = property(get_web_progress) + web_navigation = property(get_web_navigation) diff --git a/src/hulahop-web-view.cpp b/src/hulahop-web-view.cpp index 1ee6da4..3fcc3a7 100644 --- a/src/hulahop-web-view.cpp +++ b/src/hulahop-web-view.cpp @@ -25,6 +25,8 @@ #include <nsIDOMWindow2.h> #include <nsIDOMEventTarget.h> #include <nsIBaseWindow.h> +#include <nsIDocShell.h> +#include <nsIInterfaceRequestorUtils.h> #include <PyXPCOM.h> #include <gtk/gtkfixed.h> @@ -252,3 +254,15 @@ hulahop_web_view_get_window_root(HulahopWebView *web_view) return PyObject_FromNSInterface(eventTarget, NS_GET_IID(nsIDOMEventTarget)); } + +PyObject * +hulahop_web_view_get_doc_shell(HulahopWebView *web_view) +{ + nsresult rv; + + nsCOMPtr<nsIDocShell> docShell(do_GetInterface(web_view->browser, &rv)); + NS_ENSURE_SUCCESS (rv, NULL); + + return PyObject_FromNSInterface(docShell, + NS_GET_IID(nsIDocShell)); +} diff --git a/src/hulahop-web-view.h b/src/hulahop-web-view.h index e47431b..84db17b 100644 --- a/src/hulahop-web-view.h +++ b/src/hulahop-web-view.h @@ -38,6 +38,7 @@ typedef struct _HulahopWebViewClass HulahopWebViewClass; GType hulahop_web_view_get_type (void); PyObject *hulahop_web_view_get_browser (HulahopWebView *web_view); PyObject *hulahop_web_view_get_window_root (HulahopWebView *web_view); +PyObject *hulahop_web_view_get_doc_shell (HulahopWebView *web_view); G_END_DECLS |