Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-06-13 08:39:27 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-06-13 08:39:27 (GMT)
commitfe86acf314161823a648dd480e55915dc184e057 (patch)
treea5a9dd31bf456252c18dbed2047b5c5a622b1ec6
parentb6344b9e64a06ea452a42d0e77204f7f072cc9c0 (diff)
Implement grab_focus
-rw-r--r--python/hulahop.defs6
-rw-r--r--src/hulahop-web-view.cpp8
-rw-r--r--src/hulahop-web-view.h2
-rw-r--r--tests/test-web-view.py25
4 files changed, 37 insertions, 4 deletions
diff --git a/python/hulahop.defs b/python/hulahop.defs
index 7c17625..8fafc59 100644
--- a/python/hulahop.defs
+++ b/python/hulahop.defs
@@ -11,6 +11,12 @@
(return-type "none")
)
+(define-method grab_focus
+ (of-object "HulahopWebView")
+ (c-name "hulahop_web_view_grab_focus")
+ (return-type "none")
+)
+
(define-method get_browser
(of-object "HulahopWebView")
(c-name "hulahop_web_view_get_browser")
diff --git a/src/hulahop-web-view.cpp b/src/hulahop-web-view.cpp
index dc34326..bd6f14e 100644
--- a/src/hulahop-web-view.cpp
+++ b/src/hulahop-web-view.cpp
@@ -299,3 +299,11 @@ hulahop_web_view_create_window(HulahopWebView *web_view)
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) {
+ gtk_widget_grab_focus(web_view->mozilla_widget);
+ }
+}
diff --git a/src/hulahop-web-view.h b/src/hulahop-web-view.h
index 68610b5..d90a46f 100644
--- a/src/hulahop-web-view.h
+++ b/src/hulahop-web-view.h
@@ -36,6 +36,8 @@ typedef struct _HulahopWebViewClass HulahopWebViewClass;
#define HULAHOP_WEB_VIEW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), HULAHOP_TYPE_WEB_VIEW, HulahopWebViewClass))
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);
diff --git a/tests/test-web-view.py b/tests/test-web-view.py
index 0542654..63ede6b 100644
--- a/tests/test-web-view.py
+++ b/tests/test-web-view.py
@@ -6,18 +6,35 @@ import hulahop
hulahop.startup(os.path.expanduser('~/.test-hulahop'))
from hulahop.webview import WebView
-def _quit(window):
+def quit(window):
hulahop.shutdown()
gtk.main_quit()
+def entry_activate_cb(entry):
+ web_view.load_uri(entry.get_text())
+ web_view.grab_focus()
+
window = gtk.Window()
-window.connect("destroy", _quit)
+window.set_default_size(600, 400)
+window.connect("destroy", quit)
+
+vbox = gtk.VBox()
+
+entry = gtk.Entry()
+entry.connect('activate', entry_activate_cb)
+vbox.pack_start(entry, False)
+entry.show()
web_view = WebView()
-web_view.load_uri('http://www.google.com')
-window.add(web_view)
+web_view.load_uri('http://www.gnome.org')
+vbox.pack_start(web_view)
web_view.show()
+window.add(vbox)
+vbox.show()
+
window.show()
+entry.grab_focus()
+
gtk.main()