29
30
def __init__(self, applet, parent):
30
31
self.applet = applet
31
32
self.parent = parent
33
self.preferences_dialog = self.applet.dialog.new('preferences')
34
self.preferences_dialog.connect('show', self.show_event_cb)
36
def create_display_parameter_list(self):
37
cell_box = self.create_treeview()
38
store = cell_box.liststore
39
ddps = 'device_display_parameters'
40
prefs = self.parent.applet.settings[ddps]
41
for device_pref in prefs:
42
dpv = device_pref.split('|')
46
current_iter = store.append([iface, sum_include,
47
muti_include, '', '', '#ff0000', '#ffff00'])
48
ifaces = self.parent.netstats.ifaces
49
for iface in sorted(self.parent.netstats.ifaces):
50
if not 'Multi Interface' in iface \
51
and not 'Sum Interface' in iface and \
52
not iface in prefs.__str__():
53
sum_include = True if ifaces[iface]['sum_include'] \
55
multi_include = True if ifaces[iface]['multi_include'] \
57
current_iter = store.append([iface, sum_include,
58
multi_include, '', '', '#ff0000', '#ffff00'])
59
for child in self.prefs_ui.get_object('scrolledwindow1').get_children():
60
self.prefs_ui.get_object('scrolledwindow1').remove(child)
62
self.prefs_ui.get_object('scrolledwindow1').add_with_viewport(cell_box)
34
66
prefs_ui = gtk.Builder()
67
self.prefs_ui = prefs_ui
35
68
prefs_ui.add_from_file(self.parent.UI_FILE)
36
preferences_vbox = self.applet.dialog.new('preferences').vbox
37
cell_box = self.create_treeview()
38
store = cell_box.liststore
69
preferences_vbox = self.preferences_dialog.vbox
39
70
scaleThresholdSBtn = prefs_ui.get_object('scaleThresholdSBtn')
40
71
thresholdLabel = prefs_ui.get_object('label-scaleThreshold')
41
72
scaleThresholdSBtn.set_value(
88
119
labelNoneRadiobutton.connect('toggled', self.labelRadio_cb, 0)
89
120
labelSumRadiobutton.connect('toggled', self.labelRadio_cb, 1)
90
121
labelBothRadiobutton.connect('toggled', self.labelRadio_cb, 2)
91
for iface in sorted(self.parent.netstats.ifaces):
92
if not 'Multi Interface' in iface \
93
and not 'Sum Interface' in iface:
94
if self.parent.netstats.ifaces[iface]['sum_include'] == True:
98
if self.parent.netstats.ifaces[iface]['multi_include'] == True:
102
current_iter = store.append([iface, sum_include,
103
muti_include, '', '', '#ff0000', '#ffff00'])
104
prefs_ui.get_object('scrolledwindow1').add_with_viewport(cell_box)
105
122
prefs_ui.get_object('dialog-notebook').reparent(preferences_vbox)
107
124
def graphZeroToggle_cb(self, widget):
123
140
treeview.set_enable_search(True)
124
141
treeview.position = 0
125
142
rows = gtk.VBox(False, 3)
143
if hasattr(self, 'liststore'):
126
145
self.liststore = liststore
127
146
listcols = gtk.HBox(False, 0)
128
147
prows = gtk.VBox(False, 0)
194
213
def devlist_cell_func(self, column, cell, model, iter):
195
214
''' Changes the cell color to match the preferece or selected value '''
196
device = self.liststore.get_value(iter, 0)
197
column_title = column.get_title().lower().split(' ')[0]
198
cell.set_property('cell-background',
199
self.get_color(device, column_title))
216
device = self.liststore.get_value(iter, 0)
217
column_title = column.get_title().lower().split(' ')[0]
218
cell.set_property('cell-background',
219
self.get_color(device, column_title))
201
223
def bgCheckbutton_cb(self, widget):
202
224
self.applet.settings['background'] = widget.get_active()
246
268
response = colorseldlg.run()
247
269
if response == gtk.RESPONSE_OK:
248
270
self.color_choice = colorseldlg.colorsel.get_current_color()
249
self.parent.netstats.ifaces[model[path][0]]['%s_color' \
250
% prop.lower()] = self.color_choice.to_string()
271
if model[path][0] in self.parent.netstats.ifaces:
272
self.parent.netstats.ifaces[model[path][0]]['%s_color' \
273
% prop.lower()] = self.color_choice.to_string()
251
274
prefs = self.applet.settings['device_display_parameters']
253
276
prefs = ['%s|True|True|None|None' % (model[path][0])]