Re: Steps to get to GTK+ 3.0
- From: Hubert Figuiere <hfiguiere teaser fr>
- To: gtk-devel-list <gtk-devel-list gnome org>
- Subject: Re: Steps to get to GTK+ 3.0
- Date: Thu, 05 Jun 2008 09:28:22 -0400
On Thu, 2008-06-05 at 08:59 +0200, Jean-Yves Lefort wrote:
> or using the Qt way:
>
> class QFoo : public QObject
> {
> Q_OBJECT
>
> Q_PROPERTY(int bar READ bar WRITE setBar)
>
> public:
> void setBar (int value);
> int bar () const;
> };
>
> void QFoo::setBar (int value)
> {
> // ...
> }
>
> int QFoo::bar ()
> {
> // ...
> }
Of the Gtkmm way:
class GFoo : public Glib::Object
{
Glib::PropertyProxy<int> m_bar;
public:
GFoo();
Glib::PropertyProxy<int> property_bar(int value)
{ return m_bar; }
// allow using the property on const objects, enforcing
// the read-onlyness.
Glib::PropertyProxy<int>_ReadOnly property_bar(int value) const
{ return m_bar; }
};
GFoo::GFoo()
: Glib::ObjectBase(typeid(GFoo)),
m_bar(*this, "bar")
{
}
Icing on the cake: you can even use g_object_get_property() and
g_object_set_property() on it by accessing the underlying GObject.
Also note to C++ haters: it is simplier if you don't care about GObject.
Hub
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]