Re: GObject - create with arguments.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Uzytkownik <uzytkownik2 poczta onet pl> writes:

I'm newbie in GObject(before I use C++).
Can I create object with arguments?
In C++:
class xyz
{
      public:
              xyz(int i);
};

Yes.  As a (poor) example:

MyClass *
my_class_new(gint foo, const gchar *bar)
{
  return MY_CLASS(g_object_new(MY_TYPE_CLASS, "foo", foo, "bar", bar, NULL));
}

This passes "construction parameters" to g_object_new.  When the
object is constructed, the construction parameters are set for the
object.  These are object properties installed with
g_object_class_install_property() with G_PARAM_CONSTRUCT.  See the
GObject tutorial for examples
(http://www.le-hacker.org/papers/gobject/)


Regards,
Roger

- -- 
Roger Leigh
                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                Debian GNU/Linux        http://www.debian.org/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFCYr7VVcFcaSW/uEgRAqxuAJ0b2oUGpQhsC8X405YX1sVycGZXbgCgovRD
qOzM4DZxOCvsmZsnOkTaEU4=
=FbBX
-----END PGP SIGNATURE-----



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