def on_btSave_clicked(self, *a): tvItems = self.builder.get_object("tvItems") cbProfile = self.builder.get_object("cbProfile") entTitle = self.builder.get_object("entTitle") entClass = self.builder.get_object("entClass") cbMatchTitle = self.builder.get_object("cbMatchTitle") cbMatchClass = self.builder.get_object("cbMatchClass") cbExactTitle = self.builder.get_object("cbExactTitle") cbRegExp = self.builder.get_object("cbRegExp") rbProfile = self.builder.get_object("rbProfile") rbTurnOff = self.builder.get_object("rbTurnOff") rbRestart = self.builder.get_object("rbRestart") ce = self.builder.get_object("ConditionEditor") # Build condition data = {} if cbMatchTitle.get_active() and entTitle.get_text(): if cbExactTitle.get_active(): data['exact_title'] = entTitle.get_text() elif cbRegExp.get_active(): data['regexp'] = entTitle.get_text() else: data['title'] = entTitle.get_text() if cbMatchClass.get_active() and entClass.get_text(): data['wm_class'] = entClass.get_text() condition = Condition(**data) # Grab selected action model, iter = cbProfile.get_model(), cbProfile.get_active_iter() action = NoAction() if rbProfile.get_active(): action = ChangeProfileAction(model.get_value(iter, 0)) elif rbTurnOff.get_active(): action = TurnOffAction() elif rbRestart.get_active(): action = RestartDaemonAction() # Grab & update current row model, iter = tvItems.get_selection().get_selected() o = model.get_value(iter, 0) o.condition = condition o.action = action model.set_value(iter, 1, condition.describe()) model.set_value(iter, 2, action.describe(Action.AC_SWITCHER)) self.hide_dont_destroy(ce) self.save_config()
def on_btSave_clicked(self, *a): tvItems = self.builder.get_object("tvItems") cbProfile = self.builder.get_object("cbProfile") entTitle = self.builder.get_object("entTitle") entClass = self.builder.get_object("entClass") cbMatchTitle = self.builder.get_object("cbMatchTitle") cbMatchClass = self.builder.get_object("cbMatchClass") cbExactTitle = self.builder.get_object("cbExactTitle") cbRegExp = self.builder.get_object("cbRegExp") ce = self.builder.get_object("ConditionEditor") # Build condition data = {} if cbMatchTitle.get_active() and entTitle.get_text(): if cbExactTitle.get_active(): data['exact_title'] = entTitle.get_text() elif cbRegExp.get_active(): data['regexp'] = entTitle.get_text() else: data['title'] = entTitle.get_text() if cbMatchClass.get_active() and entClass.get_text(): data['wm_class'] = entClass.get_text() condition = Condition(**data) # Grab selected profile model, iter = cbProfile.get_model(), cbProfile.get_active_iter() profile = model.get_value(iter, 0) # Grab & update current row model, iter = tvItems.get_selection().get_selected() o = model.get_value(iter, 0) o.condition = condition model.set_value(iter, 1, condition.describe()) model.set_value(iter, 2, profile) self.hide_dont_destroy(ce) self.save_config()
def on_btSave_clicked(self, *a): tvItems = self.builder.get_object("tvItems") cbProfile = self.builder.get_object("cbProfile") entTitle = self.builder.get_object("entTitle") entClass = self.builder.get_object("entClass") cbMatchTitle = self.builder.get_object("cbMatchTitle") cbMatchClass = self.builder.get_object("cbMatchClass") cbExactTitle = self.builder.get_object("cbExactTitle") cbRegExp = self.builder.get_object("cbRegExp") ce = self.builder.get_object("ConditionEditor") # Build condition data = {} if cbMatchTitle.get_active() and entTitle.get_text(): if cbExactTitle.get_active(): data['exact_title'] = entTitle.get_text() elif cbRegExp.get_active(): data['regexp'] = entTitle.get_text() else: data['title'] = entTitle.get_text() if cbMatchClass.get_active() and entClass.get_text(): data['wm_class'] = entClass.get_text() condition = Condition(**data) # Grab selected profile model, iter = cbProfile.get_model(), cbProfile.get_active_iter() profile = model.get_value(iter, 0) # Grab & update current row model, iter = tvItems.get_selection().get_selected() o = model.get_value(iter, 0) o.condition = condition model.set_value(iter, 1, condition.describe()) model.set_value(iter, 2, profile) self.on_ConditionEditor_destroy(ce) self.save_config()