Ejemplo n.º 1
0
	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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
 def on_btAdd_clicked(self, *a):
     """ Handler for "Add Item" button """
     tvItems = self.builder.get_object("tvItems")
     model = tvItems.get_model()
     o = GObject.GObject()
     o.condition = Condition()
     iter = model.append((o, o.condition.describe(), "None"))
     tvItems.get_selection().select_iter(iter)
     self.on_tvItems_cursor_changed()
     self.btEdit_clicked_cb()
Ejemplo n.º 4
0
	def load_autoswitch(self):
		""" Transfers autoswitch settings from config to UI """
		tvItems = self.builder.get_object("tvItems")
		cbShowOSD = self.builder.get_object("cbShowOSD")
		model = tvItems.get_model()
		model.clear()
		for x in self.app.config['autoswitch']:
			o = GObject.GObject()
			o.condition = Condition.parse(x['condition'])
			model.append((o, o.condition.describe(), x['profile']))
		self._recursing = True
		self.on_tvItems_cursor_changed()
		cbShowOSD.set_active(bool(self.app.config['autoswitch_osd']))
		self._recursing = False
Ejemplo n.º 5
0
 def load_autoswitch(self):
     """ Transfers autoswitch settings from config to UI """
     tvItems = self.builder.get_object("tvItems")
     cbShowOSD = self.builder.get_object("cbShowOSD")
     model = tvItems.get_model()
     model.clear()
     for x in self.app.config['autoswitch']:
         o = GObject.GObject()
         o.condition = Condition.parse(x['condition'])
         model.append((o, o.condition.describe(), x['profile']))
     self._recursing = True
     self.on_tvItems_cursor_changed()
     cbShowOSD.set_active(bool(self.app.config['autoswitch_osd']))
     self._recursing = False
Ejemplo n.º 6
0
	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()
Ejemplo n.º 7
0
    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()
Ejemplo n.º 8
0
	def load_autoswitch(self):
		""" Transfers autoswitch settings from config to UI """
		tvItems = self.builder.get_object("tvItems")
		cbShowOSD = self.builder.get_object("cbShowOSD")
		model = tvItems.get_model()
		model.clear()
		for x in self.app.config['autoswitch']:
			o = GObject.GObject()
			o.condition = Condition.parse(x['condition'])
			o.action = GuiActionParser().restart(x["action"]).parse()
			a_str = o.action.describe(Action.AC_SWITCHER)
			model.append((o, o.condition.describe(), a_str))
		self._recursing = True
		self.on_tvItems_cursor_changed()
		cbShowOSD.set_active(bool(self.app.config['autoswitch_osd']))
		self._recursing = False
Ejemplo n.º 9
0
	def load_autoswitch(self):
		""" Transfers autoswitch settings from config to UI """
		tvItems = self.builder.get_object("tvItems")
		cbShowOSD = self.builder.get_object("cbShowOSD")
		model = tvItems.get_model()
		model.clear()
		for x in self.app.config['autoswitch']:
			o = GObject.GObject()
			o.condition = Condition.parse(x['condition'])
			o.action = GuiActionParser().restart(x["action"]).parse()
			a_str = o.action.describe(Action.AC_SWITCHER)
			model.append((o, o.condition.describe(), a_str))
		self._recursing = True
		self.on_tvItems_cursor_changed()
		cbShowOSD.set_active(bool(self.app.config['autoswitch_osd']))
		self._recursing = False