Please create an account to participate in the Slashdot moderation system


Forgot your password?
User Journal

Journal e8johan's Journal: GTK+ - Gt Automagic Conversion - Alpha Testing

I've actually tried my huge Perl hack to see if I can produce any good C++ files. There have been some minor hickups, as expected, but nothing major. The only big headache for the moment is constructor resolving.

For example the gtk_button class (GButton in Gt) has two constructors (well, three, but two automagically detected): gtk_button_with_label and gtk_button_with_mnemonic. The problem is that both accepts a string as the 'additional' parameter, i.e. I've got two identical constructors doing different thing. This is however easily resolved as the _mnemonic version simply is a cooler (more features) version of the _label version. Thus, I have to resolve this by removing one of them.

Some thoughts halfway though the project. It seems like everything aught to work. In order to make the automagical conversion tool work with new versions, I need to be able to fix small problems and store the fix somehow. This is to avoid having to do the same adjustments over and over again.

As for the resulting code, you can always enjoy this. (Notice that this is still in alpha version, so not much is working yet...) The types of the properties is also missing (not retrieved by the script yet) but it is a quick hack to get it working. As for all the macros, yes, the pre-processor will be heavily utilized to avoid the need of a moc, but I don't know how far one can go with this solution.

The editor ate my tabs. The code will be neatly indented!

--- HEADER ---

#ifndef GBUTTON_H
#define GBUTTON_H

#include "gtmain.h"
#include "gbin.h"

// The GButton class
// Wraps GtkButton
class GButton : public GBin
GSLOT( activate )
GSLOT( clicked )
GSLOT( enter )
GSLOT( leave )
GSLOT( pressed )
GSLOT( released )

// Constructors
GButton( GWidget *parent=0, char *name=0 );
GButton( <typ> label, GWidget *parent=0, char *name=0 );
GButton( <typ> mnemonic, GWidget *parent=0, char *name=0 );

// Slots
virtual void activate( void );
virtual void clicked( void );
virtual void enter( void );
virtual void leave( void );
virtual void pressed( void );
virtual void released( void );

// Properties (first set, then get)
void setRelief( <typ> )
void setLabel( <typ> )
void setUse_stock( <typ> )
void setUse_underline( <typ> )

<typ> relief( void );
<typ> label( void );
<typ> use_stock( void );
<typ> use_underline( void );

--- BODY ---
#include "gbutton.h"


GButton::GButton( GWidget *parent=0, char *name=0 )
this_widget = gtk_button_new();

GButton::GButton( <typ> label, GWidget *parent=0, char *name=0 )
this_widget = gtk_button_new_with_label( label );

GButton::GButton( <typ> mnemonic, GWidget *parent=0, char *name=0 )
this_widget = gtk_button_new_with_mnemonic( mnemonic );

virtual void GButton::activate( void )

virtual void GButton::clicked( void )

virtual void GButton::enter( void )

virtual void GButton::leave( void )

virtual void GButton::pressed( void )

virtual void GButton::released( void )

void GButton::setRelief( <typ> value )
gtk_button_set_relief( this_widget, value );

void GButton::setLabel( <typ> value )
gtk_button_set_label( this_widget, value );

void GButton::setUse_stock( <typ> value )
gtk_button_set_use_stock( this_widget, value );

void GButton::setUse_underline( <typ> value )
gtk_button_set_use_underline( this_widget, value );

<typ> GButton::relief( void )
return gtk_button_get_relief( this_widget );

<typ> GButton::label( void )
return gtk_button_get_label( this_widget );

<typ> GButton::use_stock( void )
return gtk_button_get_use_stock( this_widget );

<typ> GButton::use_underline( void )
return gtk_button_get_use_underline( this_widget );

This discussion has been archived. No new comments can be posted.

GTK+ - Gt Automagic Conversion - Alpha Testing

Comments Filter:

Testing can show the presense of bugs, but not their absence. -- Dijkstra