Re: [Vala] Setting up a timer with callback event



My code doesn't compile and the problem is:

main.vala:77.10-77.19: error: syntax error, expected `('
<b>Process return 256  execution time: 0.729512 s</b>

and it points on the lines:
public delegate bool
<http://references.valadoc.org/glib-2.0/bool.html>SourceFunc
(){

return true;
}

I don't sure what is 'delegate' for but I tried to look for the correct
callback function for a timer
in valadoc and I found:
http://references.valadoc.org/glib-2.0/GLib.SourceFunc.html
It looks like this:
"public delegate bool
<http://references.valadoc.org/glib-2.0/bool.html>SourceFunc
();"
so, that's why I have wrote "delegate" for....
So I don't need this "delegate" in my code ?


My code is very large and because of that, I don't think it will be a good
idea to post it here...
I have posted here just a basic structure of my program so somebody could
tell me how
to implement a timer in a correct way.
If some body could just post me some simple example of a timer with a
callback function, that would be really great...



2009/8/19 Jan Hudec <bulb ucw cz>

Hello,

On 19 August 2009, 14:24, Arkadi Viner wrote:
I want to write some animation in my program.
I want to be able to activate it or cancel it where ever I want.
My basic program structure looks like this:

You should describe your status if you want to get useful advice. Like
mention what is failing.

using Gtk;

public class MyApp {
[...]
}

//This should activate the timer.
  [CCode (instance_pos = -1)]

It must be an instance method to have an instance pos. So it must be inside
the class.

  public void on_btnActivate_clicked (Button source) {
[...]

//Timer listener
[CCode (instance_pos = -1)]
public delegate bool SourceFunc ()

This makes no sense. 'delegate' defines a delegate *type*, but you are
defining a function here.

Oh, and you don't need instance_pos = -1 when you connect things yourself,
because vala will create appropriate wrapper automatically. It is only
needed
for the Builder.connect case, where it cannot know to create them.

I need help to fix this code so I can setup a timer properly....
I don't sure what is wrong with my code....

It's hard to help you when you didn't write whether you have compilation
problems, or wheter Gtk.Builder is complaining that it cannot connect
something or what.

--
                                       - Jan Hudec <bulb ucw cz>





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]