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

Re: gEDA-dev: Hooking into selection changes



On Wednesday 09 August 2006 22:45, Ales Hvezda wrote:
> [snip]
>
> > - It's impossible to make my widget work properly, because I can't get
> > any sort of guarantee that the necessary callback function will be run
> > when it needs to be.
>
> 	So, you need to know when the selection changes, or when a specific
> object becomes selected/unselected?

When the selection changes.  My current implementation has 
a "selection-changed" event.  I'm thinking of making it pass the callback 
function a pointer to the object that was added/removed.

> >A fairly obvious solution would be to make SELECTION subclass GObject, and
> >then to make any function that modifies a selection list emit
> >a "selection-changed" signal on it.  Any callback functions could then be
> >registered using g_signal_connect() as appropriate.
> >
> >Anyway, since this would require *extensive* changes to libgeda and
> > gschem, I would of course like some indication that it's okay to go ahead
> > with it before ploughing in. :)
>
> 	I wouldn't be opposed to this, just as long as the overhead of
> subclassing GObject isn't through the roof.

Okay.  Actually, it looks like the change will be a positive one; counting the 
number of selected objects is now O(1), and that seems to make code that 
iterates over the selection list easier to understand.

At the moment I'm getting the GedaSelection object to encapsulate a GList (had 
to call it something other than SELECTION in order to find the breakage more 
easily).  It would be nice to have a way of getting an actual GList out of 
GedaSelection to make iterating over the lselection much faster, but then it 
would be possible for users of GedaSelection objects to make changes to the 
selection without firing off events.

Options:

 (a) Make a function that returns the actual backing GList.  This will be very 
fast, but users of the API will have to be trusted not to alter it.
 (b) Make a copy of the backing GList.  This will be *slightly* slower, but 
will be a lot 'safer'.

I'm leaning towards option (b), and I'll try and implement it later today.  
Hopefully I can get a working patch with these changes out.

Peter

-- 
Fisher Society publicity officer            http://tinyurl.com/o39w2
CUSBC novices, match and league secretary   http://tinyurl.com/mwrc9
Quake II build tools maintainer             http://tinyurl.com/fkldd

v2sw6YShw7$ln5pr6ck3ma8u6/8Lw3+2m0l7Ci6e4+8t4Eb8Aen5+6g6Pa2Xs5MSr5p4
  hackerkey.com

Attachment: pgpnna8Y4dDbT.pgp
Description: PGP signature


_______________________________________________
geda-dev mailing list
geda-dev@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev