def on_menu_preferences_activate(self, *extra): """Sets program properties.""" gladeFile = gnomeglade.uninstalled_file('glade/qa-assistant.glade') if gladeFile == None: filename = os.path.join(PROGRAMNAME, 'glade/qa-assistant.glade') gladeFile = self.locate_file(gnome.FILE_DOMAIN_APP_DATADIR, filename) if gladeFile == []: raise Exception("Unable to locate glade file %s" % (filename)) else: gladeFile = gladeFile[0] prefDialog = Preferences(gladeFile) if self.logo: prefDialog.PreferencesDialog.set_icon(self.logo) prefDialog.PreferencesDialog.show()
def preferences_cb(self, action, extra): '''Sets program properties.''' gladeFile = gnomeglade.uninstalled_file('glade/qa-assistant.glade') if gladeFile == None: filename = os.path.join(PROGRAMNAME, 'glade/qa-assistant.glade') gladeFile = self.program.locate_file(gnome.FILE_DOMAIN_APP_DATADIR, filename, True) if gladeFile == []: ### FIXME: Less generic exception here. raise Exception("Unable to locate glade file %s" % (filename)) else: gladeFile = gladeFile[0] prefDialog = Preferences(gladeFile) if self.logo: prefDialog.PreferencesDialog.set_icon(self.logo) prefDialog.PreferencesDialog.show()
def not_yet_implemented(self, msg = ""): gladeFile = gnomeglade.uninstalled_file('glade/qa-assistant.glade') if gladeFile == None: filename = os.path.join(PROGRAMNAME, 'glade/qa-assistant.glade') gladeFile = self.program.locate_file(gnome.FILE_DOMAIN_APP_DATADIR, filename, True) if gladeFile == []: raise Exception("Unable to locate glade file %s" % (filename)) else: gladeFile = gladeFile[0] NYI = gtk.glade.XML(gladeFile, 'NYIDialog') NYIDialog = NYI.get_widget('NYIDialog') NYIDialog.set_default_response(gtk.RESPONSE_CLOSE) NYIDialog.connect('response', lambda dialog, response: dialog.destroy()) if msg: NYIMsg = NYI.get_widget('NYIMsg') tb = NYIMsg.get_buffer() tb.set_text(msg) NYIDialog.show() del(NYI)
def on_menu_about_activate(self, *extra): """Show the about window.""" gladeFile = gnomeglade.uninstalled_file('glade/qa-assistant.glade') if gladeFile == None: filename = os.path.join(PROGRAMNAME, 'glade/qa-assistant.glade') gladeFile = self.locate_file(gnome.FILE_DOMAIN_APP_DATADIR, filename) if gladeFile == []: raise Exception("Unable to locate glade file %s" % (filename)) else: gladeFile = gladeFile[0] about = gtk.glade.XML(gladeFile, 'AboutWindow').get_widget('AboutWindow') about.set_property('name', HUMANPROGRAMNAME) about.set_property('version', __version__) if self.logo: about.set_property('icon', self.logo) about.set_property('logo', self.logo) about.show() del(about)
def __load_checklist(self, checklist): filename = os.path.join('data', checklist) checkFile = gnomeglade.uninstalled_file(filename) if checkFile == None: filename = os.path.join(PROGRAMNAME, filename) checkFile = self.program.locate_file(gnome.FILE_DOMAIN_APP_DATADIR, filename, True) if checkFile == []: checkFile = None else: checkFile = checkFile[0] if not checkFile: ### FIXME: We can select checklists via property, we need to # print error and recover. sys.stderr.write("Unable to find checklist: %s\n" % (filename)) sys.exit(1) try: self.checklist = checklist.CheckList(checkFile) except (libxml2.parserError, libxml2.treeError, error.InvalidChecklist), msg: ### FIXME: We can select checklists via property, we need to # print error and recover. sys.stderr.write("Unable to parse the checklist: %s\n" % (msg)) sys.exit(1)
def about_cb(self, action, extra): '''Show the about window.''' ### FIXME: Should either put this in a separate glade file or # implement it in code so we don't have to load the whole glade file. gladeFile = gnomeglade.uninstalled_file('glade/qa-assistant.glade') if gladeFile == None: filename = os.path.join(PROGRAMNAME, 'glade/qa-assistant.glade') gladeFile = self.program.locate_file(gnome.FILE_DOMAIN_APP_DATADIR, filename, True) if gladeFile == []: raise Exception("Unable to locate glade file %s" % (filename)) else: gladeFile = gladeFile[0] about = gtk.glade.XML(gladeFile, 'AboutWindow').get_widget('AboutWindow') about.set_property('name', HUMANPROGRAMNAME) about.set_property('version', __version__) if self.logo: about.set_property('icon', self.logo) about.set_property('logo', self.logo) about.show() del(about)
def __init__(self, arguments): """Creates a new QA reviewer window. Keyword -- arguments: arguments: A commandline to process when setting up the environment """ # Load the main part of the interface gladefile = 'glade/qa-assistant.glade' gnomeglade.GnomeApp.__init__(self, PROGRAMNAME, __version__, HUMANPROGRAMNAME, gladefile, 'ReviewerWindow') # # Create additional interface components # # Create a uimanager to handle the menus and toolbars self.uiManager = ui.UI(self) self.mergedMenus = {} accelGroup = self.uiManager.get_accel_group() self.ReviewerWindow.add_accel_group(accelGroup) menubar = self.uiManager.get_widget('/MainMenu') toolbar = self.uiManager.get_widget('/MainToolBar') self.ReviewerWindow.set_menus(menubar) self.ReviewerWindow.set_toolbar(toolbar) iconFile = gnomeglade.uninstalled_file('pixmaps/qa-icon.png') if iconFile == None: iconFile = self.program.locate_file(gnome.FILE_DOMAIN_APP_PIXMAP, 'qa-icon.png', True) if iconFile == []: iconFile = None else: iconFile = iconFile[0] if iconFile: self.logo = gnomeglade.load_pixbuf(iconFile) self.ReviewerWindow.set_property('icon', self.logo) # Create the views onto the checklist self.checkView = CheckView() self.listPane.add(self.checkView) self.reviewView = Review() self.reviewPane.add(self.reviewView) self.grabArrow = gtk.Arrow(gtk.ARROW_LEFT, gtk.SHADOW_NONE) self.grabArrow.set_size_request(4,4) label = self.grabBar.get_child() self.grabBar.remove(label) self.grabBar.add(self.grabArrow) self.grabArrow.show() self.reviewScroll.hide() # Create our Clipboard self.clipboard = gtk.Clipboard(gtk.gdk.display_get_default(), 'CLIPBOARD') self.clipPrimary = gtk.Clipboard(gtk.gdk.display_get_default(), 'PRIMARY') self.lastSaveFileDir = './' ### FIXME: This should be set by the module that consumes it. #self.lastSRPMDir = './' # # Command line initialization # self.checklist = None ### FIXME: Read commandline for things like a checklist file specified. # If there is a checklist on the commandline, send it to the druid to # be loaded. # load that. The # properties tell us if there's any information that must be taken # from the user. Or if it's already been filled out. # # Blast off! # if self.checklist: self.ReviewerWindow.show() else: ### FIXME: While the Druid is onscreen, set everything in the # ReviewerWindow to be insensitive. # If no checklist is loaded, only file::New and file::Load should # work.... (?) startDruid = checkload.NewDruid(self, checkload.START) startDruid.set_icon(self.logo) startDruid.show_all()
def load(self): ''' ''' # Parse the xml into a DOM libxml2.registerErrorHandler(self.__no_display_parse_error, None) ctxt = libxml2.newParserCtxt() saveFile = ctxt.ctxtReadFile(self.filename, None, libxml2.XML_PARSE_DTDVALID) if ctxt.isValid() == False: ### FIXME create something less generic raise Exception('Save file does not validate against the qasave DTD.') root = saveFile.getRootElement() if root.name != 'qasave': ### FIXME create something less generic raise Exception('File is not a valid qa save file.') if root.prop('version') != _qaSaveFileVersion_: ### FIXME create something less generic raise Exception('Save file is of a different version than I understand.') # Load the appropriate base checklist. saveCheck = root.xpathEval2('/qasave/checklist') filename = saveCheck[0].content filename = os.path.join('data', filename) checkFile = gnomeglade.uninstalled_file(filename) if not checkFile: filename = os.path.join(self.app.program.get_property('app-id'), filename) checkFile = self.app.locate_file(gnome.FILE_DOMAIN_APP_DATADIR, filename)[0] if not checkFile: ### FIXME: Throw an exception to get out gracefully sys.exit(1) newList = checklist.CheckList(checkFile, self.properties) # Check that the checklist is the appropriate version if (newList.name != saveCheck[0].prop('name')): ### FIXME: Throw an exception to get out gracefully sys.exit(1) if (newList.revision != saveCheck[0].prop('revision')): ### FIXME: Think about this some more. # I think we just want to pop up a warning dialog and then # continue. # If the new checklist revision has more entries it will still # overlay fine. But the user may need to look back over completed # sections for new entries. # If the new revision has less entries, old modified entries will # go into the Custom Entries area. pass del saveCheck saveProperties = root.xpathEval2('/qasave/properties/property') ### FIXME: I think the future # is to merge both properties and savefile into checklist so # this is going to disappear. for property in saveProperties: # Set properties through the interface. if property.prop('name') == "SRPM": self.properties.load_SRPM(property.content) else: try: self.properties.set(property.prop('name'), property.content) except AttributeError, id: if id == 1: ### FIXME: need to do this: # save property.prop(name) and .content into a hash. # When we are done with the loop, check the hash. # If there are values in it, popup a warning dialog # that the save file had invalid entries that will be # discarded. pass