[Glade-users] Setting text from one application window to another

This is from the Glade FAQ  http://glade.gnome.org

Try this out first and see how it works.  I'll try to help it you get stuck.


4.6 How do I get a pointer to a widget in another window?

You need to keep track of pointers to all your toplevel windows.
For simple applications you can just use global variables to store these

For more complicated applications you can use the gtk_object_set_data() and
related functions to store a pointer to one window inside another window.
For example, if you want to create a dialog which needs to access widgets in
the main window you can do this:

  dialog = create_dialog1 ();  /* Call the function generated by Glade. */
  gtk_object_set_data (GTK_OBJECT (dialog), "main_window", main_window);

Then when you need to access the main window from within the dialog code,
you can do this:

  main_window = gtk_object_get_data (GTK_OBJECT (dialog), "main_window");

NOTE: You need to be careful to ensure that the pointer is always valid.
If the window being pointed to is destroyed, make sure you no longer use the
pointer to it or your application may crash.

On Sunday 23 September 2001 05:00 am, Rajesh Padalia wrote:

Hi everybody,

I am new to Glade and this list as well. Glade is fantastic tool for
development! I have one query on how to set text form one app to another.

I have created two application windows in glade: app1 and app2. A button on
app1 opens app2 window. I have "clist" on app2 and want to set text in
"text entry" area of app1 when row in "clist" in app2 is selected and OK
button on app2 is clicked. While I am able to read data from "clist" and I
too know how to write in "text_entry" area. The problem is - I don't know
how to reference GtkWidget from app2 to app1. Is "lookup_widget" ok for
this? Can any body give example of code for it.

I would appreciate any help on this matter. Thanks in advance.

Best Regards,

Rajesh Padalia

Content-Type: text/html; charset="iso-8859-1"; name="Attachment: 1"
Content-Transfer-Encoding: quoted-printable

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