resources/RooUsage.txt
[app.Builder.js] / tests / webkit_inspector.js
1 //<Script type="text/javascript">
2
3 /**
4  *  Test of web kit inspector.
5  *  create a window + 2 webviews. inside scrolled window.
6  *     load google in first, then hook in the inspector..
7  * 
8  * needs the transfer ownship fixing on return value in  WebKit-1.0.gir
9  * 
10  *  <method name="get_inspector"
11  *             c:identifier="webkit_web_view_get_inspector">
12  *       <return-value transfer-ownership="none">
13  *         <type name="WebInspector" c:type="WebKitWebInspector*"/>
14  *       </return-value>
15  *     </method>
16  *
17  * then compile it..
18  * g-ir-compiler /usr/share/gir-1.0/WebKit-1.0.gir -o /usr/lib/girepository-1.0/WebKit-1.0.typelib 
19  *
20  */
21  
22  
23 Gtk = imports.gi.Gtk;
24 WebKit = imports.gi.WebKit;
25
26 Gtk.init(null,null);
27
28 // build the UI..
29 w = new Gtk.Window.c_new( Gtk.WindowType.TOPLEVEL);
30 v = new Gtk.VBox();
31 s1 = new Gtk.ScrolledWindow();
32 s2 = new Gtk.ScrolledWindow();
33 w1 = new WebKit.WebView();
34 w2 = new WebKit.WebView();
35 s1.add(w1);
36 s2.add(w2);
37 v.add(s1);
38 v.add(s2);
39 w.add(v);
40
41 // enable inspector..
42 w1.get_settings().enable_developer_extras = true;
43
44 // load google on show..
45 w1.signal.show.connect(function() {
46     w1.load_uri("http://www.google.com");
47 });
48
49 // load the inspector when loading has finished!
50 w1.signal.load_finished.connect(function(wv) {
51     w1.get_inspector().show();
52 });
53
54 // return the bottom window as the inspector..
55 w1.get_inspector().signal.inspect_web_view.connect(function() {
56     return w2;
57 })
58
59 // show and go..
60 w.show_all();
61 Gtk.main();
62
63
64