172
178
def init_auto_update(self):
173
179
""" Set up the widgets that allow to configure the update automation """
174
self.combobox_update_interval = Gtk.ComboBoxText.new_with_entry()
175
self.hbox_check_for_updates.pack_start(self.combobox_update_interval, True, True, 0)
176
180
self.combobox_update_interval.show()
178
182
# this maps the key (combo-box-index) to the auto-update-interval value
179
# where (-1) means, no key
180
self.combobox_interval_mapping = { 0 : 1,
184
self.combobox_update_interval.set_active(0)
186
#update_days = apt_pkg.Config.FindI(softwareproperties.CONF_MAP["autoupdate"])
187
self.combobox_update_interval.append_text(_("Daily"))
188
self.combobox_update_interval.append_text(_("Every two days"))
189
self.combobox_update_interval.append_text(_("Weekly"))
190
self.combobox_update_interval.append_text(_("Every two weeks"))
192
model_check_interval = Gtk.ListStore(gobject.TYPE_STRING,
183
model = self.combobox_update_interval.get_model()
184
self.combobox_interval_mapping = {}
185
for (i, row) in enumerate(model):
186
# column 1 is the update interval
187
value = model.get_value(row.iter, 1)
188
self.combobox_interval_mapping[i] = value
194
190
update_days = self.get_update_interval()
196
192
# If a custom period is defined add a corresponding entry
205
201
self.combobox_update_interval.set_active(key)
209
self.checkbutton_auto_update.set_active(True)
210
self.combobox_update_interval.set_sensitive(True)
211
self.vbox_auto_updates.set_sensitive(True)
213
self.checkbutton_auto_update.set_active(False)
214
self.combobox_update_interval.set_sensitive(False)
215
self.vbox_auto_updates.set_sensitive(False)
217
self.handlers.append(
218
(self.checkbutton_auto_update,
219
self.checkbutton_auto_update.connect("toggled",
220
self.on_auto_update_toggled)))
221
204
self.handlers.append(
222
205
(self.combobox_update_interval,
223
206
self.combobox_update_interval.connect("changed",
224
207
self.on_combobox_update_interval_changed)))
225
self.handlers.append(
226
(self.radiobutton_updates_download,
227
self.radiobutton_updates_download.connect("toggled",
228
self.set_update_automation_level,
229
softwareproperties.UPDATE_DOWNLOAD)))
230
self.handlers.append(
231
(self.radiobutton_updates_inst_sec,
232
self.radiobutton_updates_inst_sec.connect("toggled",
233
self.set_update_automation_level,
234
softwareproperties.UPDATE_INST_SEC)))
235
self.handlers.append(
236
(self.radiobutton_updates_notify,
237
self.radiobutton_updates_notify.connect("toggled",
238
self.set_update_automation_level,
239
softwareproperties.UPDATE_NOTIFY)))
209
self.handlers.append(
210
(self.combobox_security_updates,
211
self.combobox_security_updates.connect("changed",
212
self.set_sec_update_automation_level)))
214
self.handlers.append(
215
(self.combobox_security_updates,
216
self.combobox_other_updates.connect("changed",
217
self.set_other_update_automation_level)))
241
220
def show_auto_update_level(self):
242
221
"""Represent the level of update automation in the user interface"""
243
level = self.get_update_automation_level()
244
self.block_handlers()
246
self.radiobutton_updates_inst_sec.set_inconsistent(True)
247
self.radiobutton_updates_download.set_inconsistent(True)
248
self.radiobutton_updates_notify.set_inconsistent(True)
223
""" Security Updates """
224
level_sec = self.get_update_automation_level()
225
if level_sec == None:
226
self.combobox_security_updates.set_sensitive(False)
250
self.radiobutton_updates_inst_sec.set_inconsistent(False)
251
self.radiobutton_updates_download.set_inconsistent(False)
252
self.radiobutton_updates_notify.set_inconsistent(False)
253
if level == softwareproperties.UPDATE_MANUAL or \
254
level == softwareproperties.UPDATE_NOTIFY:
255
self.radiobutton_updates_notify.set_active(True)
256
elif level == softwareproperties.UPDATE_DOWNLOAD:
257
self.radiobutton_updates_download.set_active(True)
258
elif level == softwareproperties.UPDATE_INST_SEC:
259
self.radiobutton_updates_inst_sec.set_active(True)
260
# Unblock the toggle handlers
261
self.unblock_handlers()
228
self.combobox_security_updates.set_sensitive(True)
230
if level_sec == softwareproperties.UPDATE_MANUAL or \
231
level_sec == softwareproperties.UPDATE_NOTIFY:
232
self.combobox_security_updates.set_active(0) # Display immediately
233
elif level_sec == softwareproperties.UPDATE_DOWNLOAD:
234
self.combobox_security_updates.set_active(1) # Download automatically
235
elif level_sec == softwareproperties.UPDATE_INST_SEC:
236
self.combobox_security_updates.set_active(2) # Download and install automatically
238
""" Other Updates """
239
level_other = self.settings.get_int("regular-auto-launch-interval")
241
self.combobox_other_updates.set_active(0) # Display immediately
242
elif level_other == 7:
243
self.combobox_other_updates.set_active(1) # Display weekly
244
elif level_other == 14:
245
self.combobox_other_updates.set_active(2) # Display every two weeks
263
247
def init_distro(self):
264
248
"""Setup the user interface elements to represent the distro"""
266
250
# TRANS: %s stands for the distribution name e.g. Debian or Ubuntu
267
self.label_updates.set_label("<b>%s</b>" % (_("%s updates") %\
268
self.distro.id.encode('UTF-8')))
269
# TRANS: %s stands for the distribution name e.g. Debian or Ubuntu
270
self.label_dist_name.set_label(_("%s Software") % self.distro.id.encode('UTF-8'))
251
self.label_dist_name.set_label(_("%s Software") % self.distro.id)
273
253
self.handlers.append((self.checkbutton_source_code,
274
254
self.checkbutton_source_code.connect("toggled",
425
405
for source in self.sourceslist_visible:
426
406
self.print_source_entry(source)
428
def set_update_automation_level(self, widget, state):
429
'''Call the backend to set the update automation level to the given
431
if widget.get_active() == True:
432
self.vbox_auto_updates.foreach(lambda b, d: b.set_inconsistent(False), None)
433
SoftwareProperties.set_update_automation_level(self, state)
434
self.set_modified_config()
408
def set_sec_update_automation_level(self, widget):
409
"""Call the backend to set the security update automation level to the given
411
index = widget.get_active()
413
if index == 0: # Display immediately
414
state = softwareproperties.UPDATE_NOTIFY
415
elif index == 1: # Download automatically
416
state = softwareproperties.UPDATE_DOWNLOAD
417
elif index == 2: # Download and install automatically
418
state = softwareproperties.UPDATE_INST_SEC
419
SoftwareProperties.set_update_automation_level(self, state)
421
def set_other_update_automation_level(self, widget):
422
"""Set the other update automation level to the given value via gconf"""
423
index = widget.get_active()
425
if index == 0: # Display immediately
427
elif index == 1: # Display weekly
429
elif index == 2: # Display every two weeks
431
self.settings.set_int("regular-auto-launch-interval", days)
436
434
def is_row_separator(self, model, iter, column=0):
437
435
''' Check if a given row is a separator '''