- # set up the window
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.window.set_title(_("Tor Browser"))
- self.window.set_icon_from_file(self.common.paths['icon_file'])
- self.window.set_position(gtk.WIN_POS_CENTER)
- self.window.set_border_width(10)
- self.window.connect("delete_event", self.delete_event)
- self.window.connect("destroy", self.destroy)
-
- # build the rest of the UI
- self.build_ui()
-
- # download or run TBB
- def start_launcher(self):
- # is TBB already installed?
- latest_version = self.common.settings['latest_version']
- installed_version = self.common.settings['installed_version']
-
- # verify installed version for newer versions of TBB (#58)
- if installed_version >= '3.0':
- versions_filename = self.common.paths['tbb']['versions']
- if os.path.exists(versions_filename):
- for line in open(versions_filename):
- if 'TORBROWSER_VERSION' in line:
- installed_version = line.lstrip('TORBROWSER_VERSION=').strip()
-
- start = self.common.paths['tbb']['start']
- if os.path.isfile(start) and os.access(start, os.X_OK):
- if installed_version == latest_version:
- print _('Latest version of TBB is installed, launching')
- # current version of tbb is installed, launch it
- self.run(False)
- self.launch_gui = False
- elif installed_version < latest_version:
- print _('TBB is out of date, attempting to upgrade to {0}'.format(latest_version))
- # there is a tbb upgrade available
- self.set_gui('task', _("Your Tor Browser is out of date. Upgrading from {0} to {1}.".format(installed_version, latest_version)),
- ['download_sha256',
- 'download_sha256_sig',
- 'download_tarball',
- 'verify',
- 'extract',
- 'run'])
- else:
- # for some reason the installed tbb is newer than the current version?
- self.set_gui('error', _("Something is wrong. The version of Tor Browser Bundle you have installed is newer than the current version?"), [])
-
- # not installed
- else:
- print _('TBB is not installed, attempting to install {0}'.format(latest_version))
- self.set_gui('task', _("Downloading and installing Tor Browser for the first time."),
- ['download_sha256',
- 'download_sha256_sig',
- 'download_tarball',
- 'verify',
- 'extract',
- 'run'])
-
- # there are different GUIs that might appear, this sets which one we want
- def set_gui(self, gui, message, tasks, autostart=True):
+ # Build the rest of the UI
+
+ # Set up the window
+ self.setWindowTitle(_("Tor Browser"))
+ self.setWindowIcon(QtGui.QIcon(self.common.paths['icon_file']))
+
+ # Label
+ self.label = QtWidgets.QLabel()
+
+ # Progress bar
+ self.progress_bar = QtWidgets.QProgressBar()
+ self.progress_bar.setTextVisible(True)
+ self.progress_bar.setMinimum(0)
+ self.progress_bar.setMaximum(0)
+ self.progress_bar.setValue(0)
+
+ # Buttons
+ self.yes_button = QtWidgets.QPushButton()
+ self.yes_button.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_DialogApplyButton))
+ self.yes_button.clicked.connect(self.yes_clicked)
+ self.start_button = QtWidgets.QPushButton(_('Start'))
+ self.start_button.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_DialogApplyButton))
+ self.start_button.clicked.connect(self.start)
+ self.cancel_button = QtWidgets.QPushButton()
+ self.cancel_button.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_DialogCancelButton))
+ self.cancel_button.clicked.connect(self.close)
+ buttons_layout = QtWidgets.QHBoxLayout()
+ buttons_layout.addStretch()
+ buttons_layout.addWidget(self.yes_button)
+ buttons_layout.addWidget(self.start_button)
+ buttons_layout.addWidget(self.cancel_button)
+ buttons_layout.addStretch()
+
+ # Layout
+ layout = QtWidgets.QVBoxLayout()
+ layout.addWidget(self.label)
+ layout.addWidget(self.progress_bar)
+ layout.addLayout(buttons_layout)
+
+ central_widget = QtWidgets.QWidget()
+ central_widget.setLayout(layout)
+ self.setCentralWidget(central_widget)
+
+ self.update()
+
+ # Set the current state of Tor Browser Launcher
+ def set_state(self, gui, message, tasks, autostart=True):