~ubuntu-branches/ubuntu/oneiric/software-properties/oneiric-security

« back to all changes in this revision

Viewing changes to softwareproperties/gtk/SoftwarePropertiesGtk.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt, Mohamed Amine IL Idrissi, Michael Vogt
  • Date: 2011-07-22 19:11:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110722191126-xoi15h2c116uzlgu
Tags: 0.81
[ Mohamed Amine IL Idrissi ]
* Redesigned the Updates tab according to
  https://wiki.ubuntu.com/SoftwareUpdateHandling#settings (LP:
  #351484, #357676, #253412)

[ Michael Vogt ]
* add dbus/polkit backend, based on 
  lp:~kubuntu-packagers/software-properties/dbusworker
* use new dbus backend
* automatically run tests at bzr-buildpackage time

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
import apt
26
26
import apt_pkg
 
27
import dbus
27
28
import tempfile
28
29
from gettext import gettext as _
29
30
import os
30
 
import re
31
 
from xml.sax.saxutils import escape
32
31
 
33
32
from gi.repository import Gdk
34
33
from gi.repository import Gtk
 
34
from gi.repository import Gio
35
35
import gobject
36
36
 
37
37
from SimpleGtkbuilderApp import SimpleGtkbuilderApp
68
68
) = range(5)
69
69
 
70
70
def error(parent_window, summary, msg):
71
 
  " show a error dialog "
72
 
  dialog = Gtk.MessageDialog(parent=parent_window,
73
 
                             flags=Gtk.DialogFlags.MODAL,
74
 
                             type=Gtk.MessageType.ERROR,
75
 
                             buttons=Gtk.ButtonsType.OK,
76
 
                             message_format=None)
77
 
  dialog.set_markup("<big><b>%s</b></big>\n\n%s" % (summary, msg))
78
 
  res = dialog.run()
79
 
  dialog.destroy()
80
 
  return False
 
71
    """ show a error dialog """
 
72
    dialog = Gtk.MessageDialog(parent=parent_window,
 
73
                               flags=Gtk.DialogFlags.MODAL,
 
74
                               type=Gtk.MessageType.ERROR,
 
75
                               buttons=Gtk.ButtonsType.OK,
 
76
                               message_format=None)
 
77
    dialog.set_markup("<big><b>%s</b></big>\n\n%s" % (summary, msg))
 
78
    res = dialog.run()
 
79
    dialog.destroy()
 
80
    return False
81
81
 
82
82
class SoftwarePropertiesGtk(SoftwareProperties,SimpleGtkbuilderApp):
 
83
 
83
84
  def __init__(self, datadir=None, options=None, file=None, parent=None):
