[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Object Orientation in GTK
- From: Matthew Ettus <ettus earthlink net>
- To: gtk-app-devel-list redhat com
- Subject: Re: Object Orientation in GTK
- Date: Sun, 08 Nov 1998 13:24:24 -0800
Isn't this essentially like global variables? Just because you throw
them all into a structure, it is essentially the same, right?
Matt
Havoc Pennington wrote:
>
> On Sat, 7 Nov 1998, Matthew Ettus wrote:
> >
> > On the other hand, it seems to encourage the use of global variables.
> > In many instances, I see no way of avoiding global variables.
> >
>
> It's trivial; just use structs and methods that act on them.
>
> /* define MyApp object */
> typedef struct _MyApp MyApp;
>
> struct _MyApp {
> GtkWidget* main_window;
> /* other data too */
> };
>
> void my_app_quit(MyApp* app);
> void my_app_foo(MyApp* app, MyFooData* foo);
> etc.
>
> You can do everything with this that you could do with:
> class MyApp {
> void quit();
> };
>
> Though of course it will be less safe and involve more typing.
>
> Plain structs are fairly limited as objects; if you want a "real" object
> you can make a GtkObject descendant. This gives you signals and
> inheritance and type checking.
>
> Havoc
>
> --
> To unsubscribe: mail gtk-app-devel-list-request@redhat.com with
> "unsubscribe" as the Subject.
>
> Mailing list concerns should be mailed to <listmaster@redhat.com>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]