Re: [Vala] GBinding support?

2010-06-21 Thread Jürg Billeter
Hi,

On Sun, 2010-06-20 at 17:57 +0200, Frederik wrote:
> GLib/GObject 2.26 will add property binding [1]. The straightforward way to
> support this in Vala would be:
> 
>   Object.bind_property (foo, "x", bar, "y");
>   Object.bind_property (foo, "x", bar, "y", BindingFlags.BIDIRECTIONAL);
> 
> However, this is not very type-safe. Would direct language support be
> reasonable? E.g. something like
> 
>   foo.x +> bar.y; // default
>   foo.x <+> bar.y;// bidirectional
> 
> Or is it too cryptic?

We don't need special syntax for every available GObject method. Let's
first have a plain binding and see how it will be used. If we see a very
common pattern where syntactic sugar would help a lot, we can reconsider
adding syntactic sugar.

> And how to deal with 'g_object_bind_property_full'? It takes two 
> TransformFuncs
> but only one user_data/GDestroyNotify pair.

This will be fixed, I talked to ebassi on IRC.

Jürg

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] GBinding support?

2010-06-21 Thread Frederik
Am 21.06.2010 05:51, Matias De la Puente wrote:
> This stuff is great! very helpful for my project :)
> 
> My suggestions:
> 
> public class foo : Object
> {
>   public int x { set; get; }
>   public int y { set; get; }
> }
> 
> public class bar : Object
> {
>   private Foo foo = new Foo ();
>   
>   //One possibility
>   public int x { set; get; } as foo.x;
>   public int y { private set; get; } as foo.y;//one direction
>   
>   //Another possibility
>   public int x { set; get; } bind foo.x;
>   public int y { private set; get; } bind foo.y;  //one direction
> }
> 
> Matias

And what if you want to bind to a property of an object not yet instantiated
at construction time?


Best regards,

Frederik
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] GBinding support?

2010-06-21 Thread Frederik
Am 21.06.2010 09:29, Fredderic Unpenstein wrote:
> On 21 June 2010 01:57, Frederik  wrote:
>> GLib/GObject 2.26 will add property binding [1]. The straightforward way to
>> support this in Vala would be:
>>  Object.bind_property (foo, "x", bar, "y");
>>  Object.bind_property (foo, "x", bar, "y", BindingFlags.BIDIRECTIONAL);
> 
> Would foo.x.bind_property be a possibility?  And perhaps
> bind_bidirectional or bind_with (do you bind anything else, other than
> properties, on an object property?)...  Maybe then also bind_property
> could become bind_to or something equaly less redundant?

A problem is that 'foo.x' will evaluate to the value of the property,
not representing the property itself. So, if you write

  foo.x.bind_property (bar.y);

and if 'foo.x' is 4 and 'bar.y' is 5 it would essentially mean

  4.bind_property (5);

> Personaly, I like the operators, but they're a little limited once you
> add extra varients or options, as with the connect family.  Unless
> some syntax is added for general operator functions...  eg:
> 
>foo.x +> [BIDIRECTIONAL] bar.y;
> 
> which could also make += signal connection useful again.  Perhaps
> adding support for a bracketed comma-separated list with the extra
> arguments, instead.

Personally, I prefer descriptive names over symbolic operators. The question
is whether the property binding feature is essential enough to justify extra
syntax (keyword, operator) just to be type safe.

>> And how to deal with 'g_object_bind_property_full'? It takes two 
>> TransformFuncs
>> but only one user_data/GDestroyNotify pair.
>>  (foo.x, celsius_to_fahrenheit) <+> (bar.y, fahrenheit_to_celsius);
>>  (foo.x, (b, s, t) => { }) <+> (bar.y, (b, s, t) => { });
> 
> That's sort of what I was saying with bracketing above, too.  A
> general syntax pattern like that might help with other places where
> syntactic support would be useful but presently shunned.
> 
> 
> Fredderic
> 

Best regards,

Frederik
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Adding my custom object to libGee.List...

