Re: Why some GTK objects are not GObject?
- From: David Nečas (Yeti) <yeti physics muni cz>
- To: Marc Krisnanto <marc centrin net id>
- Cc: gtk-list gnome org
- Subject: Re: Why some GTK objects are not GObject?
- Date: Thu, 11 May 2006 11:24:02 +0200
On Thu, May 11, 2006 at 11:17:59AM +0700, Marc Krisnanto wrote:
> Why are there "objects" in GTK which are not GObject?
> For example, GtkTreeModel, GtkTreeIter, GtkTreePath etc.
> I am speaking for GTK+2.0 because I see G_IS_OBJECT assertions
> fail.
>
> Will they be GObject in the future or will they stay as they are?
GtkTreeModel is an interface. But anything implementing
this interface *is* a GObject. How do you make the
assertions fail? The interface typecasting machinery is
not a problem:
GtkListStore *store;
GtkTreeModel *model;
store = gtk_list_store_new(1, G_TYPE_INT);
model = GTK_TREE_MODEL(store);
g_print("G_IS_OBJECT(store): %d\n", G_IS_OBJECT(store));
g_print("G_IS_OBJECT(model): %d\n", G_IS_OBJECT(model));
GtkTreeIter is a very simple structure intended to be
commonly allocated on stack (i.e., be an automatic
variable) and copied by value:
GtkTreeIter iter1, iter2;
set_iter_to_something(&iter1);
iter2 = iter1;
Obviously, it cannot be a GObject then.
GtkTreePath is another very simple data structure which does
not make much sense to be an GObject.
> This makes those kind of objects difficult to implement because
> it makes an inconsistent model. I am referring to implementing
> GTK via direct calls from a programming language without going
> through C (for example, via a JIT engine such as GNU Lightning).
>
> With GObject, I can easily automate "self" while with those kind
> of "object" I am forced to pass a pointer to the struct, which
> means I have to take care of details to maintain, synchronize,
> and free the pointer.
The same for any simple C structure you may happen to use
like GdkRectangle or GtkAllocation, for GList items, etc.
They are not `objects'. If all these simple data types were
objects it might make Java programmers happy but I doubt any
C programmer would use Gtk+ then.
Yeti
--
Anonyms eat their boogers.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]