summaryrefslogtreecommitdiff
path: root/test/smoke-tests/splash-page.js
blob: ff52a9f9a25850ef8babb69f0ce9ecaf81368b07 (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
51
52
53
54
55
// Copyright 2013 Endless Mobile, Inc.

const Lang = imports.lang;
const Endless = imports.gi.Endless;
const Gtk = imports.gi.Gtk;

const TEST_APPLICATION_ID = 'com.endlessm.example.test';

const TestApplication = new Lang.Class ({
    Name: 'TestApplication',
    Extends: Endless.Application,

    vfunc_startup: function() {
        this.parent();

        // First page
        this._splash_page = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL });
        let splash_label = new Gtk.Label({ label: 'The Splash Page' });
        this._splash_page.add(splash_label);
        let splash_button = new Gtk.Button({ label: 'Show main page' });
        splash_button.connect('clicked', Lang.bind(this, function () {
            this._pm.show_main_page();
        }));
        this._splash_page.add(splash_button);

        // Second page
        this._main_page = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL });
        let main_label = new Gtk.Label({ label: 'The Main Page' });
        this._main_page.add(main_label);
        let main_button = new Gtk.Button({ label: 'Go back to splash page' });
        main_button.connect('clicked', Lang.bind(this, function () {
            this._pm.show_splash_page();
        }));
        this._main_page.add(main_button);

        this._pm = new Endless.SplashPageManager();
        this._pm.set_splash_page(this._splash_page);
        this._pm.set_main_page(this._main_page);

        this._window = new Endless.Window({
            application: this,
            border_width: 16,
            page_manager: this._pm
        });
        this._window.show_all();
    },

    _onButtonClicked: function () {
        this._window.destroy();
    },
});

let app = new TestApplication({ application_id: TEST_APPLICATION_ID,
                                flags: 0 });
app.run(ARGV);