~martijnbraam/pyatem

pyatem/gtk_switcher/__main__.py -rw-r--r-- 1.8 KiB
ed164087Martijn Braam i18n: update translation files from source 4 days ago
                                                                                
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
import argparse
import locale
import gettext
import os
import gi

from gtk_switcher.atemwindow import AtemWindow

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio

gi.require_version('Handy', '1')
from gi.repository import Handy


class AtemApplication(Gtk.Application):
    def __init__(self, application_id, flags, args):
        Gtk.Application.__init__(self, application_id=application_id, flags=flags)
        self.connect("activate", self.new_window)
        self.args = args

        settings = Gtk.Settings.get_default()
        settings.set_property("gtk-application-prefer-dark-theme", True)

    def new_window(self, *args):
        AtemWindow(self, self.args)


def main(version):
    Handy.init()

    parser = argparse.ArgumentParser(description="ATEM Control panel")
    parser.add_argument('ip', help='ip-address of the switcher to connect to', nargs='?')
    parser.add_argument('--persist', action='store_true', help='save the new ip address')
    parser.add_argument('--debug', action='store_true', help='output extra debugging info')
    parser.add_argument('--dump', help='dump data for specific packets', nargs='*')
    parser.add_argument('--view', choices=['switcher', 'media', 'audio', 'camera'], default='switcher',
                        help='default view to open when launching')
    args = parser.parse_args()

    if os.path.isfile('atem.gresource'):
        print("Using resources from cwd")
        resource = Gio.resource_load("atem.gresource")
        Gio.Resource._register(resource)

    app = AtemApplication("nl.brixit.Switcher", Gio.ApplicationFlags.FLAGS_NONE, args=args)
    app.run()


if __name__ == '__main__':
    locale.bindtextdomain("openswitcher", os.getenv('LOCALEDIR', '.'))
    gettext.install("openswitcher", os.getenv('LOCALEDIR', '.'))
    locale.textdomain("openswitcher")

    main('')