Re: Problems finding items in a GList



El lun, 28-10-2002 a las 10:40, amitjain escribió:
> firstly i should summarize your question
> you have a GList of GtkLabel and now you want to change the labels .right?
> 
No, sorry if I explained it badly.

I have a variable number of sections, each section has a name that
appears in a GtkLabel, the user can modify de label with a GtkEntry,
remove the sections or add new ones.
The String of the labels are also in a GtkCombo (in the GList which
declaration is GList *defafult_list).

When the user add a new section, and give it a name, I want to add the
label to the GtkCombo, I do I like that:

GString *label = g_string_new(NULL); /*where I save the String of the
label*/
g_string_assign(label, gtk_label_get_text(GTK_LABEL (obox[j].name)));
gtk_label_set_text(GTK_LABEL (obox[j].name), 
		gtk_entry_get_text(GTK_ENTRY (obox[j].label_text_box)));
default_list = g_list_append(default_list, gtk_entry_get_text(GTK_ENTRY
			(obox[j].label_text_box)));
gtk_combo_set_popdown_strings (GTK_COMBO (default_combo), default_list);

This works well.
The problem came when I want to change the value of the GtkCombo because
the GtkEntry is changed. I have done this:

GList *rem = NULL;
g_string_assign(label, gtk_label_get_text(GTK_LABEL
		(obox[j].name)));/*Get the  old value of the GtkCombo I want to
delete*/
rem = g_list_find_custom(default_list, label->str,
	(GCompareFunc)strcmp);/*Find the position of the String in the GList,
HERE rem IS ALWAYS NULL*/

if (rem != NULL)
{/*Delete it*/}
gtk_label_set_text(GTK_LABEL (obox[j].name), 
	gtk_entry_get_text(GTK_ENTRY (obox[j].label_text_box)));/*No I 
	can change the label*/
default_list = g_list_append(default_list, gtk_entry_get_text(GTK_ENTRY
		(obox[j].label_text_box)));
gtk_combo_set_popdown_strings (GTK_COMBO (default_combo),
default_list);/*And add the new value*/

If my original GList is:
hello
goodbye
computer

and I change goodbye to goodby

my new GList is:
hello
goodby
computer
goodby

I don't see the problem. Thanks
-- 
The chains are broken and the door is open wide
Our eyes adjusting to the light that was denied
And bring a sense of wonder

	http://www.es.debian.org/intro/about.es.html

Attachment: signature.asc
Description: Esta parte del mensaje esta firmada digitalmente



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