Re: G_LIST_REMOVE not working... at least not for me :-)
- From: Mike Dailey <daileyml yahoo com>
- To: Havoc Pennington <hp redhat com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: G_LIST_REMOVE not working... at least not for me :-)
- Date: Sat, 16 Nov 2002 18:04:52 -0800 (PST)
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"?
--- Havoc Pennington <hp redhat com> wrote:
On Sat, Nov 16, 2002 at 03:50:05PM -0800, Mike
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
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;
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
] [Thread Prev