Dan Mueth wrote:
> 
> First, I'd like to thank all the Glade developers - Glade makes Gtk+/Gnome
> developing easy(er) and fun.
> 
> I have a very basic question about how one shares Widgets in
> Gtk+/Gnome/Glade. Imagine I have two separate windows, "main" and
> "preferences".  Suppose "main" has some combo box widgets and
> "preferences" has some toggle buttons.  I would like the callbacks on the
> toggle buttons to change the entries in the combo boxes which are in a
> separate window.  How do the callback functions(to events in "preferences"
> window) know what the names of the combo box Widgets in "main" window are?
> 
> Does one have to define external variables for this, or is there a nicer
> way?

Look at on_Fontsel_activate() in examples/editor/src/callbacks.c :


/* This is called when the 'Change Font' command is used. We just need to
   show the font selection dialog. */
void
on_Font_activate                       (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{
  GtkWidget *main_window;

  main_window = lookup_widget (GTK_WIDGET (menuitem), "main_window");
  if (!fontsel)
    {
      fontsel = create_font_selection ();
      gtk_object_set_data (GTK_OBJECT (fontsel), MainWindowKey, main_window);
    }
  gtk_widget_show (fontsel);

  /* We raise the window in case it is already created and shown, but is
     hidden behind another window. */
  gdk_window_raise (fontsel->window);
}



Notice that it creates a new dialog with create_font_selection() and then
calls gtk_object_set_data() to save a pointer to the main window inside the
font selection dialog.

on_fontsel_apply_button_clicked() then uses gtk_object_get_data() to get the
pointer again so it can update the main window.

You may need to be careful to ensure that the pointer is always valid.
i.e. you could connect to the main window's destroy signal so you can remove
the pointer to it.

Damon

+---------------------------------------------------------------------+
To unsubscribe from this list, send a message to [EMAIL PROTECTED]
with the line "unsubscribe glade-devel" in the body of the message.

Reply via email to