Re: Passing custom parameters
- From: "Jim George" <jimgeorge gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Passing custom parameters
- Date: Thu, 28 Sep 2006 06:16:48 -0600
On 9/28/06, Sumedh <sumedhk ftml net> wrote:
Gtk - C
how to pass multiple arguments to a function from a widget. eg i have
two text entry widgets
and one button. What i want to do is that when i click the button i
should be able to
print(terminal) the contents of both the text entry widgets. Right now i
can print from only one
widget.
g_signal_connect accepts only 4 arguments. The last one is the data
pointer when i pass
another data pointer as 5 arguments, gtk spits an error which says that
only 4 arguments
are valid.
Here's how I'd do it:
struct my_params {
GtkEntry *e1, *e2;
int my_other_param;
}
...
struct my_params mp;
mp.e1 = ...;
g_signal_connect(G_OBJECT(button), "clicked", callback, &mp);
...
void callback(GtkButton *b, gpointer data)
{
struct my_params *mp = data;
/* use mp->e1 and mp->e2 */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]