Re: Help! Custom cell renderers blowing up ...

On 21.02.2013 07:28, Dan Kasak wrote:
Can't locate object method "EDITING_STARTED" via package
"Gtk3::Ex::Datasheet::DBI::CellRendererText" at
/usr/lib64/perl5/site_perl/5.12.4/ line 228.

I don't get this with my Gtk3 port of odot, so… no clue off-hand. Can you provide a self-contained example program exhibiting this?

 From my searching around, 'editing_started' is a signal, not a method.
What's going on?

It is a signal, but it is also a virtual function in the GtkCellRenderer interface. Glib::Object::Introspection maps the names of virtual functions to upper-case letters and calls them automatically on your Perl object if they were invoked on the underlying C object. I haven't given much thought to virtual functions which are also signals, so maybe the problem is here somewhere.

Some more comments on the code:

package Gtk3::Ex::Datasheet::DBI::CellEditableText;

You might have to put empty implementations of the virtual functions of Gtk3::CellEditable here:

  # do nothing

  # do nothing

  # do nothing

In contrast to Gtk2's wrapper of this interface, Glib::Object::Introspection's generic wrapper does no runtime checks for the existence of a sub before forwarding a call to it.

package Gtk3::Ex::Datasheet::DBI::CellRendererText;


use Glib::Object::Subclass
   properties => [
                                                     "Editable widget",
                                                     "The editable
that's used for cell editing.",

                                                     [ qw( readable
writable ) ]

Do you need this property? It was a hack in Odot, and I've now removed it. If you don't need it, you can also consider moving the creation of the editable from INIT_INSTANCE to START_EDITING.

         # TODO: Find these constants ...
         if (
             $event->keyval == $Gtk3::Gdk::KEY_RETURN ||
             $event->keyval == $Gtk3::Gdk::KEY_KP_ENTER
             and not $event-> state & qw(control-mask)

They are constant subs now, named Gtk3::Gdk::KEY_Return, Gtk3::Gdk::KEY_KP_Enter, etc. Simply change every instance of $Gtk2::Gdk::Keysyms{ xxx } to Gtk3::Gdk::KEY_xxx, preserving the case of "xxx".

             # For some reason, the last item returned by the above call to
             # $parent->get_columns isn't a Gtk3::TreeViewColumn, and
             # the $parent_set_cursor line fails. Avoid this.
             if ( ref $next_col eq 'Gtk3::TreeViewColumn' ) {
                 $parent->set_cursor ( $path, $next_col, 1 )
                     if $next_col;

That shouldn't happen.  What is the last item if it's not a column?

     $editable->signal_connect( editing_done => sub {[...]});

As of gtk+ 2.6, the editing-done callback should look like this:

  $editable -> signal_connect(editing_done => sub {
    my ($editable) = @_;
    my $canceled = $editable -> get('editing-canceled');
      # or $editable -> { _editing_canceled } if you store it directly
    $cell -> stop_editing($canceled);
    unless ($canceled) {
      $cell -> signal_emit(edited => $path, $editable -> get_text());

sub GET_SIZE {

     my ( $self, $widget, $cell_area ) = @_;

     return $self->SUPER::GET_SIZE ( $widget, $cell_area );


If you simply chain up, you can also just not provide any implementation at all. The effect will be the same, but it will be faster as it avoids the roundtrip marshalling of the arguments from C to Perl back to C. (And GET_SIZE will be called a lot.)

     #$editable->modify_font( Gtk2::Pango::FontDescription->from_string(
"Arial " . $cell->get( "font" ) ) );
     $editable->modify_font( Pango::FontDescription->from_string( "Arial
" . $cell->get( "font" ) ) );

Do you really want to hard-code a particular font here, completely ignoring the user's preference? If you want to modify the font size, use the Gtk3::CellRendererText's "size" property (which you inherit in your cell renderer).

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