Gtk-Perl
view release on metacpan or search on metacpan
Gtk/samples/oldtest.pl view on Meta::CPAN
sub shape_create_icon {
my($xpm_file, $x, $y, $px, $py, $window_type) = @_;
my($window, $pixmap, $fixed, $gc, $gdk_pixmap_mask, $gdk_pixmap, $style);
$style = Gtk::Widget->get_default_style;
$gc = $style->black;#_gc;
$window = new Gtk::Window $window_type;
$fixed = new Gtk::Fixed;
$fixed->set_usize(100,100);
$window->add($fixed);
show $fixed;
$window->set_events( [@{$window->get_events}, 'button_motion_mask', 'pointer_motion_hint_mask', 'button_press_mask']);
realize $window;
($gdk_pixmap, $gdk_pixmap_mask) = Gtk::Gdk::Pixmap->create_from_xpm($window->window, $style->bg('normal'), $xpm_file);
$pixmap = new Gtk::Pixmap $gdk_pixmap, $gdk_pixmap_mask;
$fixed->put($pixmap, $px, $py);
show $pixmap;
$window->shape_combine_mask($gdk_pixmap_mask, $px, $py);
$window->signal_connect('button_press_event', \&shape_pressed);
$window->signal_connect('button_release_event', \&shape_released);
$window->signal_connect('motion_notify_event', \&shape_motion);
$window->set_uposition($x,$y);
$window->show;
$window;
}
sub destroy_window {
my($widget, $windowref, $w2) = @_;
$$windowref = undef;
$w2 = undef if defined $w2;
0;
}
sub button_window {
my($widget,$button) = @_;
if (! $button->visible) {
show $button;
} else {
hide $button;
}
}
sub create_shapes {
$root_win = Gtk::Gdk::Window->new_foreign(Gtk::Gdk->ROOT_WINDOW());
if (not defined $modeller) {
$modeller = shape_create_icon("Modeller.xpm", 440, 140, 0,0, -popup);
$modeller->signal_connect("destroy", \&Gtk::Widget::destroyed, \$modeller);
} else {
destroy $modeller;
}
if (not defined $sheets) {
$sheets = shape_create_icon("FilesQueue.xpm", 580,170, 0,0, -popup);
$sheets->signal_connect("destroy", \&Gtk::Widget::destroyed, \$sheets);
} else {
destroy $sheets;
}
if (not defined $rings) {
$rings = shape_create_icon("3DRings.xpm", 460, 270, 25,25, -toplevel);
$rings->signal_connect("destroy", \&Gtk::Widget::destroyed, \$rings);
} else {
destroy $rings;
}
}
sub create_buttons {
my($box1, $box2, $table, @button, $separator);
if (not defined $buttons_window) {
$buttons_window = new Gtk::Window 'toplevel';
signal_connect $buttons_window "destroy", \&destroy_window, \$buttons_window;
signal_connect $buttons_window "delete_event", \&destroy_window, \$buttons_window;
$buttons_window->set_title("buttons");
$buttons_window->border_width(0);
$box1 = new Gtk::VBox 0, 0;
$buttons_window->add($box1);
$box1->show;
$table = new Gtk::Table (3,3, 0);
$table->set_row_spacings(5);
$table->set_col_spacings(5);
$table->border_width(10);
$box1->pack_start($table, 1, 1, 0);
$table->show;
for (0..8) { $button[$_] = new Gtk::Button "button".($_+1); }
$button[0]->signal_connect("clicked", \&button_window, $button[1]);
$table->attach($button[0], 0, 1, 0, 1, {expand=>1,fill=>1}, {expand=>1,fill=>1},0,0);
$button[0]->show;
$button[1]->signal_connect("clicked", \&button_window, $button[2]);
$table->attach($button[1], 1, 2, 1, 2, {expand=>1,fill=>1}, {expand=>1,fill=>1},0,0);
$button[1]->show;
$button[2]->signal_connect("clicked", \&button_window, $button[3]);
$table->attach($button[2], 2, 3, 2, 3, ["expand","fill"], ["expand","fill"],0,0);
$button[2]->show;
$button[3]->signal_connect("clicked", \&button_window, $button[4]);
$table->attach($button[3], 0, 1, 2, 3, ["expand","fill"], ["expand","fill"],0,0);
$button[3]->show;
$button[4]->signal_connect("clicked", \&button_window, $button[5]);
$table->attach($button[4], 2, 3, 0, 1, ["expand","fill"], ["expand","fill"],0,0);
$button[4]->show;
$button[5]->signal_connect("clicked", \&button_window, $button[6]);
$table->attach($button[5], 1, 2, 2, 3, ["expand","fill"], ["expand","fill"],0,0);
$button[5]->show;
Gtk/samples/oldtest.pl view on Meta::CPAN
$pixwid = new Gtk::Pixmap $book_closed, $book_closed_mask;
$label_box->pack_start($pixwid, 0, 1, 0);
$pixwid->set_padding(3, 1);
$label = new Gtk::Label $buffer;
$label_box->pack_start($label, 0, 1, 0);
show_all $label_box;
$menu_box = new Gtk::HBox 0, 0;
$pixwid = new Gtk::Pixmap $book_closed, $book_closed_mask;
$menu_box ->pack_start($pixwid, 0, 1, 0);
$pixwid->set_padding(3,1);
$label = new Gtk::Label $buffer;
$menu_box->pack_start($label, 0, 1, 0);
show_all $menu_box;
$notebook->append_page_menu($child, $label_box, $menu_box);
}
}
sub rotate_notebook {
my($button, $notebook) = @_;
my(%rotate) = (top => "right", right => "bottom", bottom => "left", left => "top");
$notebook->set_tab_pos($rotate{$notebook->tab_pos});
}
sub standard_notebook {
my($button, $notebook) = @_;
$notebook->set_show_tabs(1);
$notebook->set_scrollable(0);
if ($notebook->children == 15) {
my($i);
for($i=0;$i<10;$i++) {
$notebook->remove_page(5);
}
}
}
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);
$frame = new Gtk::Frame;
$frame->set_shadow_type("in");
$frame->set_usize(60,60);
$hpaned->add1($frame);
$frame->show;
$frame = new Gtk::Frame;
$frame->set_shadow_type("in");
( run in 2.140 seconds using v1.01-cache-2.11-cpan-364913b4093 )