[gedit-plugins] [multiedit] Fix custom selection colors



commit 1ce689222699ea7d2b6cfae08766172869263fb4
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Mon Jan 13 14:44:34 2014 +0100

    [multiedit] Fix custom selection colors

 plugins/multiedit/multiedit/viewactivatable.py |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/plugins/multiedit/multiedit/viewactivatable.py b/plugins/multiedit/multiedit/viewactivatable.py
index ddf250a..4f6664f 100644
--- a/plugins/multiedit/multiedit/viewactivatable.py
+++ b/plugins/multiedit/multiedit/viewactivatable.py
@@ -100,17 +100,17 @@ class MultiEditViewActivatable(GObject.Object, Gedit.ViewActivatable, Signals):
 
     def _update_selection_tag(self):
         context = self.view.get_style_context()
-        state = context.get_state()
+        context.save()
+        context.add_class('view')
+        state = context.get_state() | Gtk.StateFlags.SELECTED
 
         fg_rgba = context.get_color(state)
         bg_rgba = context.get_background_color(state)
 
-        # TODO: Use GdkRGBA directly when possible
-        fg = Gdk.Color(fg_rgba.red * 65535, fg_rgba.green * 65535, fg_rgba.blue * 65535)
-        bg = Gdk.Color(bg_rgba.red * 65535, bg_rgba.green * 65535, bg_rgba.blue * 65535)
+        context.restore()
 
-        self._selection_tag.props.foreground_gdk = fg
-        self._selection_tag.props.background_gdk = bg
+        self._selection_tag.props.foreground_rgba = fg_rgba
+        self._selection_tag.props.background_rgba = bg_rgba
 
     def reset_buffer(self, newbuf):
         if self._buffer:
@@ -665,7 +665,11 @@ class MultiEditViewActivatable(GObject.Object, Gedit.ViewActivatable, Signals):
         width = layout.get_pixel_extents()[1].width
 
         context = self.view.get_style_context()
+        context.save()
+        context.add_class('view')
         col = context.get_background_color(Gtk.StateFlags.SELECTED)
+        context.restore()
+
         Gdk.cairo_set_source_rgba(cr, col)
 
         cstart = self._column_mode[2]


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