6 from addedit
import VSPACING
, HSPACING
8 from choices
import settings
11 plugins
.types
['cpu'] = _("CPU Load")
14 platform
= plugins
.get_platform()
19 return os
.sysconf("SC_NPROCESSORS_ONLN")
22 # FIXME: SC_NPROCESSORS_ONLN may not be standard, try /proc/stat
26 class Description(bardesc
.Description
):
27 def __init__(self
, num
):
28 bardesc
.Description
.__init
__(self
, num
)
30 self
.cpu
= settings
.get_bar_int(num
, 'cpu', -1)
36 return _("CPU %d") % self
.cpu
38 def change_num(self
, num
):
39 bardesc
.Description
.change_num(self
, num
)
40 settings
.set_bar(num
, 'cpu', self
.cpu
)
43 return platform
.get_cpu_load_range()
45 def get_reading(self
):
46 return platform
.get_cpu_load(self
.cpu
)
50 class Dialog(addedit
.Dialog
):
51 def get_type_name(self
):
54 def layout_for_type(self
):
56 hbox
.pack_start(self
.make_label(_("CPU")) , False, True, HSPACING
)
57 self
.cpu_w
= g
.combo_box_new_text()
58 self
.cpu_w
.append_text(_("All"))
59 for n
in range(get_n_cpus()):
60 self
.cpu_w
.append_text(str(n
))
61 self
.cpu_w
.set_active(self
.desc
.cpu
+ 1)
62 hbox
.pack_start(self
.cpu_w
, True, True, HSPACING
)
63 self
.vbox
.pack_start(hbox
, True, True, VSPACING
)
64 if self
.instant_apply
:
65 self
.cpu_w
.connect("changed", self
.cpu_changed_cb
)
69 addedit
.Dialog
.apply(self
)
71 def cpu_changed_cb(self
, w
= None):
72 cpu
= self
.cpu_w
.get_active()
78 settings
.set_bar(self
.desc
.num
, 'cpu', cpu
)
79 if self
.instant_apply
:
80 self
.bar_w
.whole_redraw()
81 self
.parent_win
.update_bar_name(self
.desc
)
83 def get_default_label(self
):