Sure, below I have pasted a sample.cc program that demonstrates the relevant
GObject concepts, implemented with C++ and Gtkmm/Glibmm/Sigc.

Compile with:

g++ `pkg-config --cflags --libs gtkmm-2.4` -o sample sample.cc

===== sample.c =====
#include <iostream>
#include <gtkmm.h>

using namespace std;

class Sample : public ::Glib::Object
{
  public:
    // Construction
    Sample () :
      ::Glib::ObjectBase (typeid (Sample)), // inform GObject of your type
      m_propertyWeight (*this, "sample-weight"),
      m_signalPropertyWeight (this, "sample-weight")
    {
      // Connect sample-weight change signal to our handler
      m_signalPropertyWeight.connect (
       ::sigc::mem_fun (this, &Sample::onPropertyWeight));
    }

    virtual ~Sample () {}

  public:
     // Property "sample-weight" is an int
     ::Glib::PropertyProxy<int> propertyWeight (void)
     {
       return ::Glib::PropertyProxy<int> (this, "sample-weight");
     }

  protected:
     void onPropertyWeight (void)
     {
       // display something when property changes
       cout << "property weight changed to " << propertyWeight () << endl;
     }

  private:
    // property weight
    ::Glib::Property<int> m_propertyWeight;

    // signal to inform you of changes to property weight
    ::Glib::SignalProxyProperty m_signalPropertyWeight;
};

int main (int argc, char* argv[])
{
  // most importantly in this example, this step initializes the gobject
type system.
  ::Gtk::Main (argc, argv);

  Sample s;

  for (int i=1; i<10; i++)
  {
    s.propertyWeight () = i;
  }
}


On Mon, Dec 8, 2008 at 7:21 AM, Germán Diago <[EMAIL PROTECTED]> wrote:

> Hello. I'm looking at the gtkmm documentation. I would like to know if
> it's possible to register signals, GType and properties for types from the
> c++ bindings, or if I need to use c directly to do it. I'm new to GObject,
> so
> I don't know very well what I'm doing. What I would like to do is to
> get introspection
> capabilities at least for signals, types and properties, and I would like
> them
> to be registered in the Gobject type system. Thanks in advance.
> _______________________________________________
> gtkmm-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to