[Vala] maemo5 hildon input mode

2010-02-08 Thread Martin DeMello
I'm trying to disable Maemo's autocapitalisation in a Gtk.Entry field.
Maemo 5 adds a "hildon-input-mode" property to Gtk.Entry [
http://maemo.org/api_refs/5.0/5.0-final/gtk/GtkEntry.html], but I
can't find any way to access it from Vala, either from a Gtk.Entry or
a Hildon.Entry.

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


Re: [Vala] maemo5 hildon input mode

2010-02-08 Thread Martin DeMello
2010/2/8 Jiří Zárevúcky :
> Martin DeMello píše v Po 08. 02. 2010 v 22:26 +0530:
>> I'm trying to disable Maemo's autocapitalisation in a Gtk.Entry field.
>> Maemo 5 adds a "hildon-input-mode" property to Gtk.Entry [
>> http://maemo.org/api_refs/5.0/5.0-final/gtk/GtkEntry.html], but I
>> can't find any way to access it from Vala, either from a Gtk.Entry or
>> a Hildon.Entry.
>
> You can try using this method:
>
> http://www.valadoc.org/gobject-2.0/GLib.Object.get.html

Thanks, that worked beautifully. For anyone googling this up, the exact code is:

 var input  = new Hildon.Entry (Hildon.SizeType.AUTO);
 input.set("hildon-input-mode", Hildon.GtkInputMode.FULL);
 // refer to hildon-1.vapi for the full enum

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


[Vala] using libgee from c

2010-02-12 Thread Martin DeMello
Other than reading gee.h directly, is there any documentation on the C
api to libgee?

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


[Vala] sorted keys from a hash

2010-02-12 Thread Martin DeMello
What's the most efficient (in terms of speed) way to iterate over a
hash in sorted order of the keys? The keys are strings.

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


Re: [Vala] sorted keys from a hash

2010-02-13 Thread Martin DeMello
On Sat, Feb 13, 2010 at 3:39 AM, Jan Hudec  wrote:
> On Sat, Feb 13, 2010 at 02:54:21 +0530, Martin DeMello wrote:
>> What's the most efficient (in terms of speed) way to iterate over a
>> hash in sorted order of the keys? The keys are strings.
>
> To use a balanced tree.
>
> Hash can only ever be iterated in the hash order, which is fixed but
> pseudo-random.

Well, here's my exact problem: I have a TreeMap that I add (string,
string) pairs to. The desired output is a sorted list of these pairs.
Now I'm wondering if it'd be more efficient to use a HashMap instead,
since I don't really need to maintain the sorted property as the list
is built up, just have it sorted when I return it. Roughly, I want

for i in map.keys.sort() {
  retval.append (i, map[i])
}

return retval

except I've been through the API and I can't find a good way to sort
the keys, or to push the pairs into a list and sort the list.

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


Re: [Vala] An elegant way to concatenate integers into a string.

2010-06-24 Thread Martin DeMello
On Tue, Jun 15, 2010 at 6:17 AM, Celil  wrote:
> I would like to translate the following python code snippet to vala:
>
>        x = [1,2,3]
>        print ",".join(map(str, x))
>
> So far I have this:
>
>        int[] x = {1,2,3};
>        string[] y = {};
>        foreach (var e in x) { y += e.to_string(); }
>        stdout.printf(string.joinv(",", y));
>
> Is there a better way to do this? Dose vala support something equivalent
> to the python built-in `map` function?

Good question; I went through the Vala docs and couldn't find a nice
way either. Might be worth porting Ruby's Enumberable module to Vala.

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


Re: [Vala] Graphic toolkits for Vala?

2010-07-06 Thread Martin DeMello
On Sat, Jul 3, 2010 at 2:32 AM, CaStarCo  wrote:
> Thanks to all :) ,
>
> now i'm trying to decide if is better to use some web system such as webkit
> or to use something like clutter because it's more orientated to graphics
> than webkit...
>
> probably i'll take the webkit option because it will help me to extend the
> application to the web later.

Could you post an announcement to the list when you have something up?
I'd love to keep an eye on this.

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


Re: [Vala] Graphic toolkits for Vala?

2010-07-06 Thread Martin DeMello
On Sat, Jul 3, 2010 at 2:14 AM, Martin Olsson  wrote:
> Checkout all the ones listed on this page:
> http://live.gnome.org/ProjectRidley/CanvasOverview
>
> Also take a moment a serious consider doing it using
> open web standards rendered via a WebKit webview
> or similar (inside you can use SVG or HTML Canvas etc).
> The benefit of this is that you can probably deliver
> your app both as a webapp and a rich client app.
> The rich client version will of course have better
> desktop integration etc which is nice sometimes but
> on the go you can use the web app instead.

Is it possible to render an svg image into a webkit canvas and
receiving click/drag events on it from vala? Could someone post a
quick example if so? The available documentation is rather thin on the
ground.

martin

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


[Vala] Why no functions returning lists in libgee?

2010-07-12 Thread Martin DeMello
How come libgee doesn't have any functions that return new lists (in
particular list.map() and list.filter())? Is it to avoid allocation?
I've been looking at porting ruby's Enumerable module to vala, but I
thought I'd check first as to why it isn't there already, and if this
sort of thing is for some reason a bad idea.

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


Re: [Vala] information on dova

2010-07-22 Thread Martin DeMello
On Wed, Jul 21, 2010 at 7:21 PM, Abderrahim Kitouni  wrote:
> Hi,
> في ر، 21-07-2010 عند 14:51 +0200 ، كتب andi:
>> Hi list,
>> I was wondering if anyone could give me or point me at some information
>> on dova and its aims. I've been googling for quite some time now and
>> read a bit of code in the gitorous repo. Of course, I also found the
>> page on live.gnome.org.

> Its aim is mainly to have vala without the quirks and limitations of
> GObject. Vala with dova should be closer to Java and C# than now (but
> it'll still be better ;-))

How will that affect the writing of gtk and gnome apps?

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


[Vala] valasemanticanalyzer error

2010-08-17 Thread Martin DeMello
What do I need to do to get the following code to compile? It dies with

$ valac --pkg gee-1.0 test.vala
**
ERROR:valasemanticanalyzer.c:2948:vala_semantic_analyzer_get_actual_type:
assertion failed: (instance_type != NULL)
Aborted


# ---
using Gee;

public interface Enumerable : Iterable {

public delegate T DFunc(G elem);

public void map(DFunc fn, Gee.List acc) {
foreach (G i in this) {
acc.add(fn(i));
}
}
}

public class EnumerableList : Gee.ArrayList, Enumerable {
}

public static int main(string[] args) {
var a = new EnumerableList ();
a.add(1);
a.add(2);
a.add(3);
var b = new Gee.ArrayList ();
a.map( (i) => { return "%d".printf(i); }, b);
foreach (string i in b) {
println(i);
}

return 0;
}

#


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


Re: [Vala] valasemanticanalyzer error

2010-08-19 Thread Martin DeMello
Note also that this dies in a different place in 0.92 (last tagged
release before the "generic delegates support" feature):

$ valac --pkg gee-1.0 test.vala
test.vala:23.37-23.37: error: Argument 1: Cannot convert from `G' to `int'
a.map( (i) => { return "%d".printf(i); }, b);
   ^
Compilation failed: 1 error(s), 0 warning(s)

martin

On Tue, Aug 17, 2010 at 6:09 PM, Martin DeMello  wrote:
> What do I need to do to get the following code to compile? It dies with
>
> $ valac --pkg gee-1.0 test.vala
> **
> ERROR:valasemanticanalyzer.c:2948:vala_semantic_analyzer_get_actual_type:
> assertion failed: (instance_type != NULL)
> Aborted
>
>
> # ---
> using Gee;
>
> public interface Enumerable : Iterable {
>
>        public delegate T DFunc(G elem);
>
>        public void map(DFunc fn, Gee.List acc) {
>                foreach (G i in this) {
>                        acc.add(fn(i));
>                }
>        }
> }
>
> public class EnumerableList : Gee.ArrayList, Enumerable {
> }
>
> public static int main(string[] args) {
>        var a = new EnumerableList ();
>        a.add(1);
>        a.add(2);
>        a.add(3);
>        var b = new Gee.ArrayList ();
>        a.map( (i) => { return "%d".printf(i); }, b);
>        foreach (string i in b) {
>                println(i);
>        }
>
>        return 0;
> }
>
> #
>
>
> martin
>
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] valasemanticanalyzer error

2010-08-19 Thread Martin DeMello
On Thu, Aug 19, 2010 at 6:39 PM, Jürg Billeter  wrote:
> On Tue, 2010-08-17 at 18:09 +0530, Martin DeMello wrote:
>> public interface Enumerable : Iterable {
>>
>>       public delegate T DFunc(G elem);
>>
>>       public void map(DFunc fn, Gee.List acc) {
>>               foreach (G i in this) {
>>                       acc.add(fn(i));
>>               }
>>       }
>> }
>
> This is invalid code. Inner types don't have access to generic type
> parameters of outer types. So you probably want something as follows:
>
> public interface Enumerable : Iterable {
>
>        public delegate T DFunc(G elem);
>        [...]
> }

Okay, I made that change, and now I'm getting the same error that .92 gives:

test.vala:23.37-23.37: error: Argument 1: Cannot convert from `G' to `int'
a.map( (i) => { return "%d".printf(i); }, b);
   ^
i.e. it cannot infer the type of i even though a is of type
EnumerableList

Also, does "support for generic delegates" mean that I will ultimately
be able to specialise the delegate function when I call it? Something
like this at the least, though anonymous function support would be
nice:

