-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-assistant.py
More file actions
executable file
·80 lines (63 loc) · 2.34 KB
/
setup-assistant.py
File metadata and controls
executable file
·80 lines (63 loc) · 2.34 KB
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
#!/usr/bin/env python3
import gi, os, pathlib
gi.require_version("Gtk", "3.0")
gi.require_version("Gst", "1.0")
from gi.repository import Gtk, Gst, GObject
VIDEO_PATH = str(pathlib.Path.home() / "setup-assistant" / "video" / "welcome.mp4")
MARKER_FILE = str(pathlib.Path.home() / ".setup_assistant_done")
class SetupAssistant(Gtk.Window):
def __init__(self):
super().__init__()
self.set_title("Setup Assistant")
self.set_decorated(False)
self.fullscreen()
Gst.init(None)
self.player = Gst.ElementFactory.make("playbin", "player")
self.player.set_property("uri", "file://" + VIDEO_PATH)
sink = Gst.ElementFactory.make("gtksink", "sink")
self.player.set_property("video-sink", sink)
self.video_widget = sink.props.widget
overlay = Gtk.Overlay()
self.add(overlay)
overlay.add(self.video_widget)
self.button = Gtk.Button(label=" Lets Go! ")
self.button.set_size_request(220, 90)
self.button.connect("clicked", self.on_start_clicked)
overlay.add_overlay(self.button)
self.button.set_halign(Gtk.Align.CENTER)
self.button.set_valign(Gtk.Align.END)
self.button.set_margin_bottom(40)
css = b"""
button {
border-radius: 999px;
box-shadow: none;
font-size: 36px;
font-weight: bold;
}
"""
style_provider = Gtk.CssProvider()
style_provider.load_from_data(css)
Gtk.StyleContext.add_provider_for_screen(
self.get_screen(),
style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
)
bus = self.player.get_bus()
bus.add_signal_watch()
bus.connect("message::eos", self.on_eos)
self.connect("destroy", Gtk.main_quit)
def on_eos(self, bus, msg):
self.player.seek_simple(
Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, 0
)
def on_start_clicked(self, button):
self.player.set_state(Gst.State.NULL)
pathlib.Path(MARKER_FILE).touch()
Gtk.main_quit()
if __name__ == "__main__":
if os.path.exists(MARKER_FILE):
exit(0)
win = SetupAssistant()
win.show_all()
win.player.set_state(Gst.State.PLAYING)
Gtk.main()