This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
GtkStack1.lua
94 lines (82 loc) · 1.93 KB
/
GtkStack1.lua
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
89
90
91
92
93
94
local lgi = require("lgi")
local Gtk = lgi.require("Gtk", "3.0")
local App = Gtk.Application({
application_id = "com.github.Miqueas.Lua-GTK3-Examples.GtkStack1"
})
function App:on_startup()
Gtk.ApplicationWindow({
application = self,
default_width = 600,
default_height = 400,
border_width = 10
})
end
function App:on_activate()
self.active_window:set_titlebar(Gtk.HeaderBar({
visible = true,
show_close_button = true,
title = "GtkStack",
subtitle = "Example 1"
}))
--[[ GtkStack:
A container that shows only one (1) child at a time
]]
local Stack = Gtk.Stack({
visible = true,
transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT,
-- Increment this value to see the animation more slow
transition_duration = 280,
{
Gtk.Label({
visible = true,
label = "<span size='xx-large' font_weight='bold'>Page 0</span>",
use_markup = true
}),
title = "Page 0",
name = "Page0"
},
{
Gtk.Label({
visible = true,
label = "<span size='xx-large' font_weight='bold'>Page 1</span>",
use_markup = true
}),
title = "Page 1",
name = "Page1"
},
{
Gtk.Label({
visible = true,
label = "<span size='xx-large' font_weight='bold'>Page 2</span>",
use_markup = true
}),
title = "Page 2",
name = "Page2"
},
{
Gtk.Label({
visible = true,
label = "<span size='xx-large' font_weight='bold'>Page 3</span>",
use_markup = true
}),
title = "Page 3",
name = "Page3"
}
})
local Box = Gtk.Box({
visible = true,
orientation = Gtk.Orientation.VERTICAL,
{
Stack,
expand = true
},
Gtk.StackSwitcher({
visible = true,
stack = Stack,
halign = Gtk.Align.CENTER
})
})
self.active_window:add(Box)
self.active_window:present()
end
return App:run(arg)