ItemFactory things and callback doesn't working



So. Some playing with ItemFactory things. Actually the menu is working (i 
attached or copy a small source for this) but i got errors about callbacks!

(x.pl:21909): GLib-GObject-CRITICAL **: file gobject.c: line 1413 
(g_object_set_data): assertion `G_IS_OBJECT (object)' failed

(x.pl:21909): GLib-GObject-WARNING **: invalid (NULL) pointer instance

(x.pl:21909): GLib-GObject-CRITICAL **: file gsignal.c: line 1861 
(g_signal_connect_data): assertion `G_TYPE_CHECK_INSTANCE (instance)' failed

This error messages and the callback doesn't working. What's wrong ?

Best regards:
Christian Hamar alias kRiX


#!/usr/bin/perl -w

use Gtk2;

init Gtk2;

$m{'win'} = new Gtk2::Window;
$m{'win'}->signal_connect('delete-event', sub { Gtk2->main_quit; });
$m{'win'}->set_title("TEST");

$m{'vbox'} = new Gtk2::VBox(0,1);
$m{'win'}->add($m{'vbox'});

@menu_items = (
{
        path            => '/Main',
        type            => '<Branch>'
},
{
        path            => '/Main/_TV',
        accelerator     => '<control>T',
        callback        => \&do_some
},
{
        path            => '/Main/_Print',
        accelerator     => '<control>P',
        callback        => \&do_print
},
{
        path            => '/Main/_Exit',
        accelerator     => '<control>E',
        callback        => sub {Gtk2->main_quit;}
},
{
        path            => '/Perfs',
        type            => '<Branch>'
},
{
        path            => '/Perfs/_Settings',
        accelerator     => '<control>S',
        callback        => \&do_settings
},
{
        path            => 'Help',
        type            => '<Branch>'
},
{
        path            => '/Help/About',
        callback        => \&do_about
}
);

$m{'menubar'} = create_menubar( $m{'win'} );
$m{'vbox'}->pack_start($m{'menubar'}, 0, 1, 0);

sub create_menubar {
        my  ( $window ) = @_;
        my $item_factory;
        my $accel_group;
        $accel_group = new Gtk2::AccelGroup();
        $item_factory = new Gtk2::ItemFactory( 'Gtk2::MenuBar', '<main>', 
$accel_group);
        $item_factory->create_items( @menu_items);
        $window->add_accel_group($accel_group);
        return ($item_factory->get_widget('<main>'));
}

$m{'win'}->show_all;


main Gtk2;





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