Advertisement
hackloper775

vterl

Feb 24th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.26 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use Glib qw(TRUE FALSE);
  5. use Gtk2 -init;
  6. use Gnome2::Vte;
  7.  
  8. my $ventana = Gtk2::Window->new;
  9. $ventana->set_default_size(300, 200);
  10. $ventana->set_border_width(5);
  11. my $terminal = Gnome2::Vte::Terminal->new;
  12. #$terminal->set_scroll_background (TRUE); # Hacer que se mueva el fondo de pantalla
  13.  
  14. my $archivo = Gtk2::Menu->new;
  15. my $opciones = Gtk2::Menu->new;
  16.  
  17. my $cambiar_fondo = Gtk2::MenuItem->new( '_Fondo' );
  18. $cambiar_fondo->signal_connect( activate => \&cambiar_fondo );
  19. my $exit = Gtk2::MenuItem->new( '_Salir' );
  20. $exit->signal_connect( activate => sub{ Gtk2::main_quit } );
  21. my $about = Gtk2::MenuItem->new( '_Acerca de...' );
  22. $about->signal_connect( activate => \&acerca_De );
  23.  
  24. $opciones->append( $cambiar_fondo );
  25. $opciones->append( $exit);
  26. $archivo->append( $about );
  27.  
  28. my $menu1 = Gtk2::MenuItem->new( '_Archivo' );
  29. $menu1->set_submenu( $opciones );
  30. my $menu2 = Gtk2::MenuItem->new( 'A_yuda' );
  31. $menu2->set_submenu( $archivo );
  32.  
  33. my $menubar = Gtk2::MenuBar->new;
  34. $menubar->append( $menu1 );
  35. $menubar->append( $menu2 );
  36.  
  37. my $vbox = Gtk2::VBox->new;
  38. $vbox->pack_start ($menubar, TRUE, TRUE, 0);
  39. $vbox->pack_start ($terminal, TRUE, TRUE, 0);
  40.  
  41. $ventana->add ($vbox);
  42. $ventana->show_all;
  43.  
  44. $terminal->fork_command ('/bin/bash', ['bash', '-login'], undef,
  45.                            '~', FALSE, FALSE, FALSE);
  46. $terminal->signal_connect (child_exited => sub { Gtk2->main_quit });
  47.  
  48. $ventana->signal_connect (delete_event =>
  49.                            sub { Gtk2->main_quit; FALSE });
  50.  
  51. Gtk2->main;
  52.  
  53. sub cambiar_fondo {
  54.  
  55. my $imagen_de_fondo = Gtk2::FileChooserDialog->new( 'Elije una imagen...', undef, 'open',
  56. 'gtk-ok' => 'ok',
  57. 'gtk-cancel' => 'cancel' );
  58.  
  59. if( $imagen_de_fondo->run eq 'ok' ) {
  60. my $imagen = $imagen_de_fondo->get_filename;
  61. $terminal->set_background_image_file ($imagen);
  62. $imagen_de_fondo->destroy;
  63.  
  64. } else { print "Error\n";}
  65. }
  66.  
  67. sub acerca_De {
  68. my $acerca_DE = Gtk2::Dialog->new( 'Acerca de...', undef, 'modal',
  69.                    'gtk-ok' => 'ok' );
  70.  
  71. my $acerca =<<EOF;
  72.  
  73. Gtk2/Vte
  74.  
  75. Terminal : Perl para GNU/Linux
  76.  
  77. Por: Atheyus
  78.  
  79. EOF
  80.  
  81. $acerca_DE->vbox->pack_start( Gtk2::Label->new( $acerca ), FALSE, FALSE, 7 );
  82. $acerca_DE->vbox->show_all;
  83.  
  84. if ($acerca_DE->run) { $acerca_DE->destroy }
  85. return TRUE;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement