Re: [gtk-list] Re: Perl/Gtk CVS 19990914



On Thu, Sep 23, 1999 at 04:29:57PM +0000, Dermot Musgrove wrote:
> My problem is that I am converting from the C constants (eg 
> 'GNOME_STOCK_BUTTON_OK'  to "Button_Ok") on the fly. I can't see an easy
> and reliable way to do the conversion without a lookup, especially when
> sometimes underlines translate to spaces and 'OK' translates to 'Ok'.

We could build an hash table that maps the C define to the string, but is 
this hash table useful for programs other then yours? I think it's not.
Let's see.
Now:

$stock = Gnome::Stock->button('Button_Ok');

Alternative:

$stock = Gnome::Stock->button($Gnome::Stock{'GNOME_STOCK_BUTTON_OK'});

Note that you have to lookup both Button_Ok and GNOME_STOCK_BUTTON_OK
int the c header file.

> I have cut-and-pasted the header #defines into my module but I will have the
> same problems as Perl/Gtk when they change. This was why I asked about a
> Gtk::Enums and Gnome::Enums package that could be generated from the header
> files when Perl/Gtk was built. 

Write a script that generates the hash table in the build process of
the Glade module from the header file.

lupus



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