From: Raffaele Sandrini Date: Wed, 9 Jul 2008 21:38:27 +0000 (+0000) Subject: Change GObject properties to always notify on value change, remove the X-Git-Tag: VALA_0_3_5~64 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0dc4e986f8060e9f8444966e065061acd4a2416;p=platform%2Fupstream%2Fvala.git Change GObject properties to always notify on value change, remove the 2008-07-10 Raffaele Sandrini * gobject/valaccodegenerator.vala: * vala/valaproperty.vala: Change GObject properties to always notify on value change, remove the [Notify] attribute and add a boolean CCode attribute parameter named `notify', based on patch by Jared Moore, fixes bug 540700 * tests/classes-properties.vala: update svn path=/trunk/; revision=1690 --- diff --git a/ChangeLog b/ChangeLog index 57fc485..4d58d46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-07-10 Raffaele Sandrini + + * gobject/valaccodegenerator.vala: + * vala/valaproperty.vala: + + Change GObject properties to always notify on value change, remove the + [Notify] attribute and add a boolean CCode attribute parameter named + `notify', based on patch by Jared Moore, fixes bug 540700 + + * tests/classes-properties.vala: update + 2008-07-98 Jared Moore * gobject/valaccodecompiler.vala: diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index 45e4689..4cc8fa4 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -953,7 +953,10 @@ public class Vala.CCodeGenerator : CodeGenerator { } // notify on property changes - if (prop.notify && (acc.writable || acc.construction)) { + if (current_class.is_subtype_of (gobject_type) && + prop.notify && + prop.access != SymbolAccessibility.PRIVATE && // FIXME: use better means to detect gobject properties + (acc.writable || acc.construction)) { var notify_call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_notify")); notify_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("self"), "GObject *")); notify_call.add_argument (prop.get_canonical_cconstant ()); diff --git a/tests/classes-properties.vala b/tests/classes-properties.vala index 94d6216..3c011f7 100644 --- a/tests/classes-properties.vala +++ b/tests/classes-properties.vala @@ -4,7 +4,6 @@ public class Sample : Object { private string automatic { get; set; } private string _name; - [Notify] public string name { get { return _name; } set { _name = value; } diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala index 2eb0c77..79cd77f 100644 --- a/vala/valaproperty.vala +++ b/vala/valaproperty.vala @@ -18,6 +18,7 @@ * * Author: * Jürg Billeter + * Raffaele Sandrini */ using GLib; @@ -56,7 +57,7 @@ public class Vala.Property : Member, Lockable { * Specifies whether a `notify' signal should be emitted on property * changes. */ - public bool notify { get; set; } + public bool notify { get; set; default = true; } /** * Specifies whether the implementation of this property does not @@ -241,14 +242,20 @@ public class Vala.Property : Member, Lockable { return str.str; } - + + void process_ccode_attribute (Attribute a) { + if (a.has_argument ("notify")) { + notify = a.get_bool ("notify"); + } + } + /** * Process all associated attributes. */ public void process_attributes () { foreach (Attribute a in attributes) { - if (a.name == "Notify") { - notify = true; + if (a.name == "CCode") { + process_ccode_attribute (a); } else if (a.name == "NoAccessorMethod") { no_accessor_method = true; } else if (a.name == "Description") {