Gtk2::ComboBox - setting value by string?

Hi all,

Running into a minor problem with Gtk2::ComboBox. I can set the current selected option by using an iter (or a string representation of the iter like "0") but I can't just set it to a string I know is in the list directly.

As a workaround I've had to create a little helper function like:

sub find_index {
  my ($model, $find) = @_;
  my $i = 0;
  while (1) {
    my $iter = $model->get_iter_from_string($i);
    last if not defined $iter;
    return $i if $find eq $model->get($iter, 0);
  return undef;

(where $model is the combobox's model from $cb->get_model).

Is this sort of thing necessary or is there a way to set a combobox's value by string rather than by index?


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