[Glade-devel] Source code generation

On Tue, 17 Oct 2006 09:40:57 -0400
Tristan Van Berkom <tvb at gnome.org> wrote:

Magnus Bergman wrote:
I guess this has been brought up many times before, but I'm new to
this list and missed the discussions.

What I wonder is why source code generation is deprecated? Is it
just that the code in glade was deprecated (not up to date and not
maintained perhaps) or is the whole idea of generating code
considered deprecated? I think it's nice. But would really prefer
to have a command line tool to do the job (so I actually have
nothing against it being removed from glade). Is there any reason
why I shouldn't get going and create such a tool right away?

   Historically - people have generally found it much easier to
maintain a project that loads a glade file than a project that
uses generates sources - mostly because of the pain of merging
sources every time the UI might change, using libglade removes
this stubmling block from your work and additionally gives you
a dynamic UI that can be modified without recompiling your app.

Yes, I agree that using a GUI to create the source code is not optimal.
(But what's the merging about, I never needed to do that?) That's why I
thought about creating a command line tool to begin with. So that the
code generation could be taken care of by the Makefile. To me the glade
file is just another source file. And if you change a source file you
have to recompile (if you don't use an interpreted language but that's
another story). Maybe that's just because I'm the kind of guy who likes
to generate source files from graphics and all sorts of data files.

Glade 3 was designed to externalize the task of code generation
(as it has a modular design it should do as little as possible
outside of creating glade files - it should create glade files
_well_), it was planned that "if people want code generation -
they can generate code from glade files".

I think that was a very good decision. But no such tool is created or
even planned (by the Glade project that is), right? I found some old
tool called g2c. But it was abandoned long ago (before it was finished I
assume) and it doesn't seem to be compatible with how Glade 2 works. (I
tried to get in contact with the developer but haven't got any

That being said; I personally dont think it wise to encourage
people to use generated source files in thier project, when all
that generated code can be replaced by 3 or 4 lines of libglade
code and a glade file.

I don't see why anybody need to care about the generated source files.
And there is no reason why calling generated code should require more
than 3 or 4 lines either.

Why not talk to the Anjuta folks about this ?

I will. (But I have no experience with Anjuta so I might not understand
the details of how this affects it).

... generating code for signal callbacks from an ide could be
cool right ?

I don't completely understand your idea. You mean jumping from a widget
in the GUI designer to its signal handlers in the source code editor? If
so, I don't really get how the command line utility I have in mind
could be of any help.

My 2 cents on the issue also is - if there is to be code generation
at all, there should be some kind of unified api - maybe code
generators should be plugins to an IDE, maybe the IDE should be able
to use the same semantics to generate "creation code"/"signal callback
code" for both the C# and python (and other...) generators.

My idea for how it should work is simple, you just put this in the
Makefile and it does the same thing Glade 2 does then telling it to
generate source code:

interface.c interface.h and some other stuff...: %.glade
        glade2c $<

To create some window you call create_some_window() and to get other
widgets you call lookup_widget(), just as usual for compatibility. If
someone has other ideas, then I'm interested in hearing them. Sure it
could be extended to generate code for other languages too, but right
now I'm focusing on C (since it's the language I personally prefer).

I don't understand your idea with IDE plugins either. For generating the
code the IDE just has to call make, right? I guess it's something else
than what I have in mind. But it sounds interesting. If I have a look
at Anjuta and libglade perhaps I'll understand.


/me is getting the hang of answering this one ;-)

Thanks for the answer. And since I'm not discouraged to create this
glade2c tool yet, I will probably proceed with my plans soon.

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