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
|
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const EndlessWikipedia = imports.wikipedia.EndlessWikipedia;
const CategorySelectorView = imports.wikipedia.widgets.category_selector_view;
const TITLE_CATEGORY_COLUMN_SPACING = 10; // pixels
GObject.ParamFlags.READWRITE = GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE;
const PrebuiltFrontPage = new Lang.Class({
Name: 'PrebuiltFrontPage',
Extends: Gtk.Grid,
Signals: {
'category-chosen': {
param_types: [GObject.TYPE_STRING, GObject.TYPE_INT]
}
},
_init: function(props) {
this._category_selector = new CategorySelectorView.CategorySelectorView();
props = props || {};
props.orientation = Gtk.Orientation.HORIZONTAL;
props.column_spacing = TITLE_CATEGORY_COLUMN_SPACING;
this.parent(props);
this.add(this._category_selector);
this._category_selector.connect('category-chosen',
Lang.bind(this, this._onCategoryChosen));
},
get title() {
return this._title;
},
set title(value) {
this._title = value;
this._title_label.title = value;
},
get image_uri() {
return this._image_uri;
},
set image_uri(value) {
this._image_uri = value;
this._title_label.image_uri = value;
},
setCategories: function(categories) {
this._category_selector.setCategories(categories);
},
// Proxy signal
_onCategoryChosen: function(widget, title, index) {
this.emit('category-chosen', title, index);
}
});
|