Gtk
view release on metacpan or search on metacpan
test.pl.old view on Meta::CPAN
$scrolled_win->set_policy(-automatic, -automatic);
$box2->pack_start($scrolled_win, 1, 1, 0);
$scrolled_win->show;
$list = new Gtk::List;
$list->set_selection_mode(-multiple);
$list->set_selection_mode(-browse);
$scrolled_win->add($list);
$list->show;
for($i=0;$i<@list_items;$i++)
{
$list_item = new Gtk::ListItem($list_items[$i]);
$list->add($list_item);
$list_item->show;
}
$button = new Gtk::Button "add";
$button->can_focus(0);
$button->signal_connect("clicked", \&list_add, $list);
$box2->pack_start($button, 0, 1, 0);
$button->show;
$button = new Gtk::Button "remove";
$button->can_focus(0);
$button->signal_connect("clicked", \&list_remove, $list);
$box2->pack_start($button, 0, 1, 0);
$button->show;
$separator = new Gtk::HSeparator;
$box1->pack_start($separator, 0, 1, 0);
$separator->show;
$box2 = new Gtk::VBox(0,10);
$box2->border_width(10);
$box1->pack_start($box2, 0, 1, 0);
$box2->show;
$button = new Gtk::Button "close";
$button->signal_connect("clicked", sub { destroy $list_window});
$box2->pack_start($button, 1, 1, 0);
$button->can_default(1);
$button->grab_default;
$button->show;
}
if (not $list_window->visible) {
show $list_window;
} else {
destroy $list_window;
}
}
sub create_menu {
my($depth) = @_;
my($menu,$submenu,$menuitem);
if ($depth<1) {
return undef;
}
$menu = new Gtk::Menu;
$submenu = undef;
$menuitem = undef;
my($i,$j);
for($i=0,$j=1;$i<5;$i++,$j++)
{
my($buffer) = sprintf("item %2d - %d", $depth, $j);
$menuitem = new Gtk::RadioMenuItem($buffer, $menuitem);
$menu->append($menuitem);
$menuitem->show;
if ($depth>0) {
if (not defined $submenu) {
$submenu = create_menu($depth-1);
$menuitem->set_submenu($submenu);
}
}
}
return $menu;
}
sub create_menus {
my($box1,$box2,$button,$menu,$menubar,$menuitem,$optionmenu,$separator);
if (not defined $menu_window) {
$menu_window = new Gtk::Window -toplevel;
signal_connect $menu_window destroy => \&destroy_window, \$menu_window;
$menu_window->set_title("menus");
$menu_window->border_width(0);
$box1 = new Gtk::VBox(0,0);
$menu_window->add($box1);
$box1->show;
$menubar = new Gtk::MenuBar;
$box1->pack_start($menubar, 0, 1, 0);
$menubar->show;
$menu = create_menu(2);
$menuitem = new Gtk::MenuItem("test");
$menuitem->set_submenu($menu);
$menubar->append($menuitem);
show $menuitem;
$menuitem = new Gtk::MenuItem("foo");
$menuitem->set_submenu($menu);
$menubar->append($menuitem);
show $menuitem;
$menuitem = new Gtk::MenuItem("bar");
$menuitem->set_submenu($menu);
$menubar->append($menuitem);
show $menuitem;
$box2 = new Gtk::VBox(0,10);
$box2->border_width(10);
$box1->pack_start($box2, 1, 1, 0);
$box2->show;
$optionmenu = new Gtk::OptionMenu;
$optionmenu->set_menu(create_menu(1));
$optionmenu->set_history(4);
$box2->pack_start($optionmenu, 1, 1, 0);
$optionmenu->show;
$separator = new Gtk::HSeparator;
$box1->pack_start($separator, 0, 1, 0);
show $separator;
$box2 = new Gtk::VBox(0,10);
$box2->border_width(10);
$box1->pack_start($box2, 0, 1, 0);
$box2->show;
$button = new Gtk::Button "close";
signal_connect $button clicked => sub { destroy $menu_window};
$box2->pack_start($button, 1, 1, 0);
$button->can_default(1);
$button->grab_default;
$button->show;
}
if (!visible $menu_window) {
show $menu_window;
} else {
destroy $menu_window;
}
}
sub color_selection_ok {
my($widget, $dialog) = @_;
my(@color) = $dialog->colorsel->get_color;
print "color=@color\n";
$dialog->colorsel->set_color(@color);
}
sub color_selection_changed {
my($widget, $dialog) = @_;
my(@color) = $dialog->colorsel->get_color;
print "color=@color\n";
}
sub create_color_selection {
if (not defined $cs_window) {
print "1\n";
set_install_cmap Gtk::Preview 1;
print "2\n";
Gtk::Widget->push_visual(Gtk::Preview->get_visual);
print "3\n";
Gtk::Widget->push_colormap(Gtk::Preview->get_cmap);
print "4\n";
$cs_window = new Gtk::ColorSelectionDialog "color selection dialog";
print "5\n";
$cs_window->colorsel->set_opacity(1);
print "6\n";
$cs_window->colorsel->set_update_policy(-continuous);
print "7\n";
( run in 0.517 second using v1.01-cache-2.11-cpan-39bf76dae61 )