summaryrefslogtreecommitdiffstats
path: root/liveusb/launcher.py
blob: 3fee9108072a695e588ff640fd0b28606e6a0727 (plain)
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
# -*- coding: utf-8 -*-
#
# Copyright © 2012-2015, Tails developers <tails@boum.org>

"""
A unified launcher for the most common LiveUSBCreator usecases
"""

import os

from gi.repository import Gtk

from liveusb import _
from liveusb.utils import _get_datadir, is_running_from_tails

class LiveUSBLauncherWindow(Gtk.ApplicationWindow):
    """ Our main dialog class """

    def __init__(self, args):
        Gtk.ApplicationWindow.__init__(self)

        self.args = args
        if os.getenv('DEBUG', 0):
            self.args = self.args + ['--verbose']

        self.connect('delete-event', Gtk.main_quit)
        builder = Gtk.Builder.new_from_file(
                os.path.join(_get_datadir(), 'liveusb-creator-launcher.ui'))
        builder.connect_signals(self)
        self.add(builder.get_object('box_launcher'))
        self.set_title(_("Tails USB Installer"))

        if not is_running_from_tails():
            builder.get_object('box_tails').set_visible(False)
            builder.get_object('box_standalone').set_visible(True)

        self.show()

    def run_live_usb_creator(self, args):
        args = ['liveusb-creator'] + args + self.args
        os.execvp('liveusb-creator', args)

    def on_clone_install(self, widget, data=None):
        self.run_live_usb_creator([ '-u', '-n', '--clone', '-P', '-m', '-x' ])

    def on_clone_upgrade(self, widget, data=None):
        self.run_live_usb_creator([ '-u', '-n', '-x', '--clone' ])

    def on_upgrade_iso(self, widget, data=None):
        self.run_live_usb_creator([ '-u', '-n', '-x' ])

    def on_install_iso(self, widget, data=None):
        self.run_live_usb_creator([ '-u', '-n', '-P', '-m', '-x' ])