[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [LGI] generic question about access to methods
- From: Pavel Holejsovsky <pavel.holejsovsky@...>
- Date: Thu, 22 Nov 2012 16:50:46 +0100
Hi Laurent,
On 11/21/12 6:04 PM, Laurent FAILLIE wrote:
But I'm lost with methods calls :I'm trying to use GLib's KeyFile to
store / retrieve the configuration and I found
load_from_file methods and its C definition
:http://developer.gnome.org/glib/2.32/glib-Key-value-file-parser.html#g-key-file-load-from-file
But I didn't find the way to convert this C interface to Lua/Lgi one.
My code is the following :
cfg_filename = GLib.get_user_config_dir() .. "/IMAPNotifyMe.conf"
local config = GLib.KeyFile
config:load_from_file( cfg_filename )
Two problems here:
1) You are assigning GLib.KeyFile type to 'config' variable, instead of
creating GLib.KeyFile instance. Use local config = GLib.KeyFile() instead.
2) It will still not work, it will crash instead. GKeyFile is an
ancient API, and it is not introspection-friendly, because it is neither
GObject-based object nor GBoxed struct - this means that introspection
clients do not know how to handle lifetime of this object.
It is possible (and now already quite easy) to implement workaround in
LGI for this. From fast skimming KeyFile API, I can see that there will
be other problems (some methods with array arguments seem to be missing
annotations). I'll try to get to it in a few days and will let you know
if something usable came out of this attempt.
Sorry for not so good news,
Pavel