Re: [gtk-list] Main Window References Dialog Window(or vica versa)?



>  I have a window which creates and pops up a dialog with an entry.
>  When the OK button is pressed the callback obtains the entry
>  data and MUST update data in the main window.
> 
>  What is the best way to exchange information between windows.

This is what "user data" is used for that you see refered to in all the docs... ie:

callback(widget, row, gpointer userdata)

I tend to code in Perl, but the concepts are the same in C...

$main_window = new Gtk::Window("TopLevel");
$widget_one = new Gtk::Label;
$widget_two = new Gtk::Clist;
$widget_two->signal_connect("select_row", \&selection_handler, $widget_one);
sub selection_handler {
 ($widget, $label_widget) = @_;
  # now I have the Gtk::Label in my current context... so I can modify it even though
  # I am somewhere else...
}

>  How about using object_set_data( Window1, "window2", window2);
>  Am I wasting alot of memory doing this?
>  Will I lose the data when a window is destroyed?
> 
>  Also, a side question -------------------------------
>  How can I disable the destroy button on a dialog window?
>  I want to force the users to use the OK and CANCEL buttons.

How about signal_connect("destroy" => sub { return 1; });
(remember, this is perl, but the concept is the same...)

-Steve

P.S.
  My first example may be cryptic... the concept is this:  widgets are standalone objects
Widgets pass widgets to each other as userdata in event callbacks.  For in depth examples
feel free to check out the sourcecode to CSCMail (http://www.cyberdeck.org/cscmail)
It's in perl, but you should be able to grok the concepts....



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