Glade/Gtk-- design proposals (longish)



Hello Damon,
Hi People on the Gtk list,

Yesterday I told Damon, that I can't wait to see glade output a source
file. I offered doing the gtk-- wrapper for glade.

So here are the design proposals - please comment (so they can improve)

glade2cxx might be or not be a seperate program: (+ pro / - con)
+ a decent C++ class hirarchy (with STL) can be used to parse the glade
file and produce output.
+ Flexible, up to date (STL), easy to extend,
- code duplication (the methods to read XML and write C code are also in
gbfoo.c). They need adaption, though they should not share too much
(classes are a different concept).
+ both projects can grow independant of each other (changing one doesn't
necessarily involve the other)
+ small, pure C++ design
- you need to write 'source writers' again
+ you might even implement it in perl (if I only had knowledge of it ...
;-))

I tend to make it a seperate beast.



Tunable parameters:
- prefix/postfix etc : Widget name to class (type), instance (variable),
file name mapping
- maximum number of widgets in containing class / maximum level of
widgets
- maximum number of classes in one source file / maximum level
- maximum number of widgets in one continuous memory block / depth (then
outsource to pointers, see below)
    ( this is currently limited with egcs/gcc2.7/gcc2.8 and gtk-- !!! )


Widget structure
foo - some
    + children
    + of        + ....
    + this
    + widget
Output file:
// Header file Foo.h

#include <gtk--/somewhat.h>  // e.g. label.h
#include "Of.h"

class Foo:Container_Type {
    Some some;  // e.g. Some=Gtk_Label
    Children children;
    Of [*]of;
    This this;
    Widget widget;
    [perhaps user variables]
public:
    Foo();
    [~Foo();]
    [perhaps function objects (Signal/connect)]
};


// Definition file Foo.c

#include "Foo.h"

Foo::Foo([perhaps parameters]) :
    some(par), this(par,par,par)
{   add(&some);
    some.configure_it(par);
    some.show();
    add(children);
    ...
    of = new Of(par);
    add(of);
    of->configure_it(par);
    of->show();
}


So we have three functions to provide for each widget type:
   deklaration
   construction
   configuration




Data structures in my mind:
class Tag {
    string type;
    string value;
    vector <Tag> sub_specifications;
};

class Writer {
    bool (*declare)(ostream&,const Tag&);
    bool (*construct)(ostream&,const Tag&);
    bool (*configure)(ostream&,const Tag&);
};
// needed for each Widget type


Now to the interesting point:
I would like to propose a parametrized substructure:
Think for example of a HBox with a Label(parameter) and an Entry.
This is a common substructure, you might indicate it like
<Widget>
   ...
   <Parameters>%text</Parameters>
   <Widget>
       <Label>%text</Label>
   </Widget>
</Widget>
and use this compound widget like any other.

But Damon, please wait to include this feature until glade successfully
saves C code.


Your comments please
         Christof




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