more library structure
Chris Shoemaker
c.shoemaker at cox.net
Mon Jan 23 18:37:43 EST 2006
Aarrg!
The shutdown() function in gnucash-bin.c clearly doesn't belong
there. It's a C-implementation of the function that was getting
called from gnome-utils/gnc-gnome-utils.c:gnc_shutdown(). So, the
most obvious thing to do is replace gnc_shutdown() with it's
C-implementation.
But, of course, in guile it was using global state and through gwrap,
it had access to all the program state variables in gnome/top-level.c.
Note that src/gnome-utils doesn't depend on src/gnome. And there's
some comment saying that it shouldn't.
<side rant> BTW, the fact that you can just depend on all your
libraries being loaded by guile so that you can just say
scm_c_eval_string("blah") anytime and anywhere, even if it ends up
using a symbol in some library that's not in your LIBADD, is _bad_.
If you're going to pretend there's one global namespace why have
libraries at all? <end rant>
Ok, so src/gnome/top-level.c looks like a perfectly reasonable place
for gnc_shutdown, since all the initialization is right there and
there's high cohesion between all the init functions and the shutdown
functions. Problem: gnc_shutdown is used in 2 places in
src/gnome-utils - gnc-main-window.c (several times for all the cases
where we're exiting the gui) and druid_gconf_setup.c (where there
might be a more graceful way to exit the druid - not sure).
So, if we avoid just dropping to guile to jump from src/gnome-utils to
src/gnome, we need to decide where gnc_shutdown should live. I think
it's pretty clear it should live with all the init functions, but
where? I see a few options:
A) init/shutdown live in src/gnome:
1) Move gnc-main-window.c to src/gnome
2) Either move druid_gconf_setup.c to src/gnome or avoid the need to
shutdown.
B) move init/shutdown functions into src/gnome-utils.
1) That means pretty much all of the functions in top-level.c
2) It may be necessary to split gnc_gui_init into two parts - the
part that depends on other things in src/gnome and the lower-level
init part, and then move only the low-level part to src/gnome-utils
and call it from the part left in src/gnome.
C) remove/change the distintion between src/gnome and src/gnome-utils.
1) I was never clear on what the distinction was, anyway.
2) This could be a straight combination or a reshuffling along a
different boundary.
Any thoughts?
-chris
More information about the gnucash-devel
mailing list