Re: Having issues porting a CellRenderer / CellEditable to Gtk3



On Sun, Jul 8, 2012 at 7:40 PM, Torsten Schoenfeld <kaffeetisch gmx de> wrote:
On 08.07.2012 05:20, Daniel Kasak wrote:
One of my Gtk2 projects has some customer CellRenderers. I've done the
basic s/Gtk2/Gtk3/ on everything ... and now my treeview code is dying with:

GLib-GObject-CRITICAL **: Object class My__CellEditableText doesn't
implement property 'editing-canceled' from interface 'GtkCellEditable'
at
/usr/lib64/perl5/vendor_perl/5.12.4/x86_64-linux-thread-multi/Glib/Object/Subclass.pm
line 233.

That's just a (strong) warning, your program will normally not exit due to this.  Also, if your gtk+ >= 2.20, you will also get this warning with Gtk2.

Ah. Fair enough. I should fix the Gtk2 version too then. Yeah now I look closer, I see it's finally bailing out for another reason :/

Are there any docs on this ( ie what's required when subclassing a
GtkCellEditable ) ... or even better ... what's changed between Gtk2 and
Gtk3 more generally?

Well, what is required to implement an interface actually depends on the interface.  There is some general documentation at <http://developer.gnome.org/gobject/stable/howto-interface.html>, but much of it shows boilerplate code that Glib::Object::Subclass handles for you already.  For GtkCellEditable, it seems like nothing is really required, the default implementations are sufficient.  If you wanted to pass such an editable to code that assumes a fully general editable, maybe something would break, I'm not sure.

To get rid of the property warning, you would use

use Glib::Object::Subclass
  Gtk2::TextView::,
  properties => [
    Glib::ParamSpec->boolean (
      'editing-canceled',
      'Editing canceled',
      'Editing canceled',
      Glib::FALSE,
      [qw/readable writable/]
    ),
  ],
  interfaces => [ Gtk2::CellEditable:: ];

But that doesn't currently work correctly, at least on my machine, because the order that the 'properties' and 'interfaces' args from above reach the type registration machinery is currently random.  The warning occurs if 'interfaces' is processed before 'properties'.  The attached patch to Glib fixes this for me.

Also, this warning would not occur if Glib handled interface properties more smartly: <http://bugzilla.gnome.org/show_bug.cgi?id=570792>.

For now, I think it's safe for you to ignore this warning.
 
Thankyou very much for looking into this and giving a detailed answer, Torsten. Much appreciated.

Dan


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