Re: Can't locate object method "add_actions"...



On 10.06.2012 17:49, Dave M wrote:
Ok, here's a first attempt.  Most everything works, but there's one
bug I haven't solved - the radio_actions signal_connect is on hyper
mode for some reason.  Any pointers as to why is appreciated.

See below.

Anyway, the tar.gz contains a diff, the Gtk3.pm, and a Gtk3 version of
UI Manager for testing.  The uimanager.pl is set to use the Gtk3 from
the current directory (with use lib '.') and to be easily added to a
future Perl version of gtk3-demo.

Feedback is more than welcome.

Alright, let's get the trivial stuff out of the way first:

• Please avoid unrelated changes like these:

-use Carp qw/croak/;
+use Carp 'croak';

-our @ISA = qw(Exporter);
+our @ISA = 'Exporter';

• Please adapt to the style of the surrounding code. In this case this means indentation with two spaces (not tabs) and slightly different spacing around parens.

On to the actual meat.  In general: looking good already!  Some comments:

• The XS code allowed the entries to be either array or hash references. It would be nice to preserve this.

• To check the type of a reference, the XS code and your code look at ref($entries). This does not work for things like overloading or tie-ing, so it might be better to simply check whether the thing can be used as an array ref. Something like:

  $is_arrayref = eval { @$entries; 1 }

• The code

  if( ! $user_data ) {
    $action->signal_connect( 'activate', $callback );
  } else {
    $action->signal_connect( 'activate', $callback, $user_data );
  }

should simply be

  $action->signal_connect( 'activate', $callback, $user_data );

Even if the user data evaluates to false, it should still be passed to the callback. (And signal_connect handles undef for the user data just fine.)

• Good idea to use add_action_with_accel to save code!

• Gtk3::ActionGroup::add_actions doesn't seem to translate the label and the tooltip.

• Ah, now I see what you meant by "hyper mode" above. The problem is that you connect to $first_action's changed signal anew each time the loop is run. The code block should be moved outside the loop.

• The example program is very good to have, but it would also be good to have unit tests for the three overrides.



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