84
85
    """ Provide a GTK based graphical user interface to configure
85
86
        the used software repositories, corresponding authentication keys
87
88
    SoftwareProperties.__init__(self, options=options, datadir=datadir)
88
89
    Gtk.Window.set_default_icon_name("software-properties")
89
90
 
90
 
    SimpleGtkbuilderApp.__init__(self, os.path.join(datadir, "gtkbuilder", "main.ui"),
91
 
                            domain="software-properties")
 
91
    SimpleGtkbuilderApp.__init__(self,
 
92
                                 os.path.join(datadir, "gtkbuilder", "main.ui"),
 
93
                                 domain="software-properties")
92
94
 
93
95
    if parent:
94
96
      self.window_main.set_type_hint(Gdk.WindowTypeHint.DIALOG)
115
117
    if options and options.open_tab:
116
118
      self.notebook_main.set_current_page(int(options.open_tab))
117
119
 
 
120
    # gsettings
 
121
    self.settings = Gio.Settings("com.ubuntu.update-notifier")
 
122
    # we need this for reverting
 
123
    self.initial_auto_launch = self.settings.get_int("regular-auto-launch-interval") 
 
124
 
 
125
    # get the dbus backend
 
126
    bus = dbus.SystemBus()
 
127
    proxy = bus.get_object("com.ubuntu.SoftwareProperties", "/")
 
128
    self.backend = dbus.Interface(proxy, "com.ubuntu.SoftwareProperties")
 
129
    self.backend.connect_to_signal(
 
130
        "SourcesListModified", self.on_sources_list_modified)
 
131
    self.backend.connect_to_signal(
 
132
        "ConfigModified", self.on_config_modified)
 
133
    self.backend.connect_to_signal(
 
134
        "KeysModified", self.on_keys_modified)
 
135
    self.backend.connect_to_signal(
 
136
        "AuthFailed", self.on_auth_failed)
 
137
    
118
138
    # Show what we have early
119
139
    self.window_main.show()
120
140
 
144
164
    #       We have got some bug reports from users calling
145
165
    #       "sudo software-properties-gtk /etc/apt/sources.list" from the
146
166
    #       command line.
147
 
    if file != None and \
 
167
    if (file != None and
148
168
       os.path.abspath(file) !=  "%s%s" % (apt_pkg.config.find_dir("Dir::Etc"),
149
 
                                           apt_pkg.config.find("Dir::Etc::sourcelist")):
 
169
                                           apt_pkg.config.find("Dir::Etc::sourcelist"))):
150
170
        self.open_file(file)
151
171
 
152
172
  def update_interface(self):
153
 
    " abstract interface to keep the UI alive "
 
173
    """ abstract interface to keep the UI alive """
154
174
    while Gtk.events_pending():
155
175
      Gtk.main_iteration()
156
176
 
159
179
        corresponding to the used distro """
160
180
    is_helpful = self.get_popcon_participation()
161
181
    if is_helpful != None:
162
 
      self.label_popcon_desc.set_label(softwareproperties.distro.get_popcon_description(self.distro))
 
182
      self.label_popcon_desc.set_label(
 
183
          softwareproperties.distro.get_popcon_description(self.distro))
163
184
      self.vbox_popcon.show()
164
185
      self.checkbutton_popcon.set_active(is_helpful)
165
186
 
167
188
    " setup the widgets that allow configuring the release upgrades "
168
189
    i = self.get_release_upgrades_policy()
169
190
    self.combobox_release_upgrades.set_active(i)
170
 
    self.combobox_release_upgrades.connect('changed', self.on_combobox_release_upgrades_changed)
 
191
    self.combobox_release_upgrades.connect(
 
192
        'changed', self.on_combobox_release_upgrades_changed)
171
193
 
172
194
  def init_auto_update(self):
