Change GObject properties to always notify on value change, remove the
authorRaffaele Sandrini <raffaele@sandrini.ch>
Wed, 9 Jul 2008 21:38:27 +0000 (21:38 +0000)
committerRaffaele Sandrini <rasa@src.gnome.org>
Wed, 9 Jul 2008 21:38:27 +0000 (21:38 +0000)
2008-07-10  Raffaele Sandrini  <raffaele@sandrini.ch>

* 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

ChangeLog
gobject/valaccodegenerator.vala
tests/classes-properties.vala
vala/valaproperty.vala

index 57fc485..4d58d46 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-07-10  Raffaele Sandrini  <raffaele@sandrini.ch>
+
+       * 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  <jaredm@svn.gnome.org>
 
        * gobject/valaccodecompiler.vala:
index 45e4689..4cc8fa4 100644 (file)
@@ -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 ());
index 94d6216..3c011f7 100644 (file)
@@ -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; }
index 2eb0c77..79cd77f 100644 (file)
@@ -18,6 +18,7 @@
  *
  * Author:
  *     Jürg Billeter <j@bitron.ch>
+ *     Raffaele Sandrini <raffaele@sandrini.ch>
  */
 
 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") {