[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Object Orientation in GTK
- From: Havoc Pennington <rhpennin midway uchicago edu>
- To: gtk-app-devel-list redhat com
- Subject: Re: Object Orientation in GTK
- Date: Sun, 8 Nov 1998 08:28:39 -0600 (CST)
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
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]