Re: Program Structure



Every instance method needs to be passed a pointer to the instance
(typicaly called 'self' or 'this').

i.e
void add_to_the_label(MyClassInstance *self, gchar *charsToAdd)
{
GtkLabel *theLabel = get_theLabel(self);
gchar *oldText;
gtk_label_get(theLabel, oldText);
gchar *newText = g_strconcat(oldText, charsToAdd, '\0');
gtk_label_set_text(theLabel, newText);
g_free(oldText);
}

the get (and set) methods can delve into the containers and retrive the
widget for you or you can store a pointer to the widget in the instance
data and they just return that.
 
On Sun, 08 Apr 2001 01:02:27 frankc srv net wrote:
I am having trouble understanding the structure of programming a GTK+
app. My biggest hangup is how do I modify a widget that is nested in a
window several levels down?  I looked at mapping to it by name or
creating a master structure containing all the widget pointers.  Neither
of these look very practical.  Another method I thought of was creating
a callback that responds to a signal manufactured by another widget.
This last I am not sure how to approach, but I am hoping I can send data
to the widget that responds to the signal.  This problem probably has a
simpler solution.  I am new to programming this way as opposed to a
linear program. I am used to having access to all my data all the time.
I would like to keep my apps object oriented, but I am not understanding
how to make widgets talk to each other easily without destroying the OO
barriers.

Thanks,
Frank


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

rob





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