Check Gtk2::ListStore empty or not



Hi All,

Is it possible to check if a Gtk2::ListStore is empty?

At the moment I have a combo box with a list of items.  The user can
select items from the combo box and add them to a list.  But I don't
want them to be able to add duplicate items to the list.

So first I was going to check if the list was empty.  If it was then
it can add an item, but if it wasn't then get an array of the items
already in the list store, loop through them checking that the combo
selection isn't already there and then add the item.

I'm not entirely sure how to check if the list is empty.  At the
moment I'm trying:
if ($list_store->get_iter_first)
#or
if (defined $list_store->get_iter_first)
  # get what's there and check for duplicates
else
 # add item to list

but this doesn't work because when I try to get everything from my first column:
my @col1 = $list_store->get($list_iter, 1);

It says:
variable not allowed to be undef where GtkTreeIter is wanted at line 331

which matches the 'my @col1' line above.

Could someone please help me with the testing logic.  I understand it
needs to be defined, but it can only be defined if there's something
in the row, but then I can't test if it's empty.

Very confused.....

Many thanks,

Peter.



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