Re: [gtkmm] Glib critical messages on Property<>



Hello!

> > Yes, problem caused by Glib::Value<T*> (GValue, actualy).
> >
> > 1. T* should be a pointer to class derived from GLib::Object.
>
> No, it doesn't need to.

Hehe, three people, three opinions :-)

I think the main problem is that these things are not documented very well
and so everybody have it's own idea how it's working.

> Uh no.  There's no reason to use C++ bindings if you gonna end up using
> void* anyway.

Yes, that's very suboptimal.

> Still, I think long* _should_ work.  There's pretty tricky Glib::Value<>
> template code in place to allow things like that.  Frank: I'll probably
> investigate your diff later today.

Thank you. I'll attach the very small diff for the mailinglist too so
everybody can take a look. It's against the file
gtkmm-2.2.1/examples/cellrenderercustom/cellrenderertoggle.cc and only add
a new property long* in the same way as for the property bool.


Regards,
Frank
--- cellrenderertoggle.cc.bak	Thu Mar 27 22:42:34 2003
+++ cellrenderertoggle.cc	Thu Mar 27 23:01:58 2003
@@ -19,6 +19,7 @@
   Glib::PropertyProxy<bool> property_activatable();
   Glib::PropertyProxy<bool> property_active();
   Glib::PropertyProxy<bool> property_radio();
+  Glib::PropertyProxy<long *> property_test();
 
   SigC::Signal1<void, const Glib::ustring&>& signal_toggled();
 
@@ -46,6 +47,7 @@
   Glib::Property<bool> property_activatable_;
   Glib::Property<bool> property_active_;
   Glib::Property<bool> property_radio_;
+  Glib::Property<long *> property_test_;
 
   SigC::Signal1<void, const Glib::ustring&> signal_toggled_;
 };
@@ -62,8 +64,9 @@
   {
     Gtk::TreeModelColumn<Glib::ustring> text;
     Gtk::TreeModelColumn<bool>          active;
+    Gtk::TreeModelColumn<long *>        test;
 
-    ModelColumns() { add(text); add(active); }
+    ModelColumns() { add(text); add(active); add(test); }
   };
 
   ModelColumns                  list_columns_;
@@ -80,7 +83,8 @@
   Gtk::CellRenderer     (),
   property_activatable_ (*this, "activatable", true),
   property_active_      (*this, "active",      false),
-  property_radio_       (*this, "radio",       false)
+  property_radio_       (*this, "radio",       false),
+  property_test_        (*this, "test",        NULL)
 {
   property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
   property_xpad() = 2;
@@ -105,6 +109,11 @@
   return property_radio_.get_proxy();
 }
 
+Glib::PropertyProxy<long *> MyCellRendererToggle::property_test()
+{
+  return property_test_.get_proxy();
+}
+
 SigC::Signal1<void, const Glib::ustring&>& MyCellRendererToggle::signal_toggled()
 {
   return signal_toggled_;
@@ -224,6 +233,7 @@
     tree_view_.append_column(*Gtk::manage(column));
 
     column->add_attribute(renderer->property_active(), list_columns_.active);
+    column->add_attribute(renderer->property_test(), list_columns_.test);
     renderer->signal_toggled().connect(SigC::slot(*this, &AppWindow::on_cell_toggled));
   }
 
@@ -238,6 +248,7 @@
 
     row[list_columns_.text]   = output.str();
     row[list_columns_.active] = ((i % 2) != 0);
+    row[list_columns_.test] = NULL;
   }
 
   show_all_children();


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