Re: How to hadle the objects? g_set_data, global?



On Dec 14, 2007 2:20 PM, Diogo F. S. Ramos <diogofsr gmail com> wrote:
> > I Usually create all my windows as a Child of GtkWindow, insert all
> > the widgets I need in it (if it is static, at least). Then I write
> > simple wrappers that I connect to specific behaviour on widgets.
>
> Well, I liked your approach and I am trying to learn how to do it.
>
> So, what I need to learn is how to subclass a gobject. As Tristan said,
> there is a tutorial at DevHelp which teach how to do it. Unfortunately,
> I was unable to accomplish it using that because there only pieces of
> code on it and I couldn't find the sources anywhere (not on the place
> said it would be or internet).
>
> My next step was running to Google. I found the Gtk Tutorial, which
> teach about TicTacToe. The problem there was that the code at the
> tutorial is different from the code from the link that it references
> (http://www.gtk.org/~otaylor/gtk/tutorial/) which is different from the
> code that comes with the GTK+'s source. Not good.
>
> Then, I found a online free book called "Gtk+/Gnome Application
> Development". It is very useful but, the problem is that it is based on
> the GTK+ 1.2 series...
>
> So I am out of ideas. Every place that I found something is different
> from everything else so I don't know what is right, what is wrong, what
> _was_ right and what is right _now_.
>
> Could you (or someone) suggest me a place where I can learn about how to
> subclass a Gobject (or even better, a GtkWindow) without the fear that I
> doing things in a "deprecated way" with consistent source examples?

I learned everything I know (and I'm not an expert in it, but I can
work my way) using GObject's reference[1] (it has a nice tutorial
there, too). It is a bit odd and sometimes hard to figure out the
right way to do things, but now we have a few tools that can help you
get the grip of it:

First keep the reference pointed above for... er... reference :)

Then you would be glad to download two nice tools: GOB2 [2] and Vala [3].

These two are great if you don't really want to write it all in C, but
they are also great if you want to LEARN how to write it all in C.
Write a few constructs in those slightly higher level tools and make
them generate the C code for you... then you can study what happens on
the generated code. If you ignore a few extra stuff the GOB2 generates
I think you wouldn't even need Vala (since it is a completely new
Language it wouldn't be that good as a learning tool for C).

I hope you succeed in your study :) Feel free to ask things as they
come up. I can't guarantee I will know the answer, but I'll probably
learn something along the way too, trying to figure out the answer.

Regards,
Alexandre Moreira.

[1] http://library.gnome.org/devel/gobject/stable/
[2] http://www.5z.com/jirka/gob.html
[3] live.gnome.org/Vala

PS: I use a little stupid script to generate my boiler plate code but
it is not more than a template file that accepts a few parameters
(namespace, class name and namespace + classname for the base class).
If you're interested I can send it to you, but I can't guarantee it is
"correct" in anyway.

>
> --
>
> Diogo F. S. Ramos
>
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]