2010-06-21 Thread Didier 'Ptitjes'
On 06/21/10 11:20, Xavier Bestel wrote:
> On Sun, 2010-06-20 at 21:28 +0300, Arkadi Viner wrote:
>> Thanks, that did the trick.
>>
>> On Sun, Jun 20, 2010 at 5:02 AM, Didier 'Ptitjes'  wrote:
>>
>>> Hi,
>>>
>>> On 06/19/10 23:48, Arkadi Viner wrote:
 *so, the declaration look like this:*
   private Gee.List pdfDocuments = new Gee.ArrayList ();

 *and when I try to add some thing to it:*
 pdfDocuments.add(new PdfDocument(file_chooser.get_filename
>>> ());
 *I get compilation error:*
 main.vala:99.13-99.24: error: missing generic type arguments
 Process return 256  execution time: 0.90 s
>>>
>>> I guess you have to make your declaration:
>>>
>>> private Gee.List pdfDocuments =
>>>new Gee.ArrayList ();
> 
> How about:
> 
> var pdfDocuments = new Gee.ArrayList ();

I thought "var" only worked for a local variable. Am I wrong ? Here
pdfDocuments is a private member.

Best regards, Didier.
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Adding my custom object to libGee.List...

2010-06-21 Thread Xavier Bestel
On Sun, 2010-06-20 at 21:28 +0300, Arkadi Viner wrote:
> Thanks, that did the trick.
> 
> On Sun, Jun 20, 2010 at 5:02 AM, Didier 'Ptitjes'  wrote:
> 
> > Hi,
> >
> > On 06/19/10 23:48, Arkadi Viner wrote:
> > > *so, the declaration look like this:*
> > >   private Gee.List pdfDocuments = new Gee.ArrayList ();
> > >
> > > *and when I try to add some thing to it:*
> > > pdfDocuments.add(new PdfDocument(file_chooser.get_filename
> > ());
> > > *I get compilation error:*
> > > main.vala:99.13-99.24: error: missing generic type arguments
> > > Process return 256  execution time: 0.90 s
> >
> > I guess you have to make your declaration:
> >
> > private Gee.List pdfDocuments =
> >new Gee.ArrayList ();

How about:

var pdfDocuments = new Gee.ArrayList ();

Xav

___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Adding my custom object to libGee.List...

2010-06-21 Thread Arkadi Viner
I personally dislike the 'var' usage because it make the code harder to
understand.


On Mon, Jun 21, 2010 at 12:20 PM, Xavier Bestel wrote:

> On Sun, 2010-06-20 at 21:28 +0300, Arkadi Viner wrote:
> > Thanks, that did the trick.
> >
> > On Sun, Jun 20, 2010 at 5:02 AM, Didier 'Ptitjes' 
> wrote:
> >
> > > Hi,
> > >
> > > On 06/19/10 23:48, Arkadi Viner wrote:
> > > > *so, the declaration look like this:*
> > > >   private Gee.List pdfDocuments = new Gee.ArrayList ();
> > > >
> > > > *and when I try to add some thing to it:*
> > > > pdfDocuments.add(new
> PdfDocument(file_chooser.get_filename
> > > ());
> > > > *I get compilation error:*
> > > > main.vala:99.13-99.24: error: missing generic type arguments
> > > > Process return 256  execution time: 0.90 s
> > >
> > > I guess you have to make your declaration:
> > >
> > > private Gee.List pdfDocuments =
> > >new Gee.ArrayList ();
>
> How about:
>
> var pdfDocuments = new Gee.ArrayList ();
>
>Xav
>
>
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] GBinding support?

2010-06-21 Thread Fredderic Unpenstein
On 21 June 2010 01:57, Frederik  wrote:
> GLib/GObject 2.26 will add property binding [1]. The straightforward way to
> support this in Vala would be:
>  Object.bind_property (foo, "x", bar, "y");
>  Object.bind_property (foo, "x", bar, "y", BindingFlags.BIDIRECTIONAL);

Would foo.x.bind_property be a possibility?  And perhaps
bind_bidirectional or bind_with (do you bind anything else, other than
properties, on an object property?)...  Maybe then also bind_property
could become bind_to or something equaly less redundant?

Also, is there any way to get rid of the need for BindingFlags in
that?  If the argument IS a BindingFlags, Vala could include that
scope when looking up bare words...?


> However, this is not very type-safe. Would direct language support be
> reasonable? E.g. something like
>
>  foo.x +> bar.y;       // default
>  foo.x <+> bar.y;      // bidirectional
>
> Or is it too cryptic?

There's also := type notation, which fels like "more than assignment".
 Though since binding takes flags, I worry that it'll end up going the
same way as += for signal connection.

Personaly, I like the operators, but they're a little limited once you
add extra varients or options, as with the connect family.  Unless
some syntax is added for general operator functions...  eg:

   foo.x +> [BIDIRECTIONAL] bar.y;

which could also make += signal connection useful again.  Perhaps
adding support for a bracketed comma-separated list with the extra
arguments, instead.


> And how to deal with 'g_object_bind_property_full'? It takes two 
> TransformFuncs
> but only one user_data/GDestroyNotify pair.
>  (foo.x, celsius_to_fahrenheit) <+> (bar.y, fahrenheit_to_celsius);
>  (foo.x, (b, s, t) => { }) <+> (bar.y, (b, s, t) => { });

That's sort of what I was saying with bracketing above, too.  A
general syntax pattern like that might help with other places where
syntactic support would be useful but presently shunned.


Fredderic
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list