Re: g_timeout_add() - Passing Multiple Parameters!



On Sat, 7 Feb 2004, JOSE PEDRO SERGIO ROMAO MACHADO wrote:
I using this funtion as:

timer = g_timeout_add(1000, (GtkFunction)ReadTimerFile,
(gpointer)"database.txt");

Where "database.txt" is the file to be read.

Question: How can I pass more than one argument to my
ReadTimerFile funtion???

PS: I need to pass and pointer to a widget and the file
path, ie, (gpointer)"database.txt" and (gpointer)widget.
Hello Jose,
if you want to pass multiple parameters you should put them into a
structure, like:
struct {
  char *szFilename;
  GtkWidget *pWidget;
} UserData;

You can pass a pointer to this structure into g_timeout_add(). Inside the
callback you can access the single elements of your structure by the given
pointer.

Regards,
                 Peter
-- 
====================================================================
Peter Krüger

applied software solutions (appss) GmbH
Sandtorstr. 23
D-39106 Magdeburg
Germany

Phone:  +49-(0)391-54486-19388
Fax:    +49-(0)391-54486-19222
email:  krueger appss de
URL:    http://www.appss.de

Managing Director: Uwe Hess, Dietmar Schäfer
Register: HRB12386, AG Mageburg

"Virtual business becomes reality!"

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
====================================================================




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