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
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@author: Alessandro Facciorusso
"""
from gi.repository import Gtk
from gettext import gettext as _
class InstallProgressDialog(Gtk.Dialog):
"""A dialog for Progress of installation of bumblebee."""
def __init__(self, parent):
Gtk.Dialog.__init__(self, _("Bumblebee is installing..."), parent, Gtk.DialogFlags.MODAL,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
self.progress = 0.0
self.set_default_size(350, -1)
self.set_deletable(False)
button = self.get_widget_for_response(Gtk.ResponseType.CANCEL)
button.set_sensitive(False)
self.mainLayout = Gtk.Box(homogeneous=True, orientation=Gtk.Orientation.VERTICAL)
self.get_content_area().add(self.mainLayout)
self.label = Gtk.Label()
self.mainLayout.pack_start(self.label, False, False, 0)
self.progressBar = Gtk.ProgressBar()
self.mainLayout.pack_start(self.progressBar, True, False, 0)
self.show_all()
def setMessage(self, message):
self.label.set_text(message)
def setProgress(self, percent=None):
if percent == None:
self.progressBar.pulse()
else:
self.progress = percent
self.progressBar.set_fraction(percent / 100)
def getProgress(self):
return self.progress
def downloadingCb(self, percent):
self.setMessage(_("Downloading files..."))
self.setProgress(percent)
def installingCb(self, msg, percent):
if msg != "__FINISHED__":
self.setMessage(msg)
self.setProgress(percent)
else:
self.hide()
|