Setting an iter from an ID value
- From: Daniel Kasak <dkasak nusconsulting com au>
- To: gtk-perl mailing list <gtk-perl-list gnome org>
- Subject: Setting an iter from an ID value
- Date: Thu, 22 Jul 2004 12:25:36 +1000
Hi all.
I have some code which I'm not completely happy with.
I have a combo box with a Gtk2::ListStore model, which contains 2
fields: an ID field and a string field.
Here's how I'm currently selecting the iter:
my $iter = $widget->get_model->get_iter_first;
$widget->get_child->set_text(""); # In case no match is found for some
reason
while ($iter) {
if ($id_from_database eq $widget->get_model->get($iter, 0)) {
$widget->set_active_iter($iter);
last;
}
$iter = $widget->get_model->iter_next($iter);
}
This works, but doesn't seem like a very economical way of doing things.
I've thought about getting the string field from the database and using
$widget->get_child->set_text($string) but that also seems kinda dodgy,
and won't work if there are duplicate strings ( not that there should
be, but anyway ... )
Is there a better way of doing this?
--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au
Title: CanIt Vote for ID 71778
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]