def load_cbMIs(self): """ See above. This method just parses Default menu and checks boxes for present menu items. """ try: data = MenuData.from_fileobj(open(find_menu("Default.menu"), "r")) except Exception, e: # Shouldn't really happen log.error(traceback.format_exc()) return
def import_scc_tar(self, filename): """ Imports packaged profiles. Checks for shell() actions everywhere and ask user to enter main name, check generated ones and optionaly change them as he wish. """ files = self.builder.get_object("lstImportPackage") try: # Open tar tar = tarfile.open(filename, "r:gz") files.clear() # Grab 1st profile name = tar.extractfile(Export.PN_NAME).read() main_profile = "%s.sccprofile" % name parser = GuiActionParser() o = GObject.GObject() o.obj = Profile(parser).load_fileobj(tar.extractfile(main_profile)) files.append(( 2, name, name, _("(profile)"), o )) for x in tar: name = ".".join(x.name.split(".")[0:-1]) if x.name.endswith(".sccprofile") and x.name != main_profile: o = GObject.GObject() o.obj = Profile(parser).load_fileobj(tar.extractfile(x)) files.append(( True, name, name, _("(profile)"), o )) elif x.name.endswith(".menu"): o = GObject.GObject() o.obj = MenuData.from_fileobj(tar.extractfile(x), parser) files.append(( True, name, name, _("(menu)"), o )) except Exception, e: # Either entire tar or some profile cannot be parsed. # Display error message and let user to quit # Error message reuses same page as above. log.error(e) self.error(str(e)) return
def on_cbMI_toggled(self, widget): """ Called when one of 'Default Menu Items' checkboxes is toggled. This actually does kind of magic: - 1st, default menu file is loaded - 2nd, based on widget name, option from DEFAULT_MENU_OPTIONS is selected - 3rd, if this option is not present in loaded menu and checkbox is toggled on, option is added - (same for option that is present while checkbox was toggled off) - 4rd, default menu is saved """ if self._recursing: return try: data = MenuData.from_fileobj(open(find_menu("Default.menu"), "r"), GuiActionParser()) index = int(widget.get_name().split("_")[-1]) instance = GlobalSettings._make_mi_instance(index) except Exception, e: log.error(traceback.format_exc()) self._recursing = True widget.set_active(not widget.get_active()) self._recursing = False return
def import_scc_tar(self, filename): """ Imports packaged profiles. Checks for shell() actions everywhere and ask user to enter main name, check generated ones and optionaly change them as he wish. """ files = self.builder.get_object("lstImportPackage") try: # Open tar tar = tarfile.open(filename, "r:gz") files.clear() # Grab 1st profile name = tar.extractfile(Export.PN_NAME).read() main_profile = "%s.sccprofile" % name parser = GuiActionParser() o = GObject.GObject() o.obj = Profile(parser).load_fileobj(tar.extractfile(main_profile)) files.append((2, name, name, _("(profile)"), o)) for x in tar: name = ".".join(x.name.split(".")[0:-1]) if x.name.endswith(".sccprofile") and x.name != main_profile: o = GObject.GObject() o.obj = Profile(parser).load_fileobj(tar.extractfile(x)) files.append((True, name, name, _("(profile)"), o)) elif x.name.endswith(".menu"): o = GObject.GObject() o.obj = MenuData.from_fileobj(tar.extractfile(x), parser) files.append((True, name, name, _("(menu)"), o)) except Exception, e: # Either entire tar or some profile cannot be parsed. # Display error message and let user to quit # Error message reuses same page as above. log.error(e) self.error(str(e)) return