173
195
    """ 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
196
    self.combobox_update_interval.show()
177
 
    
 
197
 
 
198
    # normal updates
178
199
    # 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,
181
 
                                       1 : 2,
182
 
                                       2 : 7,
183
 
                                       3 : 14 }
184
 
    self.combobox_update_interval.set_active(0)
185
 
 
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"))
191
 
 
192
 
    model_check_interval = Gtk.ListStore(gobject.TYPE_STRING,
193
 
                                         gobject.TYPE_INT)
 
200
    # we build it dynamically from the model
 
201
    model = self.combobox_update_interval.get_model()
 
202
    self.combobox_interval_mapping = {}
 
203
    for (i, row) in enumerate(model):
 
204
      # column 1 is the update interval in days
 
205
      value = model.get_value(row.iter, 1)
 
206
      self.combobox_interval_mapping[i] = value
 
207
 
 
208
    # normal updates
194
209
    update_days = self.get_update_interval()
195
210
 
196
211
    # If a custom period is defined add a corresponding entry
198
213
        if update_days > 0:
199
214
            self.combobox_update_interval.append_text(_("Every %s days") 
200
215
                                                      % update_days)
201
 
            self.combobox_interval_mapping[4] = update_days
 
216
            self.combobox_interval_mapping[-1] = update_days
202
217
    
203
218
    for key in self.combobox_interval_mapping:
204
219
      if self.combobox_interval_mapping[key] == update_days:
205
220
        self.combobox_update_interval.set_active(key)
206
221
        break
207
222
 
208
 
    if update_days >= 1:
209
 
      self.checkbutton_auto_update.set_active(True)
210
 
      self.combobox_update_interval.set_sensitive(True)
211
 
      self.vbox_auto_updates.set_sensitive(True)
212
 
    else:
213
 
      self.checkbutton_auto_update.set_active(False)
214
 
      self.combobox_update_interval.set_sensitive(False)
215
 
      self.vbox_auto_updates.set_sensitive(False)
216
 
 
217
 
    self.handlers.append(
218
 
        (self.checkbutton_auto_update,
219
 
         self.checkbutton_auto_update.connect("toggled", 
220
 
                                     self.on_auto_update_toggled)))
221
223
    self.handlers.append(
222
224
        (self.combobox_update_interval,
223
225
         self.combobox_update_interval.connect("changed", 
224
226
                                     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)))
240
 
 
 
227
    
 
228
    self.handlers.append(
 
229
        (self.combobox_security_updates,
 
230
         self.combobox_security_updates.connect("changed",
 
231
                                     self.set_sec_update_automation_level)))
 
232
    
 
233
    self.handlers.append(
 
234
        (self.combobox_security_updates,
 
235
         self.combobox_other_updates.connect("changed",
 
236
                                     self.set_other_update_automation_level)))
 
237
  
241
238
  def show_auto_update_level(self):
242
239
    """Represent the level of update automation in the user interface"""
243
 
    level = self.get_update_automation_level()
244
 
    self.block_handlers()
245
 
    if level == None:
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)
 
240
 
 
241
    # Security Updates
 
242
    level_sec = self.get_update_automation_level()
 
243
    if level_sec == None:
 
244
      self.combobox_security_updates.set_sensitive(False)
249
245
    else:
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()
 
246
      self.combobox_security_updates.set_sensitive(True)
 
247
          
 
248
    if (level_sec == softwareproperties.UPDATE_MANUAL or
 
249
        level_sec == softwareproperties.UPDATE_NOTIFY):
 
250
      self.combobox_security_updates.set_active(0) # Display immediately
 
251
    elif level_sec == softwareproperties.UPDATE_DOWNLOAD:
 
252
      self.combobox_security_updates.set_active(1) # Download automatically
 
253
    elif level_sec == softwareproperties.UPDATE_INST_SEC:
 
254
      self.combobox_security_updates.set_active(2) # Download and install automatically
 
255
    
 
256
    # Other Updates
 
257
    level_other = self.settings.get_int("regular-auto-launch-interval")
 
258
    model = self.combobox_other_updates.get_model()
 
259
    for (i, row) in enumerate(model):
 
260
        level = model.get_value(row.iter, 1)
 
261
        if level_other == level:
 
262
            self.combobox_other_updates.set_active(i)
 
263
            break
262
264
 
263
265
  def init_distro(self):
264
266
    """Setup the user interface elements to represent the distro"""
265
267
 
266
268
    # 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'))
271
 
 
 
269
    self.label_dist_name.set_label(_("%s Software") % self.distro.id)
272
270
 
273
271
    self.handlers.append((self.checkbutton_source_code,
274
272
                          self.checkbutton_source_code.connect("toggled",
338
336
  def show_distro(self):
339
337
    """Fill the distro user interface with life"""
340
338
    self.block_handlers()
 
339
 
341
340
    # Enable or disable the child source checkbuttons
342
341
    for checkbox in self.vbox_updates.get_children():
343
342
        (active, inconsistent) = self.get_comp_child_state(checkbox.template)
425
424
        for source in self.sourceslist_visible:
426
425
            self.print_source_entry(source)
427
426
 
428
 
  def set_update_automation_level(self, widget, state):
429
 
    '''Call the backend to set the update automation level to the given 
430
 
       value'''
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()
 
427
  def set_sec_update_automation_level(self, widget):
 
428
    """Call the backend to set the security update automation level to the given
 
