[california] Fix regression introduced in commit 8e8a7e



commit 4c061d5389cae62f08fa0697d9e22a2047d5e021
Author: Jim Nelson <jim yorba org>
Date:   Fri Apr 4 17:43:17 2014 -0700

    Fix regression introduced in commit 8e8a7e
    
    The color button in the Calendar Manager wasn't hooked up to the
    backing source's color.  This corrects that problem using property
    binding, a better way to deal with this.

 src/manager/manager-calendar-list-item.vala |   18 +++++++++++++-----
 src/util/util-gfx.vala                      |    4 ++++
 2 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/src/manager/manager-calendar-list-item.vala b/src/manager/manager-calendar-list-item.vala
index 41c924c..917385a 100644
--- a/src/manager/manager-calendar-list-item.vala
+++ b/src/manager/manager-calendar-list-item.vala
@@ -34,9 +34,8 @@ public class CalendarListItem : Gtk.Grid {
             BindingFlags.SYNC_CREATE);
         source.bind_property(Backing.Source.PROP_VISIBLE, visible_check_button, "active",
             BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
-        
-        on_color_changed();
-        source.notify[Backing.Source.PROP_COLOR].connect(on_color_changed);
+        source.bind_property(Backing.Source.PROP_COLOR, color_button, "rgba",
+            BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL, source_to_button, button_to_source);
     }
     
     public override bool query_tooltip(int x, int y, bool keyboard_mode, Gtk.Tooltip tooltip) {
@@ -49,8 +48,17 @@ public class CalendarListItem : Gtk.Grid {
         return true;
     }
     
-    private void on_color_changed() {
-        color_button.set_color(source.color_as_rgb());
+    public bool source_to_button(Binding binding, Value source_value, ref Value target_value) {
+        bool used_default;
+        target_value = Gfx.rgb_string_to_rgba(source.color, Gfx.RGBA_BLACK, out used_default);
+        
+        return !used_default;
+    }
+    
+    public bool button_to_source(Binding binding, Value source_value, ref Value target_value) {
+        target_value = Gfx.rgb_to_uint8_rgb_string(Gfx.rgba_to_rgb(color_button.rgba));
+        
+        return true;
     }
 }
 
diff --git a/src/util/util-gfx.vala b/src/util/util-gfx.vala
index 2225df4..53e09d5 100644
--- a/src/util/util-gfx.vala
+++ b/src/util/util-gfx.vala
@@ -6,6 +6,10 @@
 
 namespace California.Gfx {
 
+public const Gdk.Color RGB_BLACK = { 0, 0, 0 };
+
+public const Gdk.RGBA RGBA_BLACK = { 0.0, 0.0, 0.0, 0.0 };
+
 /**
  * Convert an RGB string into an RGB structure.
  *


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