home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / softwareproperties / gtk / DialogAdd.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  2.6 KB  |  59 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import os
  5. import gobject
  6. import gtk
  7. import gtk.glade as gtk
  8. from gettext import gettext as _
  9. from aptsources.sourceslist import SourceEntry
  10.  
  11. class DialogAdd:
  12.     
  13.     def __init__(self, parent, sourceslist, datadir, distro):
  14.         '''
  15.     Initialize the dialog that allows to add a new source entering the
  16.     raw apt line
  17.     '''
  18.         self.sourceslist = sourceslist
  19.         self.parent = parent
  20.         self.datadir = datadir
  21.         self.gladexml = gtk.glade.XML('%s/glade/dialogs.glade' % datadir)
  22.         self.dialog = self.gladexml.get_widget('dialog_add_custom')
  23.         self.dialog.set_transient_for(self.parent)
  24.         self.entry = self.gladexml.get_widget('entry_source_line')
  25.         self.button_add = self.gladexml.get_widget('button_add_source')
  26.         self.entry.connect('changed', self.check_line)
  27.         self.label_example_line = self.gladexml.get_widget('label_example_line')
  28.         if distro:
  29.             example = '%s %s %s %s' % (distro.binary_type, distro.source_template.base_uri, distro.codename, distro.source_template.components[0].name)
  30.         else:
  31.             example = 'deb http://ftp.debian.org sarge main'
  32.         msg = _("The APT line includes the type, location and components of a repository, for example  '%s'.") % '<i>%s</i>' % example
  33.         self.label_example_line.set_label(msg)
  34.  
  35.     
  36.     def run(self):
  37.         res = self.dialog.run()
  38.         self.dialog.hide()
  39.         if res == gtk.RESPONSE_OK:
  40.             line = self.entry.get_text() + '\n'
  41.         else:
  42.             line = None
  43.         return line
  44.  
  45.     
  46.     def check_line(self, *args):
  47.         """
  48.     Check for a valid apt line and set the sensitiveness of the
  49.     button 'add' accordingly
  50.     """
  51.         line = self.entry.get_text() + '\n'
  52.         source_entry = SourceEntry(line)
  53.         if source_entry.invalid == True or source_entry.disabled == True:
  54.             self.button_add.set_sensitive(False)
  55.         else:
  56.             self.button_add.set_sensitive(True)
  57.  
  58.  
  59.