Jared Moore wrote:
Thanks; I'd already read the online docs, I'd already read file:///usr/share/doc/libglib2.0-doc/glib/glib-Timers.htmlOn Thu, Jun 19, 2008 at 3:04 AM, Sam Liddicott <sam liddicott com> wrote:(Sorry for top posting - darn pocket outlook) I forgot to say thhat I need cancellable timers. (In case the user lets go of the button before the timer goes off). SamHave a look at the GLib documentation and you will see how to cancel a timer. I suggest installing Devhelp and the lib{gtk,glib}2.0-doc packages or their equivalent on your distribution. [1] http://library.gnome.org/devel/glib/ but the GTimer doesn't have any callbacks according to those docs. (Further, the warnings on g_timer_elapsed () giving wrong values seem bizarre) The biggest difficulty I have is working out how the various functionalities have been made available to vala, the various functions seem to be scattered in different classes and namespaces. glib.vapi has class TimeoutSource, namespace Timeout, class Timer. Namespace Timeout supports callbacks but being a namespace and not a class I couldn't mentally map from the vapi file to which part of glib it actually operates on. However I found the docs at: file:///usr/share/doc/libglib2.0-doc/glib/glib-The-Main-Event-Loop.html but they don't talk about how to cancel a timer so scheduled. So you may be right that it is actually a glib question and not a vala question, but not being fully familiar with the conversation from glib to namespaces and classes and static classes I couldn't tell. However, in following the glib docs, I'm guessing I can find out how g_main_context_find_source_by_id() is implemented in vala (looks like I need to find an instance of MainContext, (or rather whatever context Timout.Add was working on) and then convert the id returned by Timeout.Add into what vala calls Source, and then call whatever the g_source_remove function has become; but in the vapi file for public class Source, the remove function still takes a "uint id" which doesn't make sense as the id would be a property of the class. So now I wonder if I have confused my Id's somehow. So even following the docs, it's pain not clear how this maps to Vala, I certainly reckon there needs to be a method on the Timeout namespace to cancel a time based on that id, but as you see I can't yet make enough sense of the vapi to add this to the vapi. Sam |