-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLauncher.py
61 lines (48 loc) · 1.66 KB
/
Launcher.py
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
from App import App
from AppWindow import *
from AppProvider import AppProvider
import Logger
REFRESH_RATE = 1 # seconds
class Launcher(object):
def __init__(self):
# Create Apps
self.apps = {}
self.num_windows = 0
self.last_slot = self.num_windows
self.createApps()
def createApps(self):
# create app launchers
self.apps = {}
for app_detail in AppProvider.getAppList(True):
self.apps[app_detail[0]] = App(self, app_detail)
self.apps[app_detail[0]].window.hide()
def update(self):
AppProvider.update()
Logger.log("GUI update")
for app in self.apps.values():
if not app.set_running(AppProvider.isAppRunning(app.exec_path)):
continue
self.last_slot = max(self.last_slot + 1, self.num_windows)
app_width, app_height = Clickable.SIZE
screen_width, screen_height = app.window.get_screen_size()
app.move(self.last_slot * app_width, screen_height - app_height)
return True
def start(self):
Logger.log("Starting...")
GLib.threads_init()
GLib.timeout_add_seconds(REFRESH_RATE, self.update)
Gtk.main()
def show_app(self, app):
self.num_windows += 1
def hide_app(self, app):
self.num_windows -= 1
def focus_app(self, app):
AppProvider.focusApp(app.exec_path)
def close_app(self, app):
AppProvider.killApp(app.exec_path)
@staticmethod
def close_parent(btn):
btn.get_parent_window().destroy()
Launcher.num_windows -= 1
if (Launcher.num_windows <= 0):
Gtk.main_quit()