~ubuntu-branches/ubuntu/maverick/software-properties/maverick

« back to all changes in this revision

Viewing changes to softwareproperties/kde/SoftwarePropertiesKDE.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-07-14 16:54:38 UTC
  • Revision ID: james.westby@ubuntu.com-20090714165438-s1uk4qcm4hcu0clr
Tags: 0.75
* new helper script "add-apt-repository" that can be used to
  enable a repository from the commandline. Useful for e.g.
  'add-apt-repository ppa:gnome-desktop'
* fix error in auto-upgrade settings when 
  dpkg-reconfigure unattended-upgrades was used (LP: #387704)
* po/zh_TW.po:
  - updated, thanks to Roy Chan (LP: #365040)
* softwareproperties/kde/SoftwarePropertiesKDE.py:
  - do not error on cancel (LP: #364288)
  - use the SUDO_USER home instead of /root (if available) 
    (LP: #364197)
  - add utf8() function and replace the custom converts to it
    (hopefully fixes LP: #362188)
  - disable "Find best server" for now, the threading crashing
    KDE
* softwareproperties/gtk/DialogCacheOutdated.py:
  - fix incorrect wait on synaptic (LP: #357617, LP: #349639)
* softwareproperties/SoftwareProperties.py:
  - check/ensure apt daily cron job is executable (LP: #390319)

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
from DialogMirror import DialogMirror
51
51
from CdromProgress import CdromProgress
52
52
 
 
53
def utf8(str):
 
54
  " helper that takes a string and converts it to utf8 unicode "
 
55
  if isinstance(str, unicode):
 
56
      return str
 
57
  return unicode(str, 'UTF-8')
 
58
 
53
59
class SoftwarePropertiesKDEUI(QWidget):
54
60
 
55
61
    def __init__(self, datadir):
140
146
      if isinstance(widget, QLabel):
141
147
          text = str(widget.text())
142
148
          text = _(text)
143
 
          ##FIXME string is a str but in unicode.  PyQt thinks it isn't unicode and any non-ascii characters break, how to fix??
144
 
          text = unicode(text, 'utf-8')
 
149
          text = utf8(text)
145
150
          widget.setText(text)
146
151
      elif isinstance(widget, QPushButton):
147
152
          text = str(widget.text())
148
153
          text = _(text)
149
 
          text = unicode(text, 'utf-8')
 
154
          text = utf8(text)
150
155
          widget.setText(text)
151
156
      elif isinstance(widget, QGroupBox):
152
157
          text = str(widget.title())
153
158
          text = _(text)
154
 
          text = unicode(text, 'utf-8')
 
159
          text = utf8(text)
155
160
          widget.setTitle(text)
156
161
      elif isinstance(widget, QCheckBox):
157
162
          text = str(widget.text())
158
163
          text = _(text)
159
 
          text = unicode(text, 'utf-8')
 
164
          text = utf8(text)
160
165
          widget.setText(text)
161
166
 
162
167
  def init_popcon(self):
166
171
    if is_helpful != None:
167
172
      text = softwareproperties.distro.get_popcon_description(self.distro)
168
173
      text = text.replace("\n", "<br />") #silly GTK mixes HTML and normal white space
169
 
      self.userinterface.label_popcon_desc.setText(unicode(text, 'UTF-8'))
 
174
      self.userinterface.label_popcon_desc.setText(utf8(text))
170
175
      self.userinterface.checkbutton_popcon.setChecked(is_helpful)
171
176
    else:
172
177
      self.userinterface.tabWidget.removeTab(4)
185
190
                                       2 : 7,
186
191
                                       3 : 14 }
187
192
 
188
 
    self.userinterface.combobox_update_interval.insertItem(99, unicode(_("Daily"), 'utf-8'))
189
 
    self.userinterface.combobox_update_interval.insertItem(99, unicode(_("Every two days"), 'utf-8'))
190
 
    self.userinterface.combobox_update_interval.insertItem(99, unicode(_("Weekly"), 'utf-8'))
191
 
    self.userinterface.combobox_update_interval.insertItem(99, unicode(_("Every two weeks"), 'utf-8'))
 
193
    self.userinterface.combobox_update_interval.insertItem(99, utf8(_("Daily")))
 
194
    self.userinterface.combobox_update_interval.insertItem(99, utf8(_("Every two days")))
 
195
    self.userinterface.combobox_update_interval.insertItem(99, utf8(_("Weekly")))
 
196
    self.userinterface.combobox_update_interval.insertItem(99, utf8(_("Every two weeks")))
192
197
 
193
198
    update_days = self.get_update_interval()
194
199
 
195
200
    # If a custom period is defined add a corresponding entry
196
201
    if not update_days in self.combobox_interval_mapping.values():
197
202
        if update_days > 0:
198
 
            self.userinterface.combobox_update_interval.insertItem(99, unicode(_("Every %s days"), 'utf-8') % update_days)
 
203
            self.userinterface.combobox_update_interval.insertItem(99, utf8(_("Every %s days")) % update_days)
199
204
            self.combobox_interval_mapping[4] = update_days
200
205
 
201
206
    for key in self.combobox_interval_mapping:
239
244
    # TRANS: %s stands for the distribution name e.g. Debian or Ubuntu
240
245
    text = _("%s updates") % self.distro.id
241
246
    text = text.replace("Ubuntu", "Kubuntu")
242
 
    self.userinterface.groupBox_updates.setTitle(unicode(text, 'UTF-8'))
 
247
    self.userinterface.groupBox_updates.setTitle(utf8(text))
243
248
    # TRANS: %s stands for the distribution name e.g. Debian or Ubuntu
244
249
    text = _("%s Software") % self.distro.id
245
 
    text = unicode(text, 'utf-8')
 
250
    text = utf8(text)
246
251
    text = text.replace("Ubuntu", "Kubuntu")
247
252
    self.userinterface.tabWidget.setTabText(0, text)
248
253
 
262
267
        #              first %s is the description of the component
263
268
        #              second %s is the code name of the comp, eg main, universe
264
269
        label = _("%s (%s)") % (comp.get_description(), comp.name)
265
 
        checkbox = QCheckBox(unicode(label, 'utf-8'), self.userinterface.vbox_dist_comps_frame)
 
270
        checkbox = QCheckBox(utf8(label), self.userinterface.vbox_dist_comps_frame)
266
271
        checkbox.setObjectName(comp.name)
267
272
        self.checkboxComps[checkbox] = comp
268
273
 
280
285
        self.userinterface.vbox_updates_frame.hide()
281
286
    self.checkboxTemplates = {}
282
287
    for template in self.distro.source_template.children:
283
 
        checkbox = QCheckBox(unicode(template.description, 'utf-8'), self.userinterface.vbox_updates_frame)
 
288
        checkbox = QCheckBox(utf8(template.description), 
 
289
                             self.userinterface.vbox_updates_frame)
284
290
        checkbox.setObjectName(template.name)
285
291
        self.checkboxTemplates[checkbox] = template
286
292
        # setup the callback and show the checkbutton
299
305
    self.mirror_urls = []
300
306
    for (name, uri, active) in self.distro.get_server_list():
301
307
        ##server_store.append([name, uri, False])
302
 
        self.userinterface.combobox_server.addItem(unicode(name,'utf-8'))
 
308
        self.userinterface.combobox_server.addItem(utf8(name))
303
309
        self.mirror_urls.append(uri)
304
310
        if [name, uri] in self.seen_server:
305
311
            self.seen_server.remove([name, uri])
309
315
            self.active_server = self.userinterface.combobox_server.count() - 1
310
316
            self.userinterface.combobox_server.setCurrentIndex(self.userinterface.combobox_server.count() - 1)
311
317
    for [name, uri] in self.seen_server:
312
 
        self.userinterface.combobox_server.addItem(unicode(name,'utf-8'))
 
318
        self.userinterface.combobox_server.addItem(utf8(name))
313
319
    self.seen_server = seen_server_new
314
320
    # add a separator and the option to choose another mirror from the list
315
321
    ##FIXME server_store.append(["sep", None, True])
316
 
    self.userinterface.combobox_server.addItem(unicode(_("Other..."), 'utf-8'))
 
322
    self.userinterface.combobox_server.addItem(utf8(_("Other...")))
317
323
    self.mirror_urls.append("")
318
324
 
319
325
    kapp.connect(self.userinterface.combobox_server, SIGNAL("currentIndexChanged(int)"), self.on_combobox_server_changed)
417
423
    if combobox.currentIndex() == self.active_server:
418
424
        return
419
425
    uri = self.mirror_urls[combobox.currentIndex()]
420
 
    name = unicode(combobox.currentText())
421
 
    if name == unicode(_("Other..."), 'utf-8'):
 
426
    name = utf8(combobox.currentText())
 
427
    if name == utf8(_("Other...")):
422
428
        dialogue = DialogMirror(self.userinterface, self.datadir, self.distro, self.custom_mirrors)
423
429
        self.translate_widget_children(dialogue)
424
430
        res = dialogue.run()
564
570
        contents = self.render_source(source)
565
571
        contents = contents.replace("<b>", "")
566
572
        contents = contents.replace("</b>", "")
567
 
        item = QTreeWidgetItem([unicode(contents, 'utf-8')])
 
573
        item = QTreeWidgetItem([utf8(contents)])
568
574
        if not source.disabled:
569
575
            item.setCheckState(0, Qt.Checked)
570
576
        else:
597
603
  def show_keys(self):
598
604
    self.userinterface.treeview2.clear()
599
605
    for key in self.apt_key.list():
600
 
      self.userinterface.treeview2.addTopLevelItem(QTreeWidgetItem([unicode(key, 'UTF-8')]))
 
606
      self.userinterface.treeview2.addTopLevelItem(QTreeWidgetItem([utf8(key)]))
601
607
 
602
608
    if self.userinterface.treeview_sources.topLevelItemCount() < 1:
603
609
      self.userinterface.button_auth_remove.setEnabled(False)
645
651
        example = "deb http://ftp.debian.org sarge main"
646
652
    # L10N: the example is of the format: deb http://ftp.debian.org sarge main
647
653
    text = _('<p><b>Enter the complete APT line of the<br /> repository that you want to add as source</b></p><p>The APT line includes the type, location and components of a repository,<br /> for example <i>"%s"</i>.</p>' % example)
648
 
    (line, valid) = QInputDialog.getText(self.userinterface, unicode(_("Add APT repository"), 'utf-8'), text)
649
 
    uline = unicode(line)
 
654
    (line, valid) = QInputDialog.getText(self.userinterface, utf8(_("Add APT repository")), text)
 
655
    uline = utf8(line)
650
656
    if valid:
651
657
        self.add_source_from_line(uline)
652
658
        self.show_isv_sources()
683
689
    """Provide a file chooser that allows to add the gnupg of a trusted
684
690
       software vendor"""
685
691
    home = QDir.homePath()
 
692
    if "SUDO_USER" in os.environ:
 
693
        home = os.path.expanduser("~%s" % os.environ["SUDO_USER"])
686
694
    url = KUrl.fromPath(home)
687
 
    filename = KFileDialog.getOpenFileName(url, '*.gpg *.gpgkey| PGP keys', self.userinterface, unicode(_("Import key"), 'utf-8'))
688
 
    if filename is not None:
 
695
    filename = KFileDialog.getOpenFileName(url, '*.gpg *.gpgkey| PGP keys', self.userinterface, utf8(_("Import key")))
 
696
    if filename:
689
697
      if not self.add_key(filename):
690
698
        title = _("Error importing selected file")
691
699
        text = _("The selected file may not be a GPG key file " \
692
700
                "or it might be corrupt.")
693
701
        KMessageBox.sorry(self.userinterface,
694
 
              unicode(text, 'utf-8'),
695
 
              unicode(title, 'utf-8'))
 
702
              utf8(text),
 
703
              utf8(title))
696
704
      self.show_keys()
697
705
 
698
706
  def remove_key_clicked(self):
705
713
      title = _("Error removing the key")
706
714
      text = _("The key you selected could not be removed. "
707
715
               "Please report this as a bug.")
708
 
      KMessageBox.sorry(self.userinterface, unicode(text, 'utf-8'), unicode(title, 'utf-8'))
 
716
      KMessageBox.sorry(self.userinterface, utf8(text), utf8(title))
709
717
    self.show_keys()
710
718
 
711
719
  def on_restore_clicked(self):
719
727
    if self.modified_sourceslist == True and self.options.no_update == False:
720
728
        messageBox = QMessageBox(self.userinterface)
721
729
        messageBox.setIcon(QMessageBox.Information)
722
 
        reloadButton = messageBox.addButton(unicode(_("Reload"), 'utf-8'), QMessageBox.AcceptRole)
 
730
        reloadButton = messageBox.addButton(utf8(_("Reload")), QMessageBox.AcceptRole)
723
731
        messageBox.addButton(QMessageBox.Close)
724
732
        text = _("<b><big>The information about available software is out-of-date</big></b>\n"
725
733
               "\n"
728
736
               "\n"
729
737
               "You need a working internet connection to continue.")
730
738
        text = text.replace("\n", "<br />")
731
 
        messageBox.setText(unicode(text, 'utf-8'))
 
739
        messageBox.setText(utf8(text))
732
740
        messageBox.exec_()
733
741
        if (messageBox.clickedButton() == reloadButton):
734
742
                cmd = ["/usr/bin/install-package", "--update"]
753
761
      progress.close()
754
762
      title = _("CD Error")
755
763
      text = _("<big><b>Error scanning the CD</b></big>\n\n%s")%msg
756
 
      KMessageBox.sorry(self.userinterface, unicode(text, 'utf-8'), unicode(title, 'utf-8'))
 
764
      KMessageBox.sorry(self.userinterface, utf8(text), utf8(title))
757
765
      return
758
766
    apt_pkg.Config.Set("Dir::Etc::sourcelist",saved_entry)
759
767
    if res == False: