Re: G_LIST_REMOVE not working... at least not for me :-)


Sorry for the second email, but I just ran into a
problem with the code you provided.  With a few small
adjustments, it popped nicely into my application.

However, when I remove the last item from the list,
the list becomes a NULL list, and I can not use
'gtk_combo_set_popdown_strings' to basically "clear"
the last item from the combo box.  I found out that
when you try to 'gtk_combo_set_popdown_strings' a NULL
glist, GTK throws an error and the contents of the
combo do not clear.

If the item you are removing from the combo box is the
last item in there, how do you remove that last item
and update the combo box to show it as "empty"?

Thanks again!


--- Havoc Pennington <hp redhat com> wrote:

On Sat, Nov 16, 2002 at 03:50:05PM -0800, Mike
Dailey wrote:

mainConnMgmtComboList = g_list_remove

C doesn't work this way; it doesn't know what the
void* in the 
GSList points to. You have to remove the string
using exactly the 
same pointer used to add the string.

remove_string_by_value (GList *list, const char
  GList *iter;
  iter = list;
  while (iter != NULL)
      const char *s = iter->data;
      if (strcmp (s, str) == 0)
        return g_list_remove (list, iter->data);
      iter = iter->next;
  return list;

You can make it more efficient by unlinking the list
node "iter" when
the string matches, instead of using g_list_remove
which scans from
the front of the list, but it's somewhat more


Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site

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