From: Joshua B. <jos...@gm...> - 2011-05-29 14:25:19
|
Hi Axel, Thanks so much for the reply. That is exactly what I was looking for. I don't think the string argument is necessary, though. (Maybe it used to be?) It looks like the current implementation generates a unique attribute name from a global mvar (uniqueCnt), so I can use objectCreateAttribute without any arguments. Josh "Ua" Ball On Sun, May 29, 2011 at 1:56 AM, Axel Simon <Axe...@in...> wrote: > Hi Josh, > > indeed, there are ways to set and get arbitrary Haskell attributes on an > Object. It's still a bit hacky. The way it works is that you do a > > myAttribute :: Attr Widget Foo > myAttribute = unsafePerformIO $ objectCreateAttribute "myAttribute" > > somewhere in your project and then use 'set' and 'get' on this object. > You can put in something more specific than Widget to make to compiler > bark if you try to use the wrong object. You need the type signature > since otherwise you could set a Foo and read back a Bar and get foobar'd > (as in run-time crash because of using one type as another). > > Cheers, > Axel > > > On 29.05.11 07:24, Joshua Ball wrote: >> Hi, >> >> What's the recommended strategy for attaching hidden information to a >> child of a notebook? >> >> For example, if I'm creating a gedit clone, then I want to track the >> "current file" with each child tab of the notebook. Where do I store >> the current file info? >> >> Maintaining a map from ints to objects is not very workable - you have >> to track the pageAdded, pageRemoved, and pageReordered events and >> re-organize the map every one of those fires. >> >> Another option is to serialize the information into a hidden control >> somewhere in the child of the notebook, but that seems very hackish. >> And besides, it doesn't work well for things that don't serialize, >> like mvars. >> >> Thoughts? Surely this has been solved many times over, and I'm just >> missing the obvious solution. >> >> Josh "Ua" Ball >> >> ------------------------------------------------------------------------------ >> vRanger cuts backup time in half-while increasing security. >> With the market-leading solution for virtual backup and recovery, >> you get blazing-fast, flexible, and affordable data protection. >> Download your free trial now. >> http://p.sf.net/sfu/quest-d2dcopy1 >> _______________________________________________ >> Gtk2hs-users mailing list >> Gtk...@li... >> https://lists.sourceforge.net/lists/listinfo/gtk2hs-users > > > ------------------------------------------------------------------------------ > vRanger cuts backup time in half-while increasing security. > With the market-leading solution for virtual backup and recovery, > you get blazing-fast, flexible, and affordable data protection. > Download your free trial now. > http://p.sf.net/sfu/quest-d2dcopy1 > _______________________________________________ > Gtk2hs-users mailing list > Gtk...@li... > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users > -- Borrow my books: http://goo.gl/UBbSH |