429
       value"""
 
430
    index = widget.get_active()
 
431
    state = -1
 
432
    if index == 0: # Display immediately
 
433
      state = softwareproperties.UPDATE_NOTIFY
 
434
    elif index == 1: # Download automatically
 
435
      state = softwareproperties.UPDATE_DOWNLOAD
 
436
    elif index == 2: # Download and install automatically
 
437
      state = softwareproperties.UPDATE_INST_SEC
 
438
    # only set if something actually changed
 
439
    if state != self.get_update_automation_level():
 
440
        self.backend.SetUpdateAutomationLevel(state)
 
441
    
 
442
  def set_other_update_automation_level(self, widget):
 
443
    """Set the other update automation level to the given value via gconf"""
 
444
    index = widget.get_active()
 
445
    model = self.combobox_other_updates.get_model()
 
446
    # the second column is the update interval days
 
447
    days = model[index][1]
 
448
    self.settings.set_int("regular-auto-launch-interval", days)
435
449
 
436
450
  def is_row_separator(self, model, iter, column=0):
437
451
    ''' Check if a given row is a separator '''
441
455
    """ set the release upgrades policy """
442
456
    #print "on_combobox_release_upgrades_changed()"
443
457
    i = combobox.get_active()
444
 
    self.set_release_upgrades_policy(i)
 
458
    self.backend.SetReleaseUpgradesPolicy(i)
445
459
 
446
460
  def on_combobox_server_changed(self, combobox):
447
461
    """
461
475
                              self.custom_mirrors)
462
476
        res = dialog.run()
463
477
        if res != None:
464
 
            self.distro.change_server(res)
465
 
            self.set_modified_sourceslist()
 
478
            self.backend.ChangeMainDownloadServer(res)
466
479
        else:
467
480
            combobox.set_active(self.active_server)
468
481
    elif uri != None and len(self.distro.used_servers) > 0:
469
482
        self.active_server = combobox.get_active()
470
 
        self.distro.change_server(uri)
471
 
        self.distro.default_server = uri
472
 
        self.set_modified_sourceslist()
473
 
    else:
474
 
        self.distro.default_server = uri
 
483
        self.backend.ChangeMainDownloadServer(uri)
 
484
    # mvo: is this still needed?
 
485
    #else:
 
486
    #    self.distro.default_server = uri
475
487
 
476
488
  def on_component_toggled(self, checkbutton, comp):
477
489
    """
479
491
    child sources and source code sources
480
492
    """
481
493
    if checkbutton.get_active() == True:
482
 
        self.enable_component(comp)
 
494
        self.backend.EnableComponent(comp)
483
495
    else:
484
 
        self.disable_component(comp)
485
 
    self.set_modified_sourceslist()
 
496
        self.backend.DisableComponent(comp)
486
497
 
487
498
  def on_checkbutton_child_toggled(self, checkbutton, template):
488
499
    """
489
500
    Enable or disable a child repo of the distribution main repository
490
501
    """
491
502
    if checkbutton.get_active() == False:
492
 
        self.disable_child_source(template)
 
503
        self.backend.DisableChildSource(template)
493
504
    else:
494
 
        self.enable_child_source(template)
 
505
        self.backend.EnableChildSource(template)
495
506
          
496
507
  def on_checkbutton_source_code_toggled(self, checkbutton):
497
508
    """ Disable or enable the source code for all sources """
498
509
    if checkbutton.get_active() == True:
499
 
        self.enable_source_code_sources()
 
510
        self.backend.EnableSourceCodeSources()
500
511
    else:
501
 
        self.disable_source_code_sources()
 
512
        self.backend.DisableSourceCodeSources()
502
513
 
503
514
  def on_checkbutton_popcon_toggled(self, widget):
504
515
    """ The user clicked on the popcon paritipcation button """
505
 
    self.set_popcon_pariticipation(widget.get_active())
 
516
    # only trigger the backend if something actually changed
 
517
    do_popcon = self.get_popcon_participation()
 
518
    if widget.get_active() != do_popcon:
 
519
        self.backend.SetPopconPariticipation(widget.get_active())
506
520
 
507
521
  def open_file(self, file):
508
522
    """Show a confirmation for adding the channels of the specified file"""
517
531
        self.sourceslist.list = []
518
532
    if res in (RESPONSE_ADD, RESPONSE_REPLACE):
519
533
        for source in new_sources:
520
 
            self.sourceslist.add(source.type,
521
 
                                 source.uri,
522
 
                                 source.dist,
523
 
                                 source.comps,
524
 
                                 source.comment)
525
 
        self.set_modified_sourceslist()
 
534
            self.backend.AddSourceFromLine(str(source))
526
535
 
527
536
  def on_sources_drag_data_received(self, widget, context, x, y,
528
537
                                     selection, target_type, timestamp):
629
638
    #FIXME cdroms need to disable the comps in the childs and sources
630
639
    iter = store.get_iter((int(path),))
631
640
    source_entry = store.get_value(iter, STORE_SOURCE) 
632
 
    self.toggle_source_use(source_entry)
 
641
    self.backend.ToggleSourceUse(str(source_entry))
633
642
 
634
643
  def init_keys(self):
635
644
    """Setup the user interface parts needed for the key handling"""
682
691
                "or it might be corrupt."))
683
692
      self.show_keys()
684
693
 
685
 
  #FIXME revert automation settings too
686
694
  def on_button_revert_clicked(self, button):
687
 
    """Restore the source list from the startup of the dialog"""
688
 
    SoftwareProperties.revert(self)
689
 
    self.set_modified_sourceslist()
690
 
    self.show_auto_update_level()
691
 
    self.button_revert.set_sensitive(False)
692
 
    self.modified_sourceslist = False
 
695
      """Restore the source list from the startup of the dialog"""
 
696
      self.backend.Revert()
 
697
      self.settings.set_int("regular-auto-launch-interval", self.initial_auto_launch)
 
698
      self.show_auto_update_level()
 
699
      self.button_revert.set_sensitive(False)
 
700
      self.modified_sourceslist = False
693
701
 
694
 
  def set_modified_config(self):
 
702
  # dbus events
 
703
  def on_config_modified(self):
695
704
    """The config was changed and now needs to be saved and reloaded"""
696
 
    SoftwareProperties.set_modified_config(self)
 
705
    apt.apt_pkg.init_config()
697
706
    self.button_revert.set_sensitive(True)
698
707
 
699
 
  def set_modified_sourceslist(self):
 
708
  def on_keys_modified(self):
 
709
    """ The apt keys have changed and need to be redisplayed """
 
710
    self.show_keys()
 
711
 
 
712
  def on_sources_list_modified(self):
700
713
    """The sources list was changed and now needs to be saved and reloaded"""
701
 
    SoftwareProperties.set_modified_sourceslist(self)
 
714
    self.reload_sourceslist()
702
715
    self.show_distro()
703
716
    self.show_isv_sources()
704
717
    self.show_cdrom_sources()
705
718
    self.button_revert.set_sensitive(True)
706
719
 
 
720
  def on_auth_failed(self):
 
721
    """ send when the authentication failed """
 
722
    # reread the current config
 
723
    self.on_sources_list_modified()
 
724
    self.on_config_modified()
 
725
    self.on_keys_modified()
 
726
 
 
727
  # helpers
707
728
  def show_isv_sources(self):
708
729
    """ Show the repositories of independent software vendors in the
709
730
        third-party software tree view """
748
769
        value = self.combobox_interval_mapping[i]
749
770
        self.set_update_interval(value)
750
771
 
751
 
  def on_auto_update_toggled(self, widget):
752
 
    """Enable or disable automatic updates and modify the user interface
753
 
       accordingly"""
754
 
    if self.checkbutton_auto_update.get_active():
755
 
      self.combobox_update_interval.set_sensitive(True)
756
 
      self.vbox_auto_updates.set_sensitive(True)
757
 
      # if no frequency was specified use daily
758
 
      i = self.combobox_update_interval.get_active()
759
 
      if i == -1:
760
 
          i = 0
761
 
          self.combobox_update_interval.set_active(i)
762
 
      value = self.combobox_interval_mapping[i]
763
 
      # A little hack to re-set the former selected update automation level