using Gee;

public interface Enumerable : Iterable {

public delegate T DFunc(G elem);

public void map(DFunc fn, Gee.List acc) {
foreach (G i in this) {
acc.add(fn(i));  // <--  error: missing generic type 
arguments
}
}
}

public class EnumerableList : Gee.ArrayList, Enumerable {
}

public string f(int i) {
return "%d".printf(i);
}

public static int main(string[] args) {
var a = new EnumerableList ();
a.add(1);
a.add(2);
a.add(3);
var b = new Gee.ArrayList ();
a.map((Enumerable.DFunc) f , b);
foreach (string i in b) {
stdout.printf("-- %s --\n", i);
}

return 0;
}

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


Re: [Vala] valasemanticanalyzer error

2010-08-20 Thread Martin DeMello
On Fri, Aug 20, 2010 at 2:55 PM, Abderrahim KITOUNI  wrote:
>
> shouldn't it be Iterable?

Thanks, that got the basic proof of concept working. Now the issue is,
I want to write a generic map function whose output type should not
need to be encoded in the Enumerable type.

using Gee;

public interface Enumerable : Iterable {
  public delegate O DFunc(I elem);

  public void map(DFunc fn, Gee.List acc) {
foreach (G i in this) {
  acc.add(fn(i));
}
  }
}

public class EnumerableList : Gee.ArrayList, Enumerable {
}

public string f(int i) {
  return "%d".printf(i);
}

public static int main(string[] args) {
  var a = new EnumerableList ();
  a.add(1);
  a.add(2);
  a.add(3);
  var b = new Gee.ArrayList ();
  a.map((Enumerable.DFunc) f , b);
  foreach (string i in b) {
stdout.printf("-- %s --\n", i);
  }

  return 0;
}


The strange bit is that the acc.add(fn(i)); line complains

test1.vala:8.7-8.9: error: missing generic type arguments
  acc.add(fn(i));
  ^^^

even though I'd expect acc to be well typed (I've declared it using

  var b = new Gee.ArrayList ();

and should be able to use it via Gee.List, no?)

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


Re: [Vala] valasemanticanalyzer error

2010-08-20 Thread Martin DeMello
On Fri, Aug 20, 2010 at 5:47 PM, Andrea Del Signore  wrote:
>
> the only error I can spot is here:
>>
>>   public void map(DFunc fn, Gee.List acc) {
>
> should be:
>
> public void map(DFunc fn, Gee.List acc)

No, it is a list of the target type, not the source type.

> I really don't understand what are you trying to do can you explain to
> me? Thanks.

I'm trying to write a generic map function that consumes a list and
emits a transformed list. If I have two lists

a = List // full
b = List // empty

and a function

target_type fn(source_type)

I should be able to write

a.map(fn, b)

And b[i] should be fn(a[i]) for all i in a's indices.

martin




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


Re: [Vala] valasemanticanalyzer error

2010-08-20 Thread Martin DeMello
On Fri, Aug 20, 2010 at 7:26 PM, Andrea Del Signore  wrote:
>
> Thanks for the explanation but I can't really imagine any other way of
> doing this without specializing the map method, because I don't see
> implemented any "standard" (non generic) IList interface in gee.
>
> So:
>
> public void map(DFunc fn, Gee.List acc) { ... }
>
> and then
>
> a.map((Enumerable.DFunc) f , b);

Thanks! I didn't know you could have generic *methods* - is that
documented anywhere? Not as clean as I'd hoped for, but it's
definitely better than not being able to do it at all. Is there any
way I can replace `f` in the above code with an anonymous lambda?

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


Re: [Vala] valasemanticanalyzer error

2010-08-20 Thread Martin DeMello
On Fri, Aug 20, 2010 at 8:06 PM, Andrea Del Signore  wrote:
>
> If you want to use a lambda this is what I came with (see the map
> function):
>
>  public void map(DFunc fn, Gee.List acc) {
>    foreach (G i in this) {
>      acc.add(fn(i));
>    }
>  }


Beautiful, thanks :)

martin

> }
>
> public class EnumerableList : Gee.ArrayList, Enumerable {
> }
>
> public string f(int i) {
>  return "%d".printf(i);
> }
>
> public static int main(string[] args) {
>  var a = new EnumerableList ();
>  a.add(1);
>  a.add(2);
>  a.add(3);
>  var b = new Gee.ArrayList ();
>  a.map(f , b);
>  foreach (string i in b) {
>    stdout.printf("-- %s --\n", i);
>  }
>  b.clear ();
>  //using a lambda
>  a.map((i) => { return "result: %d".printf (i); } , b);
>  foreach (string i in b) {
>    stdout.printf("-- %s --\n", i);
>  }
>
>  return 0;
> }
>
> HTH,
>        Andrea
>
>
>
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list