Re: menuitem activate



On Wed, May 23, 2007 at 03:00:03PM -0400, danielg Posting wrote:

It could look like:

  dv = ... set up the dir view ...
  /* And here comes your part */
  setup_notify(dv, &refresh_me);

Okay, I understand the setup_notify and the dv there, what's the refresh_me
for (do?) or is that just another call to the function you have listed below?

The function that refreshes the tree is static and therefore
probably not visible in the notification code, therefore you
have to pass the notification code something to call:
pointer to the function.  Even if it is visible, passing
a callback reduces the entanglement of your spaghetti...

What would the call to create the setup_notify be?  I'm already using 

int change_notification(void)

So, that would be 

int change_notification (dv, &handler)
{
 DirView *dv;
 struct sigaction act;
 int fd;
(...)

Something similar.  Of course you won't have a local
variable dv shadowing the argument there, you will keep [the
list of] active DirView[s] either in some file-scoped static
variable or a static variable in some function managing the
list...

and above that would be:

static void handler(int sig, siginfo_t *si, void *data, DirectoryView *dv)
{
        event_fd = si->si_fd;
        cb_refresh_dir_tree(dv, NULL);
}

I'm getting lost here as I don't know anything about the
structure of the application (aside from what I have infered
from your e-mails) and don't recall anything about
dnotify().  So, perhaps maybe.

So, this is where I need to put the listener (dnotify())?  I would like this
to go on the entire run of the program.  I guess, what's the "destroy" for?

This was the `I don't know what the lifetime rules' part.

The dnotify() handler has to know whether there's something
to refresh.  If the directory view is destroyed it will
segfault trying to refresh it.  And even if the directory
view exists during the whole lifetime of the program,
there's still a small window between the shutdown of the GUI
(when the directory view widget is destroyed) and the actual
end of the program.

So it has to keep track of active DirView[s], somehow.
I just suggested one method.

Yeti

--
http://gwyddion.net/



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