Fwd: Programming style



Hello all,

I have a few doubts about the way I code my GTK applications. One of
them is: Is it ok to use many global variables for the widgets? For
example, in a glade app where callbacks are of the form

void callback(GtkWidget *widget)

I can only have access to the widget that received the signal, but
what if I want to make it change a property of another widget? Should
I use a global variable or should I try getting the toplevel widget
and then decending to the "neighbour" widget I want to make changes
on?

Also, what is the best way to get those "neighbour" widgets, if that
is the case? On a programa I'm writing, I had to do the following:

hostname = (char *) gtk_entry_get_text(GTK_ENTRY(((GtkBoxChild *)
(GTK_BOX(gtk_widget_get_ancestor(widget,GTK_TYPE_HBOX))->children->next->data))->widget));

That doesn't look very neat, does it?

In the case of a Glade app again, is it ok to have my GladeXML
variable global or is that a bad programming style?

Thanks a lot,

--

César Leonardo Blum Silveira
Graduando em Ciência da Computação - Unisinos
Centro de Simulação de Humanos Virtuais
http://cesarbs.blogspot.com/
MSN: cesarbs490 _at_ msn _dot_ com
ICQ: 170861826



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