[meld] misc, emblemcellrenderer: Fix 3.20 API break in colour parsing
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] misc, emblemcellrenderer: Fix 3.20 API break in colour parsing
- Date: Fri, 26 Feb 2016 21:36:08 +0000 (UTC)
commit 5b0d31d2799550ad9af1c8ac6349f7b8823af20b
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Jan 30 09:28:49 2016 +1000
misc, emblemcellrenderer: Fix 3.20 API break in colour parsing
meld/misc.py | 15 ++++++++++++---
meld/ui/emblemcellrenderer.py | 5 +++--
2 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/meld/misc.py b/meld/misc.py
index ad323ef..8580139 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -147,6 +147,17 @@ def make_tool_button_widget(label):
MELD_STYLE_SCHEME = "meld-base"
+def parse_rgba(string):
+ """Parse a string to a Gdk.RGBA across different GTK+ APIs
+
+ Introspection changes broke this API in GTK+ 3.20; this function
+ is just a backwards-compatiblity workaround.
+ """
+ colour = Gdk.RGBA()
+ result = colour.parse(string)
+ return result[1] if isinstance(result, tuple) else colour
+
+
def colour_lookup_with_fallback(name, attribute):
from meld.settings import meldsettings
source_style = meldsettings.style_scheme
@@ -169,9 +180,7 @@ def colour_lookup_with_fallback(name, attribute):
"this is a bad install") % (name, attribute)
sys.exit(1)
- colour = Gdk.RGBA()
- colour.parse(style_attr)
- return colour
+ return parse_rgba(style_attr)
def get_common_theme():
diff --git a/meld/ui/emblemcellrenderer.py b/meld/ui/emblemcellrenderer.py
index a924aae..e1e528d 100644
--- a/meld/ui/emblemcellrenderer.py
+++ b/meld/ui/emblemcellrenderer.py
@@ -19,6 +19,8 @@ from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
+from meld.misc import parse_rgba
+
class EmblemCellRenderer(Gtk.CellRenderer):
@@ -57,8 +59,7 @@ class EmblemCellRenderer(Gtk.CellRenderer):
elif pspec.name == "icon-tint":
self._icon_tint = value
if self._icon_tint:
- self._tint_color = Gdk.RGBA()
- self._tint_color.parse(value)
+ self._tint_color = parse_rgba(value)
else:
self._tint_color = None
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]