Re: various Gtk2 enumerations -- how to access?



-- Ross McFarland <rwmcfa1 neces com> wrote
(on Sunday, 10 August 2003, 05:08 PM -0400):

the enum's actual values aren't available at the perl level, so if
you're wanting those for some reason you're probably out of luck. i
can't think of a situation where you'd really need them, but correct me
if you have found one.

you shouldn't need to create a perl object of the enum type. you should
just be able to have a perl scalar containing the one of the strings,
like you seemed to already have found out:

GtkShadowType
  GTK_SHADOW_NONE     => 'none'
  GTK_SHADOW_IN               => 'in'
  GTK_SHADOW_OUT      => 'out'
  GTK_SHADOW_ETCHED_IN        => 'etched-in'
  GTK_SHADOW_ETCHED_OUT       => 'etched-out'

if you want GTK_SHADOW_IN then you'll do the following:
      $widget->takes_a_policy_type_enum('in');

if you're trying to test and see what value something has:
      if( $widget->returns_a_policy_type_enum eq 'in' )

if you're wanting to hold the type in a var then the following should
work:
      $shadow_type = 'in';
      $widget->takes_a_policy_type_enum($shadow_type);

if you're trying to do something beyond that then reply with more exact
details of what it is you're trying to do, a snippet of code would be
best.

Actually, what I'm trying to do falls exactly into the scope you present
here. In each case, I simply needed an enum type to pass to a method or
an enum type returned from a method I needed to compare for special
cases. 

This would make a nice FAQ; it'd also be nice to see in some sort of POD
or manpage, too.

The only other difficulty I've had had to do with gobject type enums,
and was specific to creating a treestore; I examined some sample code in
the gtk-demo/ portion of the distribution, and learned how to do it
('Glib::String' and 'Glib::Int' were what I needed to pass to the
Gt2::TreeStore constructor). It'd be nice to have some documentation on
that, however, too.

'Course, you may have done both, by now; I'm still using 0.90. ;-)

Thanks for the clarifications -- nice and concise, and very relevant.

-- 
Matthew Weier O'Phinney
http://weierophinney.net/matthew/



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