添加更多的东西
GNOME 系统还提供另外两个很有特色的交互项:工具栏和状态栏。我们首先添加工具栏,在添加菜单的语句后添加下面的语句:
$app->create_toolbar( { type => 'item', label => 'Exit', pixmap_type => 'stock', pixmap_info => 'Quit', hint => "Click here to quit", callback => sub { Gtk->main_quit }, }, { type => 'item', label => 'About...', pixmap_type => 'stock', pixmap_info => 'About', hint => "More information about this app", callback => chunk73189426chunk#38;about_box } );
我们同样给 creat_toolbar 函数传递了一系列的匿名散列,而且散列的很多关键值都是你熟悉的。hint 关键值的内容定义当鼠标旋停在按钮上的时候显示的内容。而每个选项绑定的处理函数和选项的图标都和前面一样。 接着添加状态栏:
my $bar = new Gnome::AppBar 0,1,"user" ; $bar->set_status(" Welcome "); $app->set_statusbar( $bar );
首先,创建一个 AppBar 实例,它是一个程序的状态栏。然后用 set_status 定义状态栏的初始信息。状态栏到现在就已经存在了,但是还不会在屏幕上被显示出来。因为还没有指定它是属于整个 GNOME 环境中那个应用程序。所以我们用 set_statusbar 方法给它指定归属。现在它就会在主窗口中显示出来了。