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.

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.
diff --git a/lib/Glib/Object/Subclass.pm b/lib/Glib/Object/Subclass.pm
index 1652d8e..5968b65 100644
--- a/lib/Glib/Object/Subclass.pm
+++ b/lib/Glib/Object/Subclass.pm
@@ -227,12 +227,12 @@ sub import {
    # ignore anything that doesn't look like a registration attempt.
    return unless @_ > 1;
 
-   my ($self, $superclass, %arg) = @_;
+   my ($self, $superclass, @args) = @_;
    my $class = caller;
 
    Glib::Type->register_object(
       $superclass, $class,
-      %arg,
+      @args,
    );
 
    # ensure that we have a perlish new().  the old version of this
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list

Reply via email to