Gtk-Perl
view release on metacpan or search on metacpan
Gtk/samples/oldtest.pl view on Meta::CPAN
$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) {
set_install_cmap Gtk::Preview 1;
Gtk::Widget->push_visual(Gtk::Preview->get_visual);
Gtk::Widget->push_colormap(Gtk::Preview->get_cmap);
$cs_window = new Gtk::ColorSelectionDialog "color selection dialog";
$cs_window->colorsel->set_opacity(1);
$cs_window->colorsel->set_update_policy(-continuous);
$cs_window->position(-mouse);
signal_connect $cs_window destroy => \&destroy_window, \$cs_window;
$cs_window->colorsel->signal_connect("color_changed", \&color_selection_changed, $cs_window);
$cs_window->ok_button->signal_connect("clicked", \&color_selection_ok, $cs_window);
$cs_window->cancel_button->signal_connect("clicked", sub { destroy $cs_window });
pop_colormap Gtk::Widget;
Gtk/samples/oldtest.pl view on Meta::CPAN
sub notabs_notebook {
my($button, $notebook) = @_;
$notebook->set_show_tabs(0);
if ($notebook->children == 15) {
my($i);
for($i=0;$i<10;$i++) {
$notebook->remove_page(5);
}
}
}
sub scrollable_notebook {
my($button, $notebook) = @_;
$notebook->set_show_tabs(1);
$notebook->set_scrollable(1);
if ($notebook->children == 5) {
create_pages($notebook, 6, 15);
}
}
sub notebook_popup {
my($button, $notebook) = @_;
if ($button->active) {
$notebook->popup_enable;
} else {
$notebook->popup_disable;
}
}
sub create_notebook {
my($box1, $box2, $button, $separator, $notebook, $omenu, $menu, $submenu, $menuitem, $group, $transparent);
if (not defined $notebook_window) {
$notebook_window = new Gtk::Window -toplevel;
$notebook_window->signal_connect("destroy", \&Gtk::Widget::destroyed, \$notebook_window);
$notebook_window->set_title("notebook");
$notebook_window->border_width(0);
$box1 = new Gtk::VBox 0, 0;
$notebook_window->add($box1);
$notebook = new Gtk::Notebook;
$notebook->signal_connect("switch_page", \&page_switch);
$notebook->set_tab_pos(-top);
$box1->pack_start($notebook, 1, 1, 0);
$notebook->border_width(10);
$notebook->realize;
($book_open, $book_open_mask) = Gtk::Gdk::Pixmap->create_from_xpm_d($notebook->window, $transparent, @book_open_xpm);
($book_closed, $book_closed_mask) = Gtk::Gdk::Pixmap->create_from_xpm_d($notebook->window, $transparent, @book_closed_xpm);
create_pages($notebook, 1, 5);
$separator = new Gtk::HSeparator;
$box1->pack_start($separator, 0, 1, 10);
$box2 = new Gtk::HBox 1, 5;
$box1->pack_start($box2, 0, 1, 0);
$omenu = new Gtk::OptionMenu;
$menu = new Gtk::Menu;
$submenu = undef;
$menuitem = undef;
$menuitem = new Gtk::RadioMenuItem "Standard", $menuitem;
$menuitem->signal_connect("activate", \&standard_notebook, $notebook);
$menu->append($menuitem);
$menuitem->show;
$menuitem = new Gtk::RadioMenuItem "w/o Tabs", $menuitem;
$menuitem->signal_connect("activate", \¬abs_notebook, $notebook);
$menu->append($menuitem);
$menuitem->show;
$menuitem = new Gtk::RadioMenuItem "Scrollable", $menuitem;
$menuitem->signal_connect("activate", \&scrollable_notebook, $notebook);
$menu->append($menuitem);
$menuitem->show;
$omenu->set_menu($menu);
$box2->pack_start($omenu, 0, 0, 0);
$button = new Gtk::CheckButton "enable popup menu";
$box2->pack_start($button, 0, 0, 0);
$button->signal_connect("clicked", \¬ebook_popup, $notebook);
$box2 = new Gtk::HBox 0, 10;
$box2->border_width(10);
$box1->pack_start($box2, 0, 1, 0);
$button = new Gtk::Button "close";
$button->signal_connect("clicked", sub {$notebook_window->destroy});
$box2->pack_start($button, 1, 1, 0);
$button->can_default(1);
$button->grab_default;
$button = new Gtk::Button "next";
$button->signal_connect("clicked", sub {$notebook->next_page});
$box2->pack_start($button, 1, 1, 0);
$button = new Gtk::Button "prev";
$button->signal_connect("clicked", sub {$notebook->prev_page});
$box2->pack_start($button, 1, 1, 0);
$button = new Gtk::Button "rotate";
$button->signal_connect("clicked", \&rotate_notebook, $notebook);
$box2->pack_start($button, 1, 1, 0);
}
if (! $notebook_window->visible) {
$notebook_window->show_all;
} else {
$notebook_window->destroy;
}
}
sub create_panes {
my($frame,$hpaned,$vpaned);
if (not defined $paned_window) {
$paned_window = new Gtk::Window "toplevel";
$paned_window->signal_connect("destroy", \&destroy_window, \$paned_window);
$paned_window->signal_connect("delete_event", \&destroy_window, \$paned_window);
$paned_window->set_title("Panes");
$paned_window->border_width(0);
$vpaned = new Gtk::VPaned;
$paned_window->add($vpaned);
$vpaned->border_width(5);
$vpaned->show;
$hpaned = new Gtk::HPaned;
$vpaned->add1($hpaned);
( run in 0.734 second using v1.01-cache-2.11-cpan-39bf76dae61 )