missing ComboBox method



My Gtk2::ComboBox objects seem to be missing the get_active_text method. I'm going to submit a bug report and all, but I figured I'd provide the list with the menial filler code:

  sub Gtk2::ComboBox::get_active_text {
    my ($self) = @_;
    my $model = $self->get_model;
    $model->get(
      $model->get_iter(
        Gtk2::TreePath->new_from_string($self->get_active)
      )
    );
  }

If you're considering subclassing Gtk2::ComboBox to add this method, be advised that you'll have another hoop to jump through: Gtk2::ComboBox's new_text method doesn't do class inheritence properly:

  package MyCombo;
  @ISA = qw( Gtk2::ComboBox );

  package main;
  my $c = MyCombo->new_text;
  print ref $c;

prints Gtk2::ComboBox instead of MyCombo.  The work-around is simple:

  package MyCombo;

  sub new_text {
    my $class = shift;
    bless $class->SUPER::new_text(@_), $class;
  }

but again, I decided to just trample Gtk2::ComboBox's namespace.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart



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