Re: adding & removing sources



Hi Jeroen,

On Mon, 2002-08-26 at 18:50, Jeroen Zwartepoorte wrote:
> Hi Gustavo (& others),
> 
> So i'm thinking about what it takes to get the functionality of adding &
> removing a source to a (automake/autoconf) project working.
> 
> From what i understand/remember, you implemented this when you rewrote
> the perl backend some months ago, right?

Yes, the code is there.  The test program in src/backends/libgbf_am
should remove and then add back a source from the project given in the
command line.

Beware, though, that the implementation is incomplete.  What's missing
is updating the project model after making a modification.  That was the
last thing I was working in gnome-build.  If you're going to implement
adding/removing in the widgets, then it's a great incentive for me to
continue working on the backend... at least the perl script :-)

Here a list of the things that need to be done wrt model updating:

- In the perl script, after writing the new file, reparse it's contents
and output the xml description for the changed group.

- In the C backend (gbf-am-project) read this output from the script and
process it with the parsing functions.  I made the script spawning more
flexible in my last changes, so this part should be relatively easy.  

- After processing, the backend needs to emit a signal so that all
interested parties know the model has changed and can reread the
modified group.  How this is done is not yet specified, but IIRC, jpr
told me we were suppossed to use the bonobo event source.  Is that
working in the glue implementation?

- Finally, the widgets must be able to handle this signal and update the
view accordingly.

Apart from that, the perl code still needs work.  Right now it only
works only for programs/libraries and in the simple case when the source
file is explicitly in the *_SOURCES variable (i.e. if the source is
substituted from another var, it can't handle it... and that needs
thinking).  Implementing other target types should be easy.

> Looking at the API (the uncommitted glue version) i see this:
> 
> 	const char * (*add_source)             (GbfProject *project,
> 						const char *target_id,
> 						const char *uri,
> 						GError    **error);
> 
> So basically, you need to tell the backend to which target you want to
> add a new source and the source uri. Now since how you configure a
> source differs between projects, there's a function in the backend for
> this:
> 
> 	GtkWidget * (*configure_new_source)    (GbfProject *project,
> 						GError    **error);
> 
> So far so good. Now for some questions :) :
 
Right :-)

> Do you have any idea what should go in the configure_new_source dialog?
> A target list where you select a target to which you want to add the
> source? Do we want some sanity checks so you can't add a C file to a
> "ui" target (xml only) for example?
 
Maybe configure_new_source should accept a target id, so the widget can
pass the currently selected target.  Even in this case, I think
presenting a target list would be very useful.  Sanity checks would be
great, but not in this early stage I think :-)

> When is a project "saved"? The Makefile.am needs to be updated first if
> you want to build a project after adding a new file. Is it possible to
> undo the add source action? (add a source first, don't save the project,
> exit anjuta2).

With the current architecture I think we can only offer instant apply
:-)  That's because we need to reparse the Makefile.am after writing the
modifications.  And given the complexity of the automake system, I doubt
we can do better, at least not without a lot of work (think variable
substitutions, conditionals, etc.).  Right now, the old Makefile.am is
saved with the .bak suffix.  But of course this provides just one level
of undo.

> What if a user wants to (implicitly) create a new target? Say the user
> wants to create a test.c file and there's no test target yet? How does
> that translate to a user action?

IMO, configure_new_target should allow the initial addition of a source
file.  There certainly needs to be some interaction between document
manager actions (e.g. New File) and the project manager, but I haven't
thought about it.

> What happens when a user removes a source and there's no more sources in
> the target left? Does the target get removed implicitly?

Automake targets can be empty.  Probably asking the user for
confirmation would be the way to go here.

> A lot of questions, but i'm trying to figure out what's needed to get it
> all to work :)

Great!  You can count on me.  And poke me if I get lazy again :-) 
Sometimes I need a bit of that, if you know what I mean.

Cheers,
Gustavo





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