2 WebKit = imports.gi.WebKit;
3 Soup = imports.gi.Soup;
6 // Tabbed : imports.Tabbed
7 Settings : imports.Settings
12 Browser.View = new GType({
13 parent: WebKit.WebView.type,
20 var update_title = function (web_view, web_frame, title)
23 title = title.slice(0,25) + "...";
25 tab.get_tab_label().label = title;
28 var update_url = function (web_view, web_frame)
30 //var toolbar = tab.get_toolbar();
32 //toolbar.set_url(web_frame.get_uri());
33 //toolbar.set_can_go_back(web_view.can_go_back());
34 //toolbar.set_can_go_forward(web_view.can_go_forward());
37 var update_progress = function (bar, progress)
39 //tab.get_toolbar().set_progress(progress / 100);
42 var create_new_tab = function (web_view, web_frame, new_web_view)
44 //new_web_view = new Browser.View();
45 //new_web_view.signal.web_view_ready.connect(show_new_tab);
46 //return new_web_view;
48 //var show_new_tab = function (new_web_view)
50 // Browser.Tabbed.browser.new_tab("", new_web_view);
55 var hover_link = function (web_view, link, url)
57 //tab.get_statusbar().set_status(url);
60 var load_finished = function ()
62 //tab.get_toolbar().set_progress(0);
65 var load_committed = function (web_view, web_frame)
67 update_url(web_view, web_frame);
70 var clicked_link = function (web_view, web_frame, request,
71 action, decision, window)
73 if(action.get_reason() == WebKit.WebNavigationReason.LINK_CLICKED &&
74 action.get_button() == 2)
76 // browser.new_tab(request.get_uri(), null);
84 this.browse = function (url)
86 if(url.search("://") < 0)
87 url = "http://" + url;
92 this.set_tab = function (new_tab)
97 this.get_tab = function ()
104 //this.set_scroll_adjustments(null, null);
106 //this.signal.title_changed.connect(update_title);
107 //this.signal.load_committed.connect(load_committed);
108 //this.signal.load_finished.connect(load_finished);
109 //this.signal.load_progress_changed.connect(update_progress);
111 // For some reason, this segfaults seed in the instance init closure handler
112 // Once that's fixed, uncommenting the next line will give middle-click-open-in-new tab
113 //this.signal.navigation_policy_decision_requested.connect(clicked_link);
115 //this.signal.hovering_over_link.connect(hover_link);
117 //this.signal.create_web_view.connect(create_new_tab);
120 this.signal.resource_request_starting.connect(function(
124 request, // WebKitNetworkRequest
127 print("request starting")
132 var auth = new Soup.Auth.c_new(
135 "Basic realm=\"Test\"");
139 auth.authenticate(Browser.Settings.netrc.login,Browser.Settings.netrc.password);
140 var authmsg = auth.get_authorization(request.message);
143 request.message.request_headers.append(
144 'Authorization', authmsg);