Re: gnome_app_create_menu hack



The mnemonic's work, I must be on drugs.

On Thu, 17 Apr 2003, Chas Owens wrote:


Being my lazy self I have hacked together a quick Perl
based replacement for Gnome2::App->create_menus().  It
doesn't handle images yet and there seems to be something
wrong with the mnemonic (it underlines, but does work),
but at least I can test some more of Gtk2-Perl-XS.

This does raise a point though: should we implement this
(and possibly other things) in XS when when we can just
as easily do them in Perl?

package Gnome2::App;

sub create_menus {
        my $app = shift;
        my $menu = Gtk2::MenuBar->new;
        $app->set_menus(_create_menus($menu, @_));
        $menu->show_all;
}

sub _create_menus {
        my $menu = shift;
        for my $ui (@_) {
                if ($ui->{type} eq 'subtree') {
                        my $item    = Gtk2::MenuItem->new_with_mnemonic(
                                $ui->{label}
                        );
                        my $submenu = Gtk2::Menu->new;
                        $item->set_submenu($submenu);
                        $menu->append($item);
                        _create_menus($submenu, @{$ui->{subtree}});
                        $item->set_submenu($submenu);
                } elsif ($ui->{type} eq 'item') {
                        my $item = Gtk2::MenuItem->new_with_mnemonic(
                                $ui->{label}
                        );
                        $item->signal_connect('activate', $ui->{callback});
                        $menu->append($item);
                }
        }
        return $menu;
}
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list





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