[meld: 1/2] issue: #icon-tint-Gdk.Color - EmblemCellRenderer crashes if you try to give it a Gdk.Color property;



commit b8715c7f1cf65a4ca9dbaa714ff0162bad72f087
Author: hugosenari <hugosenari gmail com>
Date:   Fri Jun 29 02:45:40 2018 -0300

    issue: #icon-tint-Gdk.Color - EmblemCellRenderer crashes if you try to give it a Gdk.Color property; 
commit: Doc say that if type isnt bool, str, int or float tuple of property must have only 4 items
    https://python-gtk-3-tutorial.readthedocs.io/en/latest/objects.html#GObject.GObject.__gproperties__
    
    "First shalt thou take out the Holy Pin.
    Then, shalt thou count to Four, no more, no less.
    Four shall be the number thou shalt count, and the number of the counting shall be Four.
    Five shalt thou not count, nor either count thou Three, excepting that thou then proceed to Four.
    Six is right out! Once the number Four, being the fourth number, be reached,
    then lobbest thou thy Holy Hand Grenade of Antioch towards thou foe, who being naughty in my sight, shall 
snuff it."

 meld/tree.py                  |  6 +-----
 meld/ui/emblemcellrenderer.py | 14 ++++----------
 2 files changed, 5 insertions(+), 15 deletions(-)
---
diff --git a/meld/tree.py b/meld/tree.py
index 8d76c893..68c7a781 100644
--- a/meld/tree.py
+++ b/meld/tree.py
@@ -33,7 +33,7 @@ from meld.vc._vc import (  # noqa: F401
 COL_PATH, COL_STATE, COL_TEXT, COL_ICON, COL_TINT, COL_FG, COL_STYLE, \
     COL_WEIGHT, COL_STRIKE, COL_END = list(range(10))
 
-COL_TYPES = (str, str, str, str, str, Gdk.RGBA, Pango.Style,
+COL_TYPES = (str, str, str, str, Gdk.RGBA, Gdk.RGBA, Pango.Style,
              Pango.Weight, bool)
 
 
@@ -146,10 +146,6 @@ class DiffTreeStore(SearchableTreeStore):
         self.set_value(it, col_idx(COL_STATE, pane), str(state))
         self.set_value(it, col_idx(COL_TEXT,  pane), label)
         self.set_value(it, col_idx(COL_ICON,  pane), icon)
-        # FIXME: This is horrible, but EmblemCellRenderer crashes
-        # if you try to give it a Gdk.Color property
-        if tint:
-            tint = tint.to_string() if tint else None
         self.set_value(it, col_idx(COL_TINT, pane), tint)
 
         fg, style, weight, strike = self.text_attributes[state]
diff --git a/meld/ui/emblemcellrenderer.py b/meld/ui/emblemcellrenderer.py
index 6a00ea1d..2e9e6bd2 100644
--- a/meld/ui/emblemcellrenderer.py
+++ b/meld/ui/emblemcellrenderer.py
@@ -35,9 +35,9 @@ class EmblemCellRenderer(Gtk.CellRenderer):
             str, "Named secondary emblem icon",
             "Name for secondary emblem icon to overlay",
             None, GObject.ParamFlags.READWRITE),
-        "icon-tint":   (str, "Icon tint",
+        "icon-tint":   (Gdk.RGBA, "Icon tint",
                         "GDK-parseable color to be used to tint icon",
-                        None, GObject.ParamFlags.READWRITE),
+                        GObject.ParamFlags.READWRITE),
     }
 
     icon_cache = {}
@@ -48,7 +48,6 @@ class EmblemCellRenderer(Gtk.CellRenderer):
         self._emblem_name = None
         self._secondary_emblem_name = None
         self._icon_tint = None
-        self._tint_color = None
         self._state = None
         # FIXME: hardcoded sizes
         self._icon_size = 16
@@ -63,11 +62,6 @@ class EmblemCellRenderer(Gtk.CellRenderer):
             self._secondary_emblem_name = value
         elif pspec.name == "icon-tint":
             self._icon_tint = value
-            if self._icon_tint:
-                self._tint_color = Gdk.RGBA()
-                self._tint_color.parse(value)
-            else:
-                self._tint_color = None
         else:
             raise AttributeError("unknown property %s" % pspec.name)
 
@@ -108,8 +102,8 @@ class EmblemCellRenderer(Gtk.CellRenderer):
                               pixbuf.get_width(), pixbuf.get_height())
             context.fill()
 
-            if self._tint_color:
-                c = self._tint_color
+            if self._icon_tint:
+                c = self._icon_tint
                 r, g, b = c.red, c.green, c.blue
                 # Figure out the difference between our tint colour and an
                 # empirically determined (i.e., guessed) satisfying luma and


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]