Can't correctly set data to an object (button)
- From: philippe vivarelli mindspeed com
- To: gtk-list gnome org
- Subject: Can't correctly set data to an object (button)
- Date: Wed, 31 Jul 2002 11:49:09 +0200
Hi all,
Well I have toggle button to wich I attached a default string ("DEFAULT")
using the gtk_object_set_user_data function.
In the callback toggle function I reassign this string regarding the state
of the button.
I pick up the new string from a gtk_entry.
The problem is when I get the attached data again, is not set to the rigth
value.
When I toggled the button:
- the printf("attached data 1 = %s\n",attached_data); shows the rigth
value.
- the printf("Active profile name = %s\n",profile_name); shows the rigth
value too.\
- the printf("attached data 2 = %s\n",attached_data); shows an unexpected
value "DEFAULT"
Just like below
attached data 1 = DEFAULT
Active profile name = CUSTOM
attached data 2 = DEFAULT
If on the line where I set the new string (
gtk_object_set_user_data(GTK_OBJECT (button),profile_name);)
I replace profile_name by a static string (i.e "CUSTOM") it works.
Does someone can explain what is wrong in my code ?
Thank you in advance
Philippe Vivarelli
void
on_view_profile_toggled (GtkButton *button,
gpointer
EditEndpointWindow)
{
GtkWidget *button_label = NULL;
GtkWidget *profile_entry = NULL;
gchar *attached_data;
static gchar *profile_name;
// Save the current profile entry pointer and name
profile_entry = lookup_widget(EditEndpointWindow,
"profile_combo_entry");
profile_name = gtk_entry_get_text((GtkEntry *) profile_entry);
button_label = lookup_widget(EditEndpointWindow,
"button_label");
attached_data = gtk_object_get_user_data(GTK_OBJECT (button));
printf("attached data 1 = %s\n",attached_data);
if(gtk_toggle_button_get_active((GtkToggleButton *) button)
== TRUE)
{
printf("Active profile name = %s\n",profile_name);
gtk_label_set_text((GtkLabel *) button_label,"View
Current");
gtk_entry_set_text((GtkEntry *) profile_entry,
"DEFAULT");
gtk_object_set_user_data(GTK_OBJECT
(button),profile_name);
attached_data =
gtk_object_get_user_data(GTK_OBJECT (button));
printf("attached data 2 = %s\n",attached_data);
}
else
{
printf("Inactive profile name
= %s\n",profile_name);
gtk_label_set_text((GtkLabel *) button_label,"View
Default");
gtk_entry_set_text((GtkEntry *) profile_entry,
attached_data);
gtk_object_set_user_data(GTK_OBJECT
(button),"DEFAULT");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]