[meld] Update required GTK+, etc. to 3.20 and remove some compat hacks



commit 210ddbb2bcc0cd834b0b4b211aaf0e26e49c2289
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Fri Nov 17 08:06:01 2017 +1000

    Update required GTK+, etc. to 3.20 and remove some compat hacks

 README                        |    8 ++++----
 data/meld.css                 |    5 -----
 meld/gutterrendererchunk.py   |   11 +++--------
 meld/linkmap.py               |    7 ++-----
 meld/meldwindow.py            |   10 +++-------
 meld/misc.py                  |   15 +++------------
 meld/ui/emblemcellrenderer.py |    5 ++---
 meld/ui/gtkcompat.py          |    3 +--
 meld/ui/notebook.py           |    5 ++---
 9 files changed, 20 insertions(+), 49 deletions(-)
---
diff --git a/README b/README
index fa672b8..b23d4eb 100644
--- a/README
+++ b/README
@@ -16,11 +16,11 @@ Meld is licensed under the GPL v2 or later.
 Requirements
 ------------
 
-* Python 3.3
-* GTK+ 3.14
+* Python 3.4
+* GTK+ 3.20
 * GLib 2.36
-* PyGObject 3.14
-* GtkSourceView 3.14
+* PyGObject 3.20
+* GtkSourceView 3.20
 * pycairo
 
 
diff --git a/data/meld.css b/data/meld.css
index 884c23f..a9b518d 100644
--- a/data/meld.css
+++ b/data/meld.css
@@ -17,11 +17,6 @@ link-map {
     background-color: @theme_bg_color;
 }
 
-/* Only for backwards-compatibility with pre-3.20 GTK+ */
-LinkMap {
-    background-color: @theme_bg_color;
-}
-
 .meld-vc-console-pane {
     border-width: 1px 0 0 0;
     border-style: solid;
diff --git a/meld/gutterrendererchunk.py b/meld/gutterrendererchunk.py
index 32eb040..945a29a 100644
--- a/meld/gutterrendererchunk.py
+++ b/meld/gutterrendererchunk.py
@@ -238,14 +238,9 @@ class GutterRendererChunkAction(
         GtkSource.GutterRendererPixbuf.do_draw(
             self, context, background_area, cell_area, start, end, state)
         if self.is_action:
-            if Gtk.get_minor_version() < 20:
-                style_context = get_style(None, "GtkButton.flat.image-button")
-                style_context.add_class(Gtk.STYLE_CLASS_BUTTON)
-                style_context.add_class(Gtk.STYLE_CLASS_FLAT)
-            else:
-                # TODO: Fix padding and min-height in CSS and use
-                # draw_style_common
-                style_context = get_style(None, "button.flat.image-button")
+            # TODO: Fix padding and min-height in CSS and use
+            # draw_style_common
+            style_context = get_style(None, "button.flat.image-button")
             style_context.set_state(renderer_to_gtk_state(state))
 
             x = background_area.x + 1
diff --git a/meld/linkmap.py b/meld/linkmap.py
index 15a8471..15e1dff 100644
--- a/meld/linkmap.py
+++ b/meld/linkmap.py
@@ -134,11 +134,8 @@ class LinkMap(Gtk.DrawingArea):
     def do_scroll_event(self, event):
         self.filediff.next_diff(event.direction)
 
-try:
-    LinkMap.set_css_name("link-map")
-except AttributeError:
-    # New API in 3.20
-    pass
+
+LinkMap.set_css_name("link-map")
 
 
 class ScrollLinkMap(Gtk.DrawingArea):
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 4987131..c828615 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -246,13 +246,9 @@ class MeldWindow(gnomeglade.Component):
         rmenu = self.ui.get_widget('/Menubar/FileMenu/Recent').get_submenu()
         rmenu.connect("map", self._on_recentmenu_map)
 
-        try:
-            builder = meld.ui.util.get_builder("shortcuts.ui")
-            shortcut_window = builder.get_object("shortcuts-meld")
-            self.widget.set_help_overlay(shortcut_window)
-        except GLib.Error:
-            # GtkShortcutsWindow is new in GTK+ 3.20
-            pass
+        builder = meld.ui.util.get_builder("shortcuts.ui")
+        shortcut_window = builder.get_object("shortcuts-meld")
+        self.widget.set_help_overlay(shortcut_window)
 
     def _on_recentmenu_map(self, recentmenu):
         for imagemenuitem in recentmenu.get_children():
diff --git a/meld/misc.py b/meld/misc.py
index 04579cd..2a65de0 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -185,17 +185,6 @@ def get_base_style_scheme():
 base_style_scheme = None
 
 
-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
@@ -217,7 +206,9 @@ def colour_lookup_with_fallback(name, attribute):
             "this is a bad install") % (name, attribute), file=sys.stderr)
         sys.exit(1)
 
-    return parse_rgba(style_attr)
+    colour = Gdk.RGBA()
+    colour.parse(style_attr)
+    return colour
 
 
 def get_common_theme():
diff --git a/meld/ui/emblemcellrenderer.py b/meld/ui/emblemcellrenderer.py
index e1e528d..a924aae 100644
--- a/meld/ui/emblemcellrenderer.py
+++ b/meld/ui/emblemcellrenderer.py
@@ -19,8 +19,6 @@ 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):
 
@@ -59,7 +57,8 @@ class EmblemCellRenderer(Gtk.CellRenderer):
         elif pspec.name == "icon-tint":
             self._icon_tint = value
             if self._icon_tint:
-                self._tint_color = parse_rgba(value)
+                self._tint_color = Gdk.RGBA()
+                self._tint_color.parse(value)
             else:
                 self._tint_color = None
         else:
diff --git a/meld/ui/gtkcompat.py b/meld/ui/gtkcompat.py
index 0fe1edb..ae0df5d 100644
--- a/meld/ui/gtkcompat.py
+++ b/meld/ui/gtkcompat.py
@@ -42,9 +42,8 @@ def append_element(path, selector):
         ('link',          Gtk.StateFlags.LINK),
         ('visited',       Gtk.StateFlags.VISITED),
         ('checked',       Gtk.StateFlags.CHECKED),
+        ('drop(active)',  Gtk.StateFlags.DROP_ACTIVE)
     ]
-    if Gtk.get_minor_version() >= 20:
-        pseudo_classes.append(('drop(active)',  Gtk.StateFlags.DROP_ACTIVE))
 
     toks = [t for t in re.split('([#\.:])', selector) if t]
     elements = [toks[i] + toks[i + 1] for i in range(1, len(toks), 2)]
diff --git a/meld/ui/notebook.py b/meld/ui/notebook.py
index f10a585..84bb72c 100644
--- a/meld/ui/notebook.py
+++ b/meld/ui/notebook.py
@@ -38,9 +38,8 @@ class MeldNotebook(Gtk.Notebook):
     css = (
         b"""
         @binding-set TabSwitchBindings {}
-        MeldNotebook { """ +
-        (b"" if Gtk.get_minor_version() <= 18 else b"-") +
-        b"gtk-key-bindings: TabSwitchBindings; }"
+        MeldNotebook { -gtk-key-bindings: TabSwitchBindings; }
+        """
     )
 
     ui = """


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