Re: Gtk/Glade Beginner: widget lookup, text input etc
- From: Gus Koppel <gtk spamkiller bytechase cx>
- To: gtk-app-devel-list gnome org
- Subject: Re: Gtk/Glade Beginner: widget lookup, text input etc
- Date: Thu, 11 Dec 2003 13:57:59 +0100
Sukrit K Mehra wrote:
GtkWidget *localwidget = lookup_widget (button, "dialog1");
(assuming button is a GtkWidget * and is part of dialog1)
This will return the pointer to your dialog1 widget.
What if the I don't have a reference button widget from same Widget
Tree?
[...]
How can I get that reference? If it's too clumsy then how do I share
the data otherwise?
You should maintain at least globally accessable pointers to every
window (= roots of widget trees) you generate / open. These are the
references you need. The function to create a window or dialog usually
returns it (at least if created by Glade). I.e.
GtkWidget *pointer_to_my_window = create_my_window ();
You can then use "pointer_to_my_window" as argument for lookup_widget ()
(or widget_find_by_name () if you like, see
http://www.spamkiller.bytechase.cx/democode/widget_find_by_name.c).
In your situation you should likely do something like this:
GtkWidget *source_widget_in_win1 =
lookup_widget (win1, "name_of_source_widget");
GtkWidget *target_widget_in_win2 =
lookup_widget (win2, "name_of_target_widget");
data = get_your_data_from_source_widget (source_widget_in_win1);
set_your_data_in_target_widget (target_widget_in_win2, data);
If your "win1" is being destroyed before "win2" is being available then
you would need to temporarily store the "data" somewhere, likely in a
globally accessable temporary buffer which survives destruction of
"win1" and can be queried and freed when "win2" is available.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]