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



Paolo Molaro wrote:
> 
> 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.
Fair comment, I guess that there will not be many other apps that know the 
C define but not the Perl/Gtk string.

> $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.
Yes, I was thinking of doing the $Gnome::Stock{'GNOME_STOCK_BUTTON_OK'} 
just once when I build the source code and thereafter using the looked up
string when the source was run, but I can see your point, it would be very
inefficient in any case but mine.

> Write a script that generates the hash table in the build process of
> the Glade module from the header file.
You are right, I guess that it would be better to search the header files
for each C define rather than generating a giant hash for every run. I will
have to see whether there would be savings if I generated a lookup module
in my Makefile.PL.

Thanks for your time, I will stop going on about this now :-)

Regards, Dermot




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