home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / system-config-printer / gui.py < prev    next >
Encoding:
Python Source  |  2010-09-28  |  2.0 KB  |  57 lines

  1. #!/usr/bin/env python
  2.  
  3. ## system-config-printer
  4.  
  5. ## Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
  6. ## Copyright (C) 2006, 2007 Florian Festi <ffesti@redhat.com>
  7. ## Copyright (C) 2006, 2007, 2008, 2009 Tim Waugh <twaugh@redhat.com>
  8.  
  9. ## This program is free software; you can redistribute it and/or modify
  10. ## it under the terms of the GNU General Public License as published by
  11. ## the Free Software Foundation; either version 2 of the License, or
  12. ## (at your option) any later version.
  13.  
  14. ## This program is distributed in the hope that it will be useful,
  15. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ## GNU General Public License for more details.
  18.  
  19. ## You should have received a copy of the GNU General Public License
  20. ## along with this program; if not, write to the Free Software
  21. ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. import gtk
  24. import os
  25.  
  26. import config
  27. pkgdata = config.pkgdatadir
  28.  
  29. class GtkGUI:
  30.     def getWidgets(self, widgets, domain=None):
  31.         ui_dir = os.environ.get ("SYSTEM_CONFIG_PRINTER_UI",
  32.                                  os.path.join (pkgdata, "ui"))
  33.         for xmlfile, names in widgets.iteritems ():
  34.             bld = gtk.Builder ()
  35.  
  36.             if domain:
  37.                 bld.set_translation_domain (domain)
  38.  
  39.             bld.add_from_file (os.path.join (ui_dir, xmlfile + ".glade"))
  40.             for name in names:
  41.                 widget = bld.get_object(name)
  42.                 if widget is None:
  43.                     raise ValueError, "Widget '%s' not found" % name
  44.                 setattr(self, name, widget)
  45.  
  46.             try:
  47.                 win = widget.get_top_level()
  48.             except AttributeError:
  49.                 win = None
  50.             
  51.             if win != None:
  52.                 gtk.Window.set_focus_on_map(widget.get_top_level (),
  53.                                             self.focus_on_map)
  54.                 widget.show()
  55.  
  56.             bld.connect_signals (self)
  57.