Hi again ! On Thu, Sep 23, 2010 at 09:19:55AM +0200, Axel Simon wrote: > Hi John, > > > ... consequently, I propose to patch glib/System/Glib/GValue.chs > > (or add a message in haddock warning against this edge case): > > > > Why can't you simply initialize the GValue *only* in the error case? > We could patch GValue but that means that your library will be > dependent on some future version of gtk.
This is what I was doing until now. It works well once you've understood the trick and, indeed, there is no real need to patch System.Glib.GValue.chs. Hum ... let's say that, at least, this bunch of mails will help gtk2hs newbies who might encounter this same behavior in the future :) > > I have successfully cast my object to the GObjectClass by copy-pasting > > samples of code I have found. Same for signals, they are working > > fine. ... except that I'm using plain vanilla c2hs with > > pre-compiled gtk2hs-0.10 packages :( > > > > This is bad. Signals.chs and Types.chs must be automatically > generated. I'm not sure how well the standard c2hs could work, but at > least dependencies are broken so that a project with several files > will not work. > > You will run into problems that certain pointers to and from C > functions are recognizes as the Haskell types they were declared as, I > think. I was afraid so :'( /me cabal install glib gtk gconf /me copy and past part of gconf configuration to xfconf /me pull his hair out seeing that gtk2hsC2hs is outdated and can neither handle inline "#include<foobar>" instructions, nor multiple headers files through the cabal 'x-c2hs-header' directive, nor some "do" construct syntaxes (explicit '{', ';', '}' are my friends !) [... 4 hours and one thunderstorm later ... ] /me launch his quickcheck tests with parallel threads and is happy to see that everything run smoothly ... except for System.Glib.UTFString.fromUTF which is not as good as the utf8-string package to process arbitrary strings generated by QuickCheck2. Aye ! Problem solved ! > >>> What if my reference to the XfconfChannel gobject is a "weak" > >>> reference ? Is there some special things to do, since I do not > >>> require a g_object_unref finalizer. > >> > >> At the moment, a Haskell handle to an object is a strong reference. > >> If it goes out of scope, then the reference counter of that object > >> is decremented. This scheme is a bit problematic since you can > >> create space leaks by creating closures that include these object > >> references and then attach these closures to callbacks from the same > >> object. We have not yet figured out a way to circumvent this > >> problem. The only way to get rid of an object is to explicitly > >> destroy it. > > > > I have tried to solve my weak-reference problem by artificially > > increasing the object reference with objectRef. If I've correctly > > read the glib documentation, this should do the trick. > > > > I don't follow. What problem do you want to solve? Do you have weak > references anywhere? > I may have confused "weak-reference" with what the xfconf documentation calls "singleton object". Here is the official C API: http://www.xfce.org/documentation/4.6/api/xfconf/xfconf-xfconf-channel.html#xfconf-channel-get One can read that xfconf_channel_get() returns a XfconfChannel* object which is owned by the daemon and should *NOT* be g_object_unref(), whereas xfconf_channel_new*() return normal GObjects. I have artificially objectRef my objects from channel_get() to use them with gtk2hs. So simple question : is this the "right" solution or should I simply dump channel_get() and only use channel_new() with gtk2hs ? (Yes I'm really a memory-leak maniac, that's why I insist on this pseudo-problem). All these things said, and apart from these last problems, my bindings begin to look really good, so many thanks for your patience and your help. regards, John ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Gtk2hs-devel mailing list Gtk2hs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel