| 1 |
// Copyright 2013 Endless Mobile, Inc. |
| 2 |
|
| 3 |
const Lang = imports.lang; |
| 4 |
const Gtk = imports.gi.Gtk; |
| 5 |
const GObject = imports.gi.GObject; |
| 6 |
const Endless = imports.gi.Endless; |
| 7 |
|
| 8 |
const TEST_APPLICATION_ID = "com.frametest"; |
| 9 |
|
| 10 |
let TRANSITION1 = Gtk.StackTransitionType.SLIDE_LEFT; |
| 11 |
let TRANSITION2 = Gtk.StackTransitionType.SLIDE_RIGHT; |
| 12 |
if (ARGV[0] === "crossfade") { |
| 13 |
TRANSITION1 = Gtk.StackTransitionType.CROSSFADE; |
| 14 |
TRANSITION2 = Gtk.StackTransitionType.CROSSFADE; |
| 15 |
} |
| 16 |
|
| 17 |
let BACKGROUND1_NAME = "page1_1080"; |
| 18 |
let BACKGROUND2_NAME = "page2_1080"; |
| 19 |
if (ARGV[1] === "720") { |
| 20 |
BACKGROUND1_NAME = "page1_720"; |
| 21 |
BACKGROUND2_NAME = "page2_720"; |
| 22 |
} |
| 23 |
|
| 24 |
const TestApplication = new Lang.Class ({ |
| 25 |
Name: "TestApplication", |
| 26 |
Extends: Gtk.Application, |
| 27 |
|
| 28 |
vfunc_startup: function() { |
| 29 |
this.parent(); |
| 30 |
|
| 31 |
// First page |
| 32 |
this._page1 = new Gtk.EventBox({ |
| 33 |
name: BACKGROUND1_NAME, |
| 34 |
expand: true |
| 35 |
}); |
| 36 |
this._page1.connect("button-press-event", Lang.bind(this, function () { |
| 37 |
this._stack.set_transition_type(TRANSITION1); |
| 38 |
this._stack.set_visible_child(this._page2); |
| 39 |
})); |
| 40 |
|
| 41 |
// Second page |
| 42 |
this._page2 = new Gtk.Button({ |
| 43 |
name: BACKGROUND2_NAME, |
| 44 |
expand: true |
| 45 |
}); |
| 46 |
this._page2.connect("button-press-event", Lang.bind(this, function () { |
| 47 |
this._stack.set_transition_type(TRANSITION2); |
| 48 |
this._stack.set_visible_child(this._page1); |
| 49 |
})); |
| 50 |
|
| 51 |
this._stack = new Gtk.Stack(); |
| 52 |
this._stack.add(this._page1); |
| 53 |
this._stack.add(this._page2); |
| 54 |
|
| 55 |
this._stack.set_transition_duration(10000); |
| 56 |
|
| 57 |
this._window = new Gtk.Window({ |
| 58 |
application: this, |
| 59 |
}); |
| 60 |
this._window.add(this._stack); |
| 61 |
this._window.show_all(); |
| 62 |
this._window.fullscreen(); |
| 63 |
this._window.connect("key-press-event", Lang.bind(this, function() { |
| 64 |
this._window.destroy(); |
| 65 |
})); |
| 66 |
|
| 67 |
let provider = new Gtk.CssProvider (); |
| 68 |
provider.load_from_path (Endless.getCurrentFileDir() + "/gtk.css"); |
| 69 |
let context = new Gtk.StyleContext(); |
| 70 |
context.add_provider_for_screen(this._window.get_screen(), |
| 71 |
provider, |
| 72 |
Gtk.STYLE_PROVIDER_PRIORITY_USER); |
| 73 |
|
| 74 |
}, |
| 75 |
|
| 76 |
vfunc_activate: function() { |
| 77 |
this.parent(); |
| 78 |
} |
| 79 |
}); |
| 80 |
|
| 81 |
let app = new TestApplication({ application_id: TEST_APPLICATION_ID, |
| 82 |
flags: 0 }); |
| 83 |
app.run(ARGV); |