[california] Unbind from src properties when widget destroyed: Closes bug #730263
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Unbind from src properties when widget destroyed: Closes bug #730263
- Date: Fri, 16 May 2014 22:54:24 +0000 (UTC)
commit 0e10af3ba395db2a3b14f6e9240c6e320689de10
Author: Jim Nelson <jim yorba org>
Date: Fri May 16 15:39:42 2014 -0700
Unbind from src properties when widget destroyed: Closes bug #730263
base-properties helper methods didn't deal with lifecycle of generated
Binding object properly, meaning it was impossible to unbind from the
source object when the target object was destroyed, leading to bad
references when properties changed.
src/Makefile.am | 1 -
src/backing/eds/backing-eds-calendar-source.vala | 3 +
src/base/base-properties.vala | 54 ----------------------
src/host/host-quick-create-event.vala | 10 +++-
src/manager/manager-calendar-list-item.vala | 20 ++++++--
5 files changed, 27 insertions(+), 61 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 313d7ef..bc3cec5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,7 +43,6 @@ california_VALASOURCES = \
backing/eds/backing-eds-store.vala \
\
base/base-object.vala \
- base/base-properties.vala \
base/base-unit.vala \
\
calendar/calendar.vala \
diff --git a/src/backing/eds/backing-eds-calendar-source.vala
b/src/backing/eds/backing-eds-calendar-source.vala
index 535014b..6e3c0d2 100644
--- a/src/backing/eds/backing-eds-calendar-source.vala
+++ b/src/backing/eds/backing-eds-calendar-source.vala
@@ -118,6 +118,9 @@ internal class EdsCalendarSource : CalendarSource {
cancellable);
client.bind_property("readonly", this, PROP_READONLY, BindingFlags.SYNC_CREATE);
+ client.notify["readonly"].connect(() => {
+ debug("%s readonly: %s", to_string(), client.readonly.to_string());
+ });
}
// Invoked by EdsStore when closing and dropping all its refs
diff --git a/src/host/host-quick-create-event.vala b/src/host/host-quick-create-event.vala
index 635f056..42da468 100644
--- a/src/host/host-quick-create-event.vala
+++ b/src/host/host-quick-create-event.vala
@@ -44,8 +44,14 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
// make first item active
calendar_combo_box.active = 0;
- Properties.xform_to_bool(details_entry, "text-length", create_button, "sensitive",
- () => !String.is_empty(details_entry.text));
+ details_entry.bind_property("text-length", create_button, "sensitive", BindingFlags.SYNC_CREATE,
+ xform_text_length_to_sensitive);
+ }
+
+ private bool xform_text_length_to_sensitive(Binding binding, Value source_value, ref Value target_value)
{
+ target_value = !String.is_empty(details_entry.text);
+
+ return true;
}
public void jumped_to(Toolkit.Card? from, Value? message) {
diff --git a/src/manager/manager-calendar-list-item.vala b/src/manager/manager-calendar-list-item.vala
index 027e7b7..29d2fdf 100644
--- a/src/manager/manager-calendar-list-item.vala
+++ b/src/manager/manager-calendar-list-item.vala
@@ -51,10 +51,10 @@ internal class CalendarListItem : Gtk.Grid, Toolkit.MutableWidget {
BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
source.bind_property(Backing.Source.PROP_COLOR, color_button, "rgba",
BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL, source_to_color, color_to_source);
- Properties.xform_to_string(source, Backing.Source.PROP_READONLY, readonly_icon, "icon-name",
- () => source.read_only ? "changes-prevent-symbolic" : "");
- Properties.xform_to_string(source, Backing.Source.PROP_READONLY, readonly_icon, "tooltip-text",
- () => source.read_only ? _("Calendar is read-only") : null);
+ source.bind_property(Backing.Source.PROP_READONLY, readonly_icon, "icon-name",
+ BindingFlags.SYNC_CREATE, xform_readonly_to_icon_name);
+ source.bind_property(Backing.Source.PROP_READONLY, readonly_icon, "tooltip-text",
+ BindingFlags.SYNC_CREATE, xform_readonly_to_tooltip_text);
title_eventbox.button_release_event.connect(on_title_button_release);
}
@@ -68,6 +68,18 @@ internal class CalendarListItem : Gtk.Grid, Toolkit.MutableWidget {
mutated();
}
+ private bool xform_readonly_to_icon_name(Binding binding, Value source_value, ref Value target_value) {
+ target_value = source.read_only ? "changes-prevent-symbolic" : "";
+
+ return true;
+ }
+
+ private bool xform_readonly_to_tooltip_text(Binding binding, Value source_value, ref Value target_value)
{
+ target_value = source.read_only ? _("Calendar is read-only") : null;
+
+ return true;
+ }
+
public override bool query_tooltip(int x, int y, bool keyboard_mode, Gtk.Tooltip tooltip) {
// no tooltip if text is entirely shown
if (!title_label.get_layout().is_ellipsized())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]