Re: [RFC] export TRUE and FALSE from someplace



On Wednesday, January 21, 2004, at 05:58 AM, Thierry Vignaud wrote:

"muppet" <scott asofyet org> writes:

  use constant GTK_STOCK_OK => 'gtk-ok';

one thing that can keep you guessing is the rules for translating
stock macros to strings...

for stock icons, both forms directly came from gtk+ headers, the later
being quite a lot more readable, hence i do not see any interest in
exporting GTK_STOCK_* constants.

they would have to be generated from a header, and thus most conveniently available in a separate module, loaded only if you want them -- like the Keysyms and Pango constants.

  sub make_dialog {
      use Gtk2::Stock;
      my $dialog = Gtk2::Dialog->new ("something cool", undef,
                                      'destroy-with-parent',
                                      GTK_STOCK_APPLY => 'apply',
                                      GTK_STOCK_CLOSE => 'close');
      ...
  }

the advantage of constants would be compile-time checking that you spelled the stock id correctly; when using a string, you don't find out until runtime, when the button says "gtk-spply" instead of having the apply icon, etc.

--
Brian: If i recall correctly, this is the physics department.
Chris: That explains all that gravity.
        -- Family Guy, "The Story on Page One"




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