6 from addedit
import VSPACING
, HSPACING
8 from choices
import settings
11 plugins
.types
['diskactivity'] = _("Disk Activity")
14 platform
= plugins
.get_platform()
17 class Description(bardesc
.Description
):
18 def __init__(self
, num
):
19 bardesc
.Description
.__init
__(self
, num
)
20 self
.type = 'diskactivity'
21 self
.disk
= settings
.get_bar(num
, 'disk', 'sda')
22 self
.throughput
= settings
.get_throughput(self
.disk
)
23 platform
.init_disk_throughput(self
.disk
, self
.throughput
)
26 return _("Disk %s") % self
.disk
28 def change_num(self
, num
):
29 bardesc
.Description
.change_num(self
, num
)
30 settings
.set_bar(num
, 'disk', self
.disk
)
33 rng
= platform
.get_disk_activity_range(self
.disk
)
34 if rng
[1] > self
.throughput
:
35 self
.throughput
= rng
[1]
36 settings
.set_throughput(self
.disk
, self
.throughput
)
39 def get_reading(self
):
40 return platform
.get_disk_activity(self
.disk
)
44 class Dialog(addedit
.Dialog
):
45 def get_type_name(self
):
46 return _("Disk Activity")
48 def layout_for_type(self
):
50 hbox
.pack_start(self
.make_label(_("Disk")) , False, True, HSPACING
)
51 self
.disk_w
= g
.combo_box_new_text()
52 disks
= platform
.list_disks()
55 self
.disk_w
.append_text(d
)
56 if self
.desc
.disk
in disks
:
57 self
.disk_w
.set_active(disks
.index(self
.desc
.disk
))
59 self
.disk_w
.set_active(0)
60 hbox
.pack_start(self
.disk_w
, True, True, HSPACING
)
61 self
.vbox
.pack_start(hbox
, True, True, VSPACING
)
62 if self
.instant_apply
:
63 self
.disk_w
.connect("changed", self
.disk_changed_cb
)
66 self
.disk_changed_cb()
67 addedit
.Dialog
.apply(self
)
69 def disk_changed_cb(self
, w
= None):
70 disk
= self
.disks
[self
.disk_w
.get_active()]
72 settings
.set_bar(self
.desc
.num
, 'disk', disk
)
73 if self
.instant_apply
:
74 self
.bar_w
.whole_redraw()
75 self
.parent_win
.update_bar_name(self
.desc
)
77 def get_default_label(self
):