what's the best way to handle variables and objects?
- From: Andreas Kotowicz <kotoml mynetix de>
- To: gtk-app-devel-list gnome org
- Subject: what's the best way to handle variables and objects?
- Date: Wed, 15 Mar 2006 19:18:38 +0100
I'm looking for a clean solution on passing variables and objects from
gtk calls to callback functions and back.
I call for instance
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(clear_timer_cb), progressbar);
and pass with it the object I'm working with. (progressbar has been
definded before: GtkWidget *progressbar = gtk_progress_bar_new(); )
now in clear_timer_cb I can modify the object:
void clear_timer_cb(GtkObject *window, void *data)
{
GtkWidget *progressbar = data;
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar), 0);
}
but what should I do if I want to modify any other variables in this
function as well? let's say that in the part where I created the
g_signal_connect there are also some variables A and B which might be of
interest in clear_timer_cb.
should I create a struct
struct data {
gdouble *A;
gdouble *B;
GtkWidget *progressbar
};
and then initiate it and pass it always on?
what's the best way in dealing with this?
cheers,
Andreas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]