1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const EndlessWikipedia = imports.endless_wikipedia.EndlessWikipedia;
const WikipediaView = imports.views.wikipedia_view;
GObject.ParamFlags.READWRITE = GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE;
const PrebuiltArticlesPage = new Lang.Class({
Name: 'PrebuiltArticlesPage',
Extends: Gtk.Frame,
Properties: {
'title': GObject.ParamSpec.string('title',
'Article title',
'Human-readable title for the article to be displayed',
GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT,
''),
'article-uri': GObject.ParamSpec.string('article-uri',
'Article URI',
'Last component of the Wikipedia URI for the article',
GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT,
'')
},
_init: function(props) {
this._title = null;
//We don't use article_uri now since the database only needs to readable title.
this._article_uri = null;
// Create widgets
this._grid = new Gtk.Grid({
orientation: Gtk.Orientation.VERTICAL,
expand: true
});
this._title_label = new Gtk.Label({
vexpand: false,
halign: Gtk.Align.START
});
this._separator = new Gtk.Separator({
orientation: Gtk.Orientation.HORIZONTAL,
vexpand: false
});
this._wiki_view = new WikipediaView.WikipediaView();
// Put the webview in a scrolledWindow to handle large page sizes
let scrolledWindow = new Gtk.ScrolledWindow ({
hscrollbar_policy: Gtk.PolicyType.AUTOMATIC,
vscrollbar_policy: Gtk.PolicyType.AUTOMATIC,
expand: true});
scrolledWindow.add(this._wiki_view);
this.parent(props);
this._grid.add(this._title_label);
this._grid.add(this._separator);
this._grid.add(scrolledWindow);
this.add(this._grid);
// Add style contexts for CSS
let context = this._title_label.get_style_context();
context.add_class(EndlessWikipedia.STYLE_CLASS_TITLE);
context.add_class(EndlessWikipedia.STYLE_CLASS_ARTICLE);
context.add_class(EndlessWikipedia.STYLE_CLASS_ARTICLES_PAGE);
context.add_class(EndlessWikipedia.STYLE_CLASS_PREBUILT);
let context = this._separator.get_style_context();
context.add_class(EndlessWikipedia.STYLE_CLASS_ARTICLES_PAGE);
let context = this.get_style_context();
context.add_class(EndlessWikipedia.STYLE_CLASS_ARTICLES_PAGE);
},
get title() {
return this._title;
},
set title(value) {
this._title = value;
if(this._title_label)
this._title_label.label = value.toUpperCase();
},
get article_uri() {
return this._article_uri;
},
set article_uri(value) {
this._article_uri = value;
}
});
|