From 0a52042be3ff5940c1196be2409601ecb204cb51 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Thu, 20 Sep 2007 09:21:32 +0000 Subject: [PATCH] support notify attribute for properties 2007-09-20 Juerg Billeter * vala/valaproperty.vala, gobject/valaccodegenerator.vala: support notify attribute for properties svn path=/trunk/; revision=621 --- ChangeLog | 6 ++++++ gobject/valaccodegenerator.vala | 8 ++++++++ vala/valaproperty.vala | 12 ++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80c44f9..893712f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ +2007-09-20 Jürg Billeter + + * vala/valaproperty.vala, gobject/valaccodegenerator.vala: support + notify attribute for properties + 2007-09-19 Alberto Ruiz + * vala-1.0.pc.in: add vapigen variable, fixes bug 477111 diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index 56b03ff..e4bcc8c 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -643,6 +643,14 @@ public class Vala.CCodeGenerator : CodeGenerator { function.block = (CCodeBlock) acc.body.ccodenode; function.block.prepend_statement (create_property_type_check_statement (prop, acc.readable, t, true, "self")); + + // notify on property changes + if (prop.notify && (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 ()); + function.block.add_statement (new CCodeExpressionStatement (notify_call)); + } } source_type_member_definition.append (function); diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala index 89995b6..444c9c6 100644 --- a/vala/valaproperty.vala +++ b/vala/valaproperty.vala @@ -45,7 +45,13 @@ public class Vala.Property : Member, Lockable { * Represents the generated ´this' parameter in this property. */ public FormalParameter this_parameter { get; set; } - + + /** + * Specifies whether a `notify' signal should be emitted on property + * changes. + */ + public bool notify { get; set; } + /** * Specifies whether the implementation of this property does not * provide getter/setter methods. @@ -168,7 +174,9 @@ public class Vala.Property : Member, Lockable { */ public void process_attributes () { foreach (Attribute a in attributes) { - if (a.name == "NoAccessorMethod") { + if (a.name == "Notify") { + notify = true; + } else if (a.name == "NoAccessorMethod") { no_accessor_method = true; } } -- 2.7.4