GTK is OO.
- From: Muthiah Annamalai <dearestchum yahoo co in>
- To: srinivas comodo com, gtk-app-devel-list gnome org
- Cc:
- Subject: GTK is OO.
- Date: Wed, 8 Jun 2005 06:31:42 -0700 (PDT)
Hello folks!
I mean GTK Is OO.
Widgets encapsulate other widgets.
There is a type system,GObjects and signals floating
all over the place. Please try to understand this
GTK architecture.
[see developer.gnome.org and GObject
tutorials,GTK+ tutorials,before asking questions.
You can even try to search the mailinglist archives]
COMBO box encapsulates an entry and some kind of
menu.
How do you work this out ?
Lets say you want to set the entry of this combo box.
Well open the gtkcombo.h in your emacs [editor].
Then you see this:
<Code>
/* you should access only the entry and list fields
directly */
struct _GtkCombo {
GtkHBox hbox;
/*< public >*/
GtkWidget *entry;
/*< private >*/
GtkWidget *button;
GtkWidget *popup;
GtkWidget *popwin;
/*< public >*/
GtkWidget *list;
/*< private >*/
...
};
</Code>
Now you just get your combo box widget pointer[combo],
and access this entry, and set its text.
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry),
"GTK+ is Object Oriented, and I understand this!");
Now your code must be something like this
<Code>
int main()
{
GtkWidget *w,*box,*btn,*cmb;
gtk_init(NULL,NULL);
w=gtk_window_new(GTK_WINDOW_TOPLEVEL);
box=gtk_hbox_new(0,0);
cmb=gtk_combo_new();
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(cmb)->entry),
"GTK+ is Object Oriented, and I understand this!");
gtk_container_add(GTK_CONTAINER(w),box);
gtk_box_pack_start_defaults(GTK_BOX(box),cmb);
gtk_widget_show_all(w);
gtk_main();
}
</Code>
Can it get simpler? Use language bindings to GTK+ from
Python,C++,C# for OO like API.
GTK C API has powerful introspection capacities,
please make use of this before you ask questions..
Thanks
Muthu
__________________________________
Discover Yahoo!
Get on-the-go sports scores, stock quotes, news and more. Check it out!
http://discover.yahoo.com/mobile.html
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]