Re: How to copy data between widgets?



On 8/8/06, Lance Dillon <riffraff169 yahoo com> wrote:

> From: RomÃn Gorojovsky <rgorojovsky gmail com>
> To: gtk-app-devel-list gnome org
> Sent: Tuesday, August 8, 2006 10:07:06 AM
> Subject: How to copy data between widgets?

> Hi all, sorry if this is a FAQ, but I've been reading the docs and I
> couldn't find the answer.  Not being too fluent in english, I couldn't
> find it in the archives, since I don't know what to look for.

> The problem is the following.  I have a text entry, a button and a
> label.  I want the label to display the text in the entry when you
> press the button.

> So far I've used g_signal_connect_swapped() connecting the "clicked"
> signal on the button with a callback that takes a pointer to the label
> as data.  But I couldn't pass more than that, so I could't pass a
> string nor the text entry.

But you can pass any kind of pointer, so make a struct, something like this:

struct my_data {
  GtkLabel *l;
  GtkEntry *e;
};

Then pass a pointer to an instance of your struct.  Now you have both widgets available in your callback.

Ok, thanks, I'll try that.

In fact I had alredy tried and falied, but that could be a problem in
my C-fu, not in my GTK-fu.....

IIRC I did

  GtkWidget *label;
  struct my_data *data;

  /* Initialize label */

  data->l = label;

and got a Segmentation fault there.  But I'll try again I guess....





_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


--
RomÃn


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