Gtk
view release on metacpan or search on metacpan
$box2->border_width(10);
$box1->pack_start($box2, 1, 1, 0);
$box2->show;
$clist->set_row_height(20);
for $i ( 1 .. scalar(@titles) - 1 ) {
$clist->set_column_width($i, 80);
}
$clist->set_selection_mode('browse');
$clist->set_policy ('automatic', 'automatic');
$clist->set_column_justification(1, 'right');
$clist->set_column_justification(2, 'left');
for $i ( 0 .. scalar(@titles) - 1 ) {
$text[$i] = "Column $i";
}
$text[1] = 'Right';
$text[2] = 'Center';
shift( @text );
# FIXME
for $i ( 0 .. 100 ) {
$clist->append("Row $i", @text);
}
$clist->border_width(5);
$box2->pack_start($clist, 1, 1, 0);
$clist->show;
$separator = new Gtk::HSeparator;
$separator->show;
$box1->pack_start($separator, 0, 1, 0);
$box2 = new Gtk::VBox(0, 10);
$box2->border_width(10);
$box1->pack_start($box2, 1, 1, 0);
$box2->show;
$button = new Gtk::Button('close');
$button->signal_connect('clicked', sub {$clist_window->destroy});
$button->can_default(1);
$button->grab_default;
$box2->pack_start($button, 1, 1, 0);
$button->show;
}
if (not $clist_window->visible) {
show $clist_window;
} else {
destroy $clist_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->set_show_toggle(1) if $depth % 2;
$menuitem->show;
if ($depth>1) {
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;
signal_connect $menu_window delete_event => \&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;
$menu = create_menu(3);
$menuitem = new Gtk::MenuItem("foo");
$menuitem->set_submenu($menu);
$menubar->append($menuitem);
show $menuitem;
$menu = create_menu(4);
$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.715 second using v1.01-cache-2.11-cpan-39bf76dae61 )