gtk_list_find() problem



I know I ask some quite elementary questions, but here's another.  I've
pored over this thing and can't find the problem.

Here's the code:

GList *offset_list; /*Global - it's initialized with "NONE" as first
                     * element*/
-------
    /* data->offset_entry is a combo_box_entry_text widget *
     * each time it is created, It's populated from        *
     * offset_list. */
    
    G_CONST_RETURN gchar *offsetpt;
    
    offsetpt = gtk_entry_get_text (GTK_ENTRY (GTK_BIN (
                                   data->offset_entry)->child));
    
    if ( strlen (offsetpt) && strcmp(offsetpt, "NONE"))
    {
        g_string_append_printf (line, "(%s) ", offsetpt);

               /* here's the problem.  if the above combobox entry was
                * chosen from an already-existing entry in the GList,
                * don't add it again.  If it is a new element, typed into
                * the comboboxentry, then add it to the list.  (At
                * least, that's what I'm trying to do)*/
   
        if (! g_list_find (offset_list, offsetpt) )
        {
            offset_list = g_list_append (offset_list, g_strdup (offsetpt));
        }
    }
----------------------------

However, with the above, for some reason, a match is never found.  Each
time, a new entry is added to the GList, even when it comes from the
GList.  I get just what I want in line.  All seems to work well but the
matching existing entries.

I've tried a little test program creating a simple GList from a
gchar *[] and then ran g_list_find using one of the elements from the
array and it was found.

In short the test program was something like
GList *list, *found;
gchar *equ[] = {...}

populate list from equ...

if ( found = g_list_find (list, equ[1]))   {g_print("found...)}

and it found it.

I cannot see any difference in my logic there and here, but something
isn't right here.  Bet it's something simple, but I'm stumped (again).



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