Re: (proposal for) source code generator



On Sat, 28 Jun 2008 14:32:02 +0200, Grischa Jacobs wrote:

> Amadeus W.M. wrote:
> <...>
>> To exemplify, suppose I have a trivial application with a top level
>> window with just a button in it that outputs "OK" to stdout when
>> clicked. That's the whole application. The gui part of the code for
>> this would be as follows:
>> 
>> 
>> class MainWindowGUI : public sigc::trackable {
> <...>
>> I don't know enough xml/xslt but I suspect this could be done by
>> creating an intelligent xslt file, say application.xsl, then generate
>> the code with an off-the-shelf xslt processor like so:
>> 
>> xsltproc application.xsl application.glade > MainWindowGUI.hh
>> 
>> Thus, one would not have to write massive amounts of code to parse the
>> xml .glade file and generate the C++ code from it. All that would need
>> to be written (not by me though) would be a one-time xslt file
>> (transform).
> 
> We're too using glade--, despite the claim that a majority of the
> developer would prefer libglade. Nice to see that I'm not the last of
> its kind. Just two questions.
> 
> I was wondering whether Gtk::Builder would be worth to look at. Its the
> proclaimed successor of libglade and seems to provide a similar
> functionality.
> 
> And, while looking at the code, why would you derive MainWindowGUI from
> sigc::trackable instead of Gtk::Window? While this could be easily
> changed in the xsl file to fit everyones personal preference, I was just
> wondering whether there is a specific reason.
> 
>> Would this be feasible? Any xml experts willing to try this?


Because the real main window comes out of refXml as a Gtk::Window *. That 
(and not MainWindowGUI) is the window that contains all the widgets and 
with all the properties you defined in glade. You don't have to pack the 
child widgets, nor to set properties of the window in your code (like 
glade-- does). I guess libglademm does that behind the scene when parsing 
the .glade file. Someone correct me if I'm wrong. At least the code I 
posted shows you don't have to pack the child widgets. 

Of course, you can derive MainWindowGUI from Gtk::Window, but it's not 
going to be the main window. To use the main window you still need to get 
it via refXml.




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