Back to index

system-config-printer  1.3.9+20120706
gui.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 ## system-config-printer
00004 
00005 ## Copyright (C) 2006, 2007, 2008, 2009, 2010 Red Hat, Inc.
00006 ## Authors:
00007 ##  Florian Festi <ffesti@redhat.com>
00008 ##  Tim Waugh <twaugh@redhat.com>
00009 
00010 ## This program is free software; you can redistribute it and/or modify
00011 ## it under the terms of the GNU General Public License as published by
00012 ## the Free Software Foundation; either version 2 of the License, or
00013 ## (at your option) any later version.
00014 
00015 ## This program is distributed in the hope that it will be useful,
00016 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 ## GNU General Public License for more details.
00019 
00020 ## You should have received a copy of the GNU General Public License
00021 ## along with this program; if not, write to the Free Software
00022 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023 
00024 import gobject
00025 import gtk
00026 import os
00027 
00028 import config
00029 pkgdata = config.pkgdatadir
00030 
00031 class GtkGUI(gobject.GObject):
00032     def getWidgets(self, widgets, domain=None):
00033         ui_dir = os.environ.get ("SYSTEM_CONFIG_PRINTER_UI",
00034                                  os.path.join (pkgdata, "ui"))
00035         for xmlfile, names in widgets.iteritems ():
00036             bld = gtk.Builder ()
00037 
00038             if domain:
00039                 bld.set_translation_domain (domain)
00040 
00041             bld.add_from_file (os.path.join (ui_dir, xmlfile + ".ui"))
00042             for name in names:
00043                 widget = bld.get_object(name)
00044                 if widget is None:
00045                     raise ValueError, "Widget '%s' not found" % name
00046                 setattr(self, name, widget)
00047 
00048             try:
00049                 win = widget.get_top_level()
00050             except AttributeError:
00051                 win = None
00052             
00053             if win != None:
00054                 gtk.Window.set_focus_on_map(widget.get_top_level (),
00055                                             self.focus_on_map)
00056                 widget.show()
00057 
00058             bld.connect_signals (self)