home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / python2.4 / site-packages / SoftwareProperties / dialog_add.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-08-31  |  1.9 KB  |  52 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. import os
  5. import gobject
  6. import gtk
  7. import gtk.glade as gtk
  8. from gettext import gettext as _
  9. import UpdateManager.Common.aptsources as aptsources
  10.  
  11. class dialog_add:
  12.     
  13.     def __init__(self, parent, sourceslist, datadir):
  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/SoftwarePropertiesDialogs.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.  
  28.     
  29.     def run(self):
  30.         res = self.dialog.run()
  31.         self.dialog.hide()
  32.         if res == gtk.RESPONSE_OK:
  33.             line = self.entry.get_text() + '\n'
  34.         else:
  35.             line = None
  36.         return line
  37.  
  38.     
  39.     def check_line(self, *args):
  40.         """
  41.     Check for a valid apt line and set the sensitiveness of the
  42.     button 'add' accordingly
  43.     """
  44.         line = self.entry.get_text() + '\n'
  45.         source_entry = aptsources.SourceEntry(line)
  46.         if source_entry.invalid == True or source_entry.disabled == True:
  47.             self.button_add.set_sensitive(False)
  48.         else:
  49.             self.button_add.set_sensitive(True)
  50.  
  51.  
  52.