Re: [gtk-list] Re: Swapping label text?



* Emmanuel DELOGET (pixel@epita.fr) [990807 11:23]:
>     You get the pointer... right. tt contains the address of the
>     label string
> 
> >
> >  gtk_label_set (GTK_LABEL (label1), (gchar *) ss);
> 
>     The label string in label1 is destroyed.
> 
> 
> >  gtk_label_set (GTK_LABEL (label2), (gchar *) tt);
> 
>     And since tt points on it, tt now contains garbage...
> 
> 
>     What you can do is:
> 
>         gchar *tt, *ss;
> 
>         gtk_label_get(GTK_LABEL(label1), &tt);
>         tt = strdup(tt);
>         gtk_label_get(GTK_LABEL(label2), &ss);
>         gtk_label_set_text(GTK_LABEL(label1), ss);
>         gtk_label_set_text(GTK_LABEL(label2), tt);
>         free(tt);
> 
>     BTW, you don't need to cast &xx to (gchar **), since
>     &xx IS a gchar **.
> 
>     Yours,
> 
>     pixel@epita.fr

{Feeliny dense}

Thanks. I'm still getting the hang of this!

Tom.
-- 
            .-------------------------------------------------------.
    .^.     | Tom Gilbert, England | tom@tomgilbert.freeserve.co.uk |
    /V\     |----------------------| www.tomgilbert.freeserve.co.uk |
   // \\    | Sites I recommend:   `--------------------------------|
  /(   )\   | www.freshmeat.net www.enlightenment.org www.gnome.org |
   ^^-^^    `-------------------------------------------------------'



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