Re: Newbie question regarding gtk_signal_connect



Nghia wrote:
> 
> Hello,
> 
> I'm a new person to this list and this is my first post.  I want to ask
> how do I go about parsing more than one argument or information to
> gtk_signal_connect.  Heres a following example of a simple program
> I want to do:
> 
> ------
> entry box
> ------
>   button
> ------
>  text box
> ------
> 
> When the user press the button it passes all the text from the entry box
> to the text box.  But from the reference it looks like you can only
> parse one argument only, and this would need two, the entrybox and the
> textbox.  How can I make this possible?

Personally I would create a structure which contains everything you need
to keep track of the window's components and state, i.e.

struct MyWindow
{
  /* Widgets */
  GtkWidget *window;
  GtkWidget *entry_box;
  GtkWidget *button;
  GtkWidget *text_box;

  /* Other things */
  ...
};

Then, before you create the top level window, alloc one of these
structures and fill in the widgets in the usual way using
gtk_button_new() i.e.

MyWindow *data = g_new0(MyWindow, 1);
data->window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
data->entry_box = ...;

Pass the pointer to the alloc'd structure to _every_ callback and you
will have access to everything you need.

Obviously, the structure can contain anything. Also, don't forget to
free the alloc'd structure when your window is destroyed. You can do
that by connecting to the GtkObject::destroy signal.

HTH

/Matt

-- 
Matt Goodall, Software Engineer  |  Isotek Electronics Ltd
mailto:mgg@isotek.co.uk          |  Claro House, Servia Road
http://www.isotek.co.uk          |  Leeds, LS7 1NL
Tel: +44 113 234320              |  England




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