Example #1
0
 def on_mi_ctag_activate(self, widget):
     random_color = generate_tag_color()
     present_color = self.tag.get_attribute('color')
     if (present_color is not None):
         color_remove(present_color)
     self.tag.set_attribute('color', random_color)
     color_add(random_color)
Example #2
0
 def on_mi_ctag_activate(self, widget):
     random_color = generate_tag_color()
     present_color = self.tag.get_attribute('color')
     if(present_color is not None):
             color_remove(present_color)
     self.tag.set_attribute('color', random_color)
     color_add(random_color)
Example #3
0
    def _apply(self, widget: GObject.Object):
        """
        Apply button has been clicked, applying the settings and closing the
        editor window.
        """
        if self.tag is None:
            log.warning("Trying to apply but no tag set, shouldn't happen")
            self._cancel(widget)
            return

        if self.has_icon and self._emoji:
            self.tag.set_attribute('icon', self._emoji)
        elif self.has_icon:  # Should never happen, but just in case
            log.warning("Tried to set icon for %r but no icon given",
                        self.tag.get_name())
            self.tag.del_attribute('icon')
        else:
            self.tag.del_attribute('icon')

        if self.has_color:
            rgba = self.tag_rgba
            color = "#%02x%02x%02x" % (int(max(0, min(rgba.red, 1)) * 255),
                                       int(max(0, min(rgba.green, 1)) * 255),
                                       int(max(0, min(rgba.blue, 1)) * 255))
            color_add(color)
            self.tag.set_attribute('color', color)
        else:
            if tag_color := self.tag.get_attribute('color'):
                color_remove(tag_color)
            self.tag.del_attribute('color')
Example #4
0
 def on_tc_colsel_changed(self, widget):
     """Callback: update the tag color depending on the current color
     selection"""
     color = self.tc_cc_colsel.get_selected_color()
     if self.tag is not None:
         if color is not None:
             my_color = Gdk.color_parse(color)
             color = Gdk.Color(my_color.red, my_color.green, my_color.blue).to_string()
             color_add(color)
             self.tag.set_attribute('color', color)
         else:
             color_remove(self.tag.get_attribute('color'))
             self.tag.del_attribute('color')
Example #5
0
 def on_tc_colsel_changed(self, widget):
     """Callback: update the tag color depending on the current color
     selection"""
     color = self.tc_cc_colsel.get_selected_color()
     if self.tag is not None:
         if color is not None:
             my_color = Gdk.color_parse(color)
             color = Gdk.Color(my_color.red, my_color.green, my_color.blue).to_string()
             color_add(color)
             self.tag.set_attribute("color", color)
         else:
             color_remove(self.tag.get_attribute("color"))
             self.tag.del_attribute("color")