UIManager and Menus in Toolbars


I am attempting to use GtkUIManager to create a toolbar with a GtkMenuToolButton item. The documentation for GtkUIManager has this to say:

a GtkToolItem <http://library.gnome.org/devel/gtk/stable/GtkToolItem.html> subclass, the exact type depends on the action. Note that toolitem elements may contain a menu element, but only if their associated action specifies a GtkMenuToolButton <http://library.gnome.org/devel/gtk/stable/GtkMenuToolButton.html> as proxy

But i'm not exactly sure what that means.

I tried using the connect_proxy function with a Gtk2::MenutToolButton:

I also tried this:

The documentation says the connect proxy method is deprecated since 2.16 - which is what I am running - and that is should use |gtk_activatable_set_related_action()| <http://library.gnome.org/devel/gtk/unstable/GtkActivatable.html#gtk-activatable-set-related-action> - but calling set_related_function on a Gtk2::MenuToolButton throws an error saying can't find set_related_action.

Any insight or advice would greatly appreciated. Thank you.

Here is the error I get:
GLib-GObject-WARNING **: invalid cast from `GtkToolButton' to `GtkMenuToolButton ' at ../lib/TIMs/GUI/Browser/Employee.pm line 126. Gtk-CRITICAL **: gtk_menu_tool_button_set_menu: assertion `GTK_IS_MENU_TOOL_BUTT ON (button)' failed at ../lib/TIMs/GUI/Browser/Employee.pm line 126. Terminating on signal SIGINT(2)

Here is the entire function(shortened):
sub _build_toolbar {
   my $self = shift;
my $ui = Gtk2::UIManager->new;
my %actions = (
       DefaultEmployeeAction => Gtk2::Action->new(
           name    => 'DefaultEmployeeAction'       ,
           label   => 'Employees'                    ,
           tooltip => 'Employees'                   ,
           'stock-id' => 'gtk-new'        ,
       EmployeeMenuAction => Gtk2::Action->new(
           name    => 'EmployeeMenuAction'       ,
           label   => 'Employees'                    ,
           tooltip => 'Employees'                   ,
           'stock-id' => 'gtk-new'        ,
), OpenNewEmployeeWizard => Gtk2::Action->new(
           name    => 'OpenNewEmployeeWizard'       ,
           label   => '_New Employee'               ,
           tooltip => 'Hire new employee'           ,
           'stock-id' => 'gtk-new'        ,

   for (keys %actions) {
       my $method = '_do_action_' . $_;
       $actions{$_}->signal_connect('activate' => sub { $self->$method });
my $action_group = Gtk2::ActionGroup->new('EmployeeBrowser');
   $action_group->add_action($_) for values %actions;
   $ui->insert_action_group($action_group, 0);
my $toolbar = $ui->get_widget('/EmployeeBrowserToolbar');
   return $toolbar;

and here is the xml (shortened):
<?xml version="1.0" encoding="UTF-8"?>

 <toolbar name="EmployeeBrowserToolbar">
     <toolitem action="DefaultEmployeeAction">
       <menu action="EmployeeMenuAction">
           <menuitem action="OpenNewEmployeeWizard"       />

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