Пример #1
0
    def on_effect_changed(self, radio_button: Gtk.RadioButton,
                          effect: int) -> None:
        if not radio_button.get_active():
            return

        serial_message = 'be'
        config.new("back", "effect", str(effect))
        serial_message += config.parser.get("back", "effect")
        self.application.send_serial(serial_message)
Пример #2
0
    def on_auto_effect_changed(self, combo: Gtk.ComboBoxText) -> None:
        name = combo.get_name()
        effect = list(auto_effect_dict)[combo.get_active()]

        config.new('auto_effect', name, effect)

        serial_message = 'la'
        serial_message += config.parser.get("auto_effect", name)
        self.application.send_serial(serial_message)
        sleep(1.5)
Пример #3
0
    def on_led_color_changed(self,
                             color_selection: Gtk.ColorSelection) -> None:
        serial_message = 'bc'
        color_raw = color_selection.get_current_rgba().to_string()
        color_string = [
            '{0:0=3d}'.format(int(color))
            for color in color_raw[4:-1].split(',')
        ]
        config.new("back", "led_colors", ''.join(color_string) * 29)

        serial_message += ''.join(config.parser.get("back", "led_colors"))
        self.application.send_serial(serial_message)
Пример #4
0
    def on_color_changed(self, color_button: Gtk.ColorButton,
                         param: str) -> None:
        name = color_button.get_name()
        color_string = utils.rgba_to_led_color(color_button.get_rgba())
        config.new("effects", name, color_string)

        if name == "primary_color":
            serial_message = "lc"
        else:
            serial_message = "ls"

        serial_message += color_string
        self.application.send_serial(serial_message)
Пример #5
0
    def on_power_clicked(self, button: Gtk.Button) -> None:
        serial_message = 'fl'
        status = str(int(button.get_active()))

        if self.fan_index == -1:
            config.new("front", "power_status", status * 3)
        else:
            config.set_to_index("front", "power_status", status,
                                self.fan_index)

        serial_message += config.parser.get("front", "power_status")

        self.application.send_serial(serial_message)
Пример #6
0
    def on_scale_changed(self, scale: Gtk.Scale, type_=str, value=str) -> None:
        name = scale.get_name()

        if int(value) > 255:
            value = "255"
        elif int(value) < 0:
            value = "0"
        else:
            value = str(int(value))

        config.new("advanced", name, value)

        serial_message = 'l{}{:0=3d}'.format(name[0:1], int(value))
        self.application.send_serial(serial_message)
Пример #7
0
    def on_multiplier_change(self, scale: Gtk.Scale, type_: str,
                             value: str) -> None:
        serial_message = 'fm'
        pulse = int(value)
        if pulse < 1: pulse = 1

        if self.fan_index == -1:
            config.new("front", "multiplier", '{0:0=3d}'.format(pulse) * 3)
        else:
            config.set_to_index("front", "multiplier",
                                '{0:0=3d}'.format(pulse), self.fan_index)

        serial_message += config.parser.get("front", "multiplier")
        self.application.send_serial(serial_message)
Пример #8
0
    def on_effect_changed(self, radio_button: Gtk.RadioButton,
                          effect: int) -> None:
        if not radio_button.get_active():
            return

        serial_message = 'fe'

        if self.fan_index == -1:
            config.new("front", "effect", str(effect) * 3)
        else:
            config.set_to_index("front", "effect", str(effect), self.fan_index)

        serial_message += config.parser.get("front", "effect")
        self.application.send_serial(serial_message)
Пример #9
0
    def on_effects_changed(self, combo: Gtk.ComboBoxText) -> None:
        self.primary_effect.set_sensitive(True)
        self.secondary_effect.set_sensitive(True)
        self.primary_color.set_sensitive(True)
        self.secondary_color.set_sensitive(True)
        name = combo.get_name()

        if name == "primary_effect":
            effect = list(primary_effects_dict)[combo.get_active()]

            if effect in extra_effect_block_list:
                self.extra_effect.set_active(0)
                self.extra_effect.set_sensitive(False)
            else:
                self.extra_effect.set_sensitive(True)
        elif name == "secondary_effect":
            effect = list(secondary_effects_dict)[combo.get_active()]
        else:
            effect = list(extra_effects_dict)[combo.get_active()]

        if self.primary_effect.get_active() == 0:
            self.secondary_effect.set_active(0)
            self.secondary_effect.set_sensitive(False)

        if self.extra_effect.get_active(
        ) == 0 or self.primary_effect.get_active() == 0:
            current_effect_list = [
                list(primary_effects_dict)[self.primary_effect.get_active()],
                list(extra_effects_dict)[self.extra_effect.get_active()],
            ]

            if any((effect in primary_color_effect_block_list)
                   for effect in current_effect_list):
                self.primary_color.set_sensitive(False)

            if any((effect in secondary_color_effect_block_list)
                   for effect in current_effect_list):
                self.secondary_color.set_sensitive(False)

        config.new('effects', name, effect)

        serial_message = 'le'
        serial_message += config.parser.get("effects", "extra_effect")
        serial_message += config.parser.get("effects", "secondary_effect")
        serial_message += config.parser.get("effects", "primary_effect")
        self.application.send_serial(serial_message)
Пример #10
0
    def on_led_color_changed(self,
                             color_selection: Gtk.ColorSelection) -> None:
        serial_message = 'fc'
        raw_color = color_selection.get_current_rgba().to_string()
        color_string = [
            '{0:0=3d}'.format(int(color))
            for color in raw_color[4:-1].split(',')
        ]

        if self.fan_index == -1:
            config.new("front", "led_colors", ''.join(color_string) * 3)
        else:
            config.set_to_index("front", "led_colors", ''.join(color_string),
                                self.fan_index)

        serial_message += config.parser.get("front", "led_colors")
        self.application.send_serial(serial_message)