764
 
      self.vbox_auto_updates.foreach(lambda b, d: b.toggled(), None)
765
 
    else:
766
 
      self.combobox_update_interval.set_sensitive(False)
767
 
      self.vbox_auto_updates.set_sensitive(False)
768
 
      SoftwareProperties.set_update_automation_level(self, None)
769
 
      value = 0
770
 
    self.set_update_interval(str(value))
771
 
 
772
772
  def on_add_clicked(self, widget):
773
773
    """Show a dialog that allows to enter the apt line of a to be used repo"""
774
774
    dialog = DialogAdd(self.window_main, self.sourceslist,
775
775
                       self.datadir, self.distro)
776
776
    line = dialog.run()
777
777
    if line != None:
778
 
      self.add_source_from_line(line)
779
 
      self.set_modified_sourceslist()
 
778
      self.backend.AddSourceFromLine(line)
780
779
 
781
780
  def on_edit_clicked(self, widget):
782
781
    """Show a dialog to edit an ISV source"""
784
783
    (model, iter) = sel.get_selected()
785
784
    if not iter:
786
785
      return
787
 
    source_entry = model.get_value(iter, LIST_ENTRY_OBJ)
 
786
    old_source_entry = model.get_value(iter, LIST_ENTRY_OBJ)
788
787
    dialog = DialogEdit(self.window_main, self.sourceslist,
789
 
                        source_entry, self.datadir)
 
788
                        old_source_entry, self.datadir)
790
789
    if dialog.run() == Gtk.ResponseType.OK:
791
 
        self.set_modified_sourceslist()
 
790
        self.backend.ReplaceSourceEntry(str(old_source_entry), 
 
791
                                        str(dialog.new_source_entry))
792
792
 
793
793
  # FIXME:outstanding from merge
794
794
  def on_isv_source_activated(self, treeview, path, column):
823
823
    (path, column) = self.treeview_sources.get_cursor()
824
824
    iter = model.get_iter(path)
825
825
    if iter:
826
 
      self.remove_source(model.get_value(iter, LIST_ENTRY_OBJ))
827
 
      self.set_modified_sourceslist()
 
826
        source_entry = model.get_value(iter, LIST_ENTRY_OBJ)
 
827
        self.backend.RemoveSource(str(source_entry))
828
828
 
829
829
  def add_key_clicked(self, widget):
830
830
    """Provide a file chooser that allows to add the gnupg of a trusted
840
840
    res = chooser.run()
841
841
    chooser.hide()
842
842
    if res == Gtk.ResponseType.ACCEPT:
843
 
      if not self.add_key(chooser.get_filename()):
 
843
      if not self.backend.AddKey(chooser.get_filename()):
844
844
        error(self.window_main,
845
845
              _("Error importing selected file"),
846
846
              _("The selected file may not be a GPG key file " \
847
847
                "or it might be corrupt."))
848
 
      self.show_keys()
849
848
 
850
849
  def remove_key_clicked(self, widget):
851
850
    """Remove a trusted software vendor key"""
854
853
    if a_iter == None:
855
854
        return
856
855
    key = model.get_value(a_iter,0)
857
 
    if not self.remove_key(key[:8]):
 
856
    if not self.backend.RemoveKey(key[:8]):
858
857
      error(self.main,
859
858
        _("Error removing the key"),
860
859
        _("The key you selected could not be removed. "
861
860
          "Please report this as a bug."))
862
 
    self.show_keys()
863
861
 
864
862
  def on_restore_clicked(self, widget):
865
863
    """Restore the original keys"""
866
 
    self.apt_key.update()
867
 
    self.show_keys()
 
864
    self.backend.UpdateKeys()
868
865
 
869
866
  def on_delete_event(self, widget, args):
870
867
    """Close the window if requested"""
880
877
        res = d.run()
881
878
    self.quit()
882
879
 
 
880
  # FIXME: add to the new dbus backend
883
881
  def on_button_add_cdrom_clicked(self, widget):
884
882
    '''Show a dialog that allows to add a repository located on a CDROM
885
883
       or DVD'''