properties (was Re: window border)



by the way, you can get and set multiple properties in one go with the
Glib::Object functions...

  $foo->set (prop_1 => $val1,
             prop_2 => $val2,
             prop_n => $valn);
  @values = $foo->get (qw/ prop_1 prop_2 prop_n /);


incidentally, if you are are confused because of the difference between
   "border-width"         gulong               : Read / Write
in the API reference and
   $container->set (border_width => 4);
in my code examples, namely, "why is one done with dashes and the other done
with underscores?!?!?", the i should point out that all of the following are
equivalent:

   $container->set ('border-width', 4);
   $container->set ('border-width' => 4);
   $container->set ('border_width' => 4);
   $container->set (border_width => 4);

because gtk2-perl uses some string matching functions that consider '-' and
'_' equivalent.

for syntactical cleanliness purposes, and because vim will highlight it
correctly, i tend towards the last form, but you can use whatever you like.
the => operator is basically a comma that stringifies the thing to the left of
it, which is nice because it lets you omit the quotes.  if you're going to
omit the quotes, you typically need to use '_' instead of '-' because '-' is a
word separator for most syntax highlighters; i don't remember the exact rule
perl will use there, but that's why i always use '_'.


[1] that is, in sane languages, which rules out lisp and scheme ;)

-- 
muppet <scott at asofyet dot org>



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