seed r567 - trunk/doc/tutorial-standalone
- From: hortont svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r567 - trunk/doc/tutorial-standalone
- Date: Sun, 28 Dec 2008 04:03:42 +0000 (UTC)
Author: hortont
Date: Sun Dec 28 04:03:42 2008
New Revision: 567
URL: http://svn.gnome.org/viewvc/seed?rev=567&view=rev
Log:
Cleaning up tutorial browser.
Modified:
trunk/doc/tutorial-standalone/2.js
Modified: trunk/doc/tutorial-standalone/2.js
==============================================================================
--- trunk/doc/tutorial-standalone/2.js (original)
+++ trunk/doc/tutorial-standalone/2.js Sun Dec 28 04:03:42 2008
@@ -11,6 +11,7 @@
name: "TabbedBrowser",
instance_init: function (klass)
{
+ // Public
this.close_tab = function (tab)
{
browser.remove_page(browser.page_num(tab));
@@ -48,6 +49,7 @@
return this.get_nth_page(this.page);
};
+ // Implementation
this.new_tab(home_page);
}
});
@@ -57,22 +59,13 @@
name: "BrowserTab",
instance_init: function (klass)
{
+ // Private
var toolbar = new BrowserToolbar();
var web_view = new BrowserView();
var scroll_view = new Gtk.ScrolledWindow();
var tab_label;
- web_view.set_tab(this);
-
- scroll_view.smooth_scroll = true;
- scroll_view.add(web_view);
- scroll_view.set_policy(Gtk.PolicyType.Automatic,
- Gtk.PolicyType.Automatic);
-
- this.pack_start(toolbar);
- this.pack_start(scroll_view, true, true);
- this.show_all();
-
+ // Public
this.get_toolbar = function ()
{
return toolbar;
@@ -92,6 +85,18 @@
{
return tab_label;
};
+
+ // Implementation
+ web_view.set_tab(this);
+
+ scroll_view.smooth_scroll = true;
+ scroll_view.add(web_view);
+ scroll_view.set_policy(Gtk.PolicyType.Automatic,
+ Gtk.PolicyType.Automatic);
+
+ this.pack_start(toolbar);
+ this.pack_start(scroll_view, true, true);
+ this.show_all();
}
});
@@ -100,8 +105,27 @@
name: "BrowserView",
instance_init: function (klass)
{
+ // Private
var tab;
+ var update_title = function (web_view, web_frame, title)
+ {
+ if(title.length > 25)
+ title = title.slice(0,25) + "...";
+
+ tab.get_tab_label().label = title;
+ };
+
+ var update_url = function (web_view, web_frame)
+ {
+ var toolbar = tab.get_toolbar();
+
+ toolbar.set_url(web_frame.get_uri());
+ toolbar.set_can_go_back(web_view.can_go_back());
+ toolbar.set_can_go_forward(web_view.can_go_forward());
+ };
+
+ // Public
this.browse = function (url)
{
if(url.search("://") < 0)
@@ -120,23 +144,7 @@
return tab;
};
- var update_title = function (web_view, web_frame, title)
- {
- if(title.length > 25)
- title = title.slice(0,25) + "...";
-
- tab.get_tab_label().label = title;
- };
-
- var update_url = function (web_view, web_frame)
- {
- var toolbar = tab.get_toolbar();
-
- toolbar.set_url(web_frame.get_uri());
- toolbar.set_can_go_back(web_view.can_go_back());
- toolbar.set_can_go_forward(web_view.can_go_forward());
- };
-
+ // Implementation
this.set_scroll_adjustments(null, null);
this.signal.title_changed.connect(update_title);
this.signal.load_committed.connect(update_url);
@@ -148,6 +156,7 @@
name: "BrowserToolbar",
instance_init: function (klass)
{
+ // Private
var url_bar = new Gtk.Entry();
var back_button = new Gtk.ToolButton({stock_id:"gtk-go-back"});
@@ -174,11 +183,7 @@
browser.current_tab().get_web_view().browse(url.text);
};
- back_button.signal.clicked.connect(back);
- forward_button.signal.clicked.connect(forward);
- refresh_button.signal.clicked.connect(refresh);
- url_bar.signal.activate.connect(browse);
-
+ // Public
this.set_url = function (url)
{
url_bar.text = url;
@@ -193,6 +198,12 @@
{
forward_button.sensitive = can_go_forward;
};
+
+ // Implementation
+ back_button.signal.clicked.connect(back);
+ forward_button.signal.clicked.connect(forward);
+ refresh_button.signal.clicked.connect(refresh);
+ url_bar.signal.activate.connect(browse);
this.pack_start(back_button);
this.pack_start(forward_button);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]