summaryrefslogtreecommitdiff
path: root/wikipedia/widgets/category_back_button.js
blob: 312d7afd0787c529e7a215f1611c1d3844bfd792 (plain)
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
// Copyright 2014 Endless Mobile, Inc.

const Gettext = imports.gettext;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;

const CompositeButton = imports.wikipedia.widgets.composite_button;
const Config = imports.wikipedia.config;

const _ = function (string) { return GLib.dgettext('eos-sdk', string); };
Gettext.bindtextdomain('eos-sdk', Config.DATADIR + '/locale');

const CATEGORY_BACK_BUTTON_RESOURCE_URI = 'resource:///com/endlessm/wikipedia-domain/assets/wikipedia-category-back-symbolic.svg';
const CATEGORY_BACK_BUTTON_SIZE_PIXELS = 68;
const STYLE_CONTEXT_LABEL = 'label';
const STYLE_CONTEXT_BACK = 'back';

const CategoryBackButton = new Lang.Class({
    Name: 'CategoryBackButton',
    GTypeName: 'CategoryBackButton',
    Extends: CompositeButton.CompositeButton,

    _init: function(props) {
        this.parent(props);

        let gicon = new Gio.FileIcon({
            file: Gio.File.new_for_uri(CATEGORY_BACK_BUTTON_RESOURCE_URI)
        });
        let icon = Gtk.Image.new_from_gicon(gicon, Gtk.IconSize.DIALOG);
        icon.pixel_size = CATEGORY_BACK_BUTTON_SIZE_PIXELS;
        let label = new Gtk.Label({
            label: _("OTHER CATEGORIES")
        });
        let innerGrid = new Gtk.Grid({
            expand: true,
            valign: Gtk.Align.CENTER
        });

        innerGrid.add(icon);
        innerGrid.add(label);
        this.add(innerGrid);
        this.setSensitiveChildren([icon, label]);

        // Define style classes for CSS
        icon.get_style_context().add_class(Gtk.STYLE_CLASS_IMAGE);
        label.get_style_context().add_class(STYLE_CONTEXT_LABEL);
        this.get_style_context().add_class(STYLE_CONTEXT_BACK);
    }
});