Swapping label text?



Could someone help me. This is driving me crazy...

I need a dead simple bit of code that take two GtkLabels and swaps the
text from one to the other, and vice versa.

The code I put together, below, doesn't work as I expect. The result
is:
before
label1=a
label2=b
after
label1=b
label2={garbage}

i.e. the label text moves from the second to the first, but this doesn't 
work in the reverse direction.

Here's the code:
-------------------------------------------------------
  gchar *tt;
  gchar *ss;

  gtk_label_get (GTK_LABEL (label1), (gchar **) & tt);
  gtk_label_get (GTK_LABEL (label2), (gchar **) & ss);

  gtk_label_set (GTK_LABEL (label1), (gchar *) ss);
  gtk_label_set (GTK_LABEL (label2), (gchar *) tt);


I think maybe I'm being thick, but please help!
--------------------------------------------------------
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]