jaywhy13 |
2009-12-03 02:46 |
HILDON_WINDOW ( ... ) a cast function?
Is there a difference between
HildonWindow *window;
window = HILDON_WINDOW (hildon_window_new());
and
GtkWidget *window;
window = (hildon_window_new());
Essentially.. I'm trying to figure out why there's a need to do the whole HILDON_WINDOW(...) or GTK_CONTAINER(...)?
What's the real purpose of these functions? HILDON_WINDOW or GTK_CONTAINER?
Consider:
Code:
GtkWidget *window;
GtkWidget *button;
window = hildon_window_new ();
button = hildon_button_new_with_text (...);
gtk_container_add (GTK_CONTAINER (window),button);
The signature is:
Quote:
void gtk_container_add (GtkContainer *container,GtkWidget *widget);
|
In this case, "window" is a pointer to type GtkWidget... so I'm guessing the GTK_CONTAINER serves as some kind of cast (Java background.. forgive me) to convert the GtkWidget to a GtkContainer? My reasoning is since... GtkContainer is a GtkWidget, you need more specificity since the function wants a container, not just any old widget. Is this correct?
Another example I don't quite get is this one...
Quote:
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (gtk_main_quit), NULL);
|
The first parameter is supposed to be a pointer to type GObject... what role does G_OBJECT play here? If this is a cast operation... I'm not used to seeing casts goes this direction. Since GObject is the ultimate superclass.. why would you cast any subclass of GOBject back to GObject?
|