From ca21adebf1265b649ccf42fe6bdca13163a9fb59 Mon Sep 17 00:00:00 2001 From: freesource Date: Sat, 9 Dec 2000 20:23:09 +0000 Subject: [PATCH] * The beginnings of a menu. --- YardBox.pm | 79 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 7 deletions(-) diff --git a/YardBox.pm b/YardBox.pm index 98b4b82..12dfc0c 100644 --- a/YardBox.pm +++ b/YardBox.pm @@ -31,17 +31,48 @@ use Yard; use Error; my $yard_window; +my $item_factory; +my $accel_group; my $true = 1; my $false = 0; +my @menu_items = ( { path => '/File', + type => '' }, + { path => '/File/file_tearoff', + type => '' }, + { path => '/File/_Save', + accelerator => 'S', + callback => sub { print "hello"; } }, + { path => '/File/Save _As ...', + accelerator => 'A', + callback => sub { print "hello\n"; } }, + { path => '/File/file_separator', + type => '' }, + { path => '/File/_Close', + callback => sub { destroy $yard_window; }}, + + { path => '/_Edit', + type => '' }, + + { path => '/_Create', + type => '' }, + + { path => '/_Tests', + type => '' }, + + { path => '/_Help', + type => '' }, + { path => '/_Help/Tutorial' }, + { path => '/_Help/Shortcuts' } ); + ###### # YARD ###### sub yard { - + my ($kernel,$template_dir,$template) = @_; my $error; - + # Error handling in Yard will take some strategy if (!-d $kernel && -f $kernel) { $error = kernel_version_check($kernel); @@ -64,7 +95,7 @@ sub yard { $error = read_contents_file("$template_dir$template"); return if $error && $error eq "ERROR"; - + ## $error = extra_links("$template_dir$template"); ## return if $error && $error eq "ERROR"; @@ -99,11 +130,16 @@ sub yard_box { $yard_window->add( $main_vbox ); $main_vbox->show(); - my $vbox = new Gtk::HBox( $false, 50 ); - $vbox->border_width( 10 ); - $main_vbox->pack_start( $vbox, $false, $true, 0 ); + my $vbox = new Gtk::VBox( $false, 0 ); + $vbox->border_width( 0 ); + $main_vbox->pack_start( $vbox, $false, $false, 0 ); $vbox->show(); + # Item::Factory + my $menubar = yard_menu($yard_window); + $vbox->pack_start( $menubar, $false, $true, 0 ); + $menubar->show(); + $vbox = new Gtk::VBox( $false, 10 ); $vbox->border_width( 10 ); $main_vbox->pack_start( $vbox, $true, $true, 0 ); @@ -206,10 +242,39 @@ sub yard_box { sub { destroy $yard_window; } ); $vbox->pack_start( $button, $true, $true, 0 ); $button->show(); - + show $yard_window; } # end sub yard_box +sub print_hello { + my ($menu_item, $action, $date) = @_; + + $menu_item->set_active($true); + print $menu_item; + + +} + +sub yard_menu { + + my ($window) = @_; + + $accel_group = new Gtk::AccelGroup(); + $item_factory = new Gtk::ItemFactory( 'Gtk::MenuBar', '
', + $accel_group ); + $accel_group->attach($window); + $item_factory->create_items(@menu_items); + + # Manipulate Gtk::ItemFactory - The trick here is to use the real path. + ##my $checkbox = $item_factory->get_item("/File/CheckBox"); + ##$checkbox->set_active($true); + + return ( $item_factory->get_widget( '
' ) ); + +} 1; + + +