[gedit-plugins] colorpicker: handle partial colors



commit c742a178dc4fc1a6ba0ab78e5e0080d2e7fa6162
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Sep 20 12:45:27 2012 +0200

    colorpicker: handle partial colors

 plugins/colorpicker/colorpicker.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/plugins/colorpicker/colorpicker.py b/plugins/colorpicker/colorpicker.py
index 63b4e25..12f16bf 100644
--- a/plugins/colorpicker/colorpicker.py
+++ b/plugins/colorpicker/colorpicker.py
@@ -210,6 +210,7 @@ class ColorPickerViewActivatable(GObject.Object, Gedit.ViewActivatable):
 
     def __init__(self):
         GObject.Object.__init__(self)
+        self._rgba_str = None
         self._color_button = None
         self._color_helper = ColorHelper()
 
@@ -235,10 +236,18 @@ class ColorPickerViewActivatable(GObject.Object, Gedit.ViewActivatable):
             return
 
         rgba_str = self._color_helper.get_current_color(self.view.get_buffer(), True)
-        if rgba_str is not None and self._color_button is None:
+        if rgba_str is not None and rgba_str != self._rgba_str and self._color_button is not None:
             rgba = Gdk.RGBA()
             parsed = rgba.parse(rgba_str)
             if parsed:
+                self._rgba_str = rgba_str
+                self._color_button.set_rgba(rgba)
+        elif rgba_str is not None and self._color_button is None:
+            rgba = Gdk.RGBA()
+            parsed = rgba.parse(rgba_str)
+            if parsed:
+                self._rgba_str = rgba_str
+
                 bounds = buf.get_selection_bounds()
                 if bounds != ():
                     self._color_button = Gtk.ColorButton.new_with_rgba(rgba)



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