File: gdrae

package info (click to toggle)
gdrae 0.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 84 kB
  • ctags: 8
  • sloc: makefile: 40; perl: 38
file content (43 lines) | stat: -rwxr-xr-x 1,595 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl
use strict;
use Gtk2 -init;
use Gtk2::GladeXML;

my($ventana, $main_window, $boton_salir, $resultado, $buscar, $etiqueta_a_buscar, $acerca, $guardar);
$ventana = Gtk2::GladeXML->new('/usr/share/gdrae/rae.glade');
#$ventana = Gtk2::GladeXML->new('glade/rae.glade');
$main_window = $ventana->get_widget('ventana_principal');
$boton_salir =  $ventana->get_widget('salir');
$resultado = $ventana->get_widget('resultado');
$buscar = $ventana->get_widget('buscar');
$etiqueta_a_buscar = $ventana->get_widget('etiqueta_buscar');
$acerca = $ventana->get_widget('acerca');
$guardar = $ventana->get_widget('guardar');
$ventana->signal_autoconnect_from_package('main');
$boton_salir->signal_connect(clicked => \&salir);
$buscar->signal_connect(clicked => \&buscar);

Gtk2->main;

sub salir {Gtk2->main_quit;}
sub boton_menu_quit {Gtk2->main_quit;}
sub on_salir2_activate {Gtk2->main_quit;}
sub on_acerca_de1_activate {$acerca->show_all;}
sub on_cerrar_about_clicked {$acerca->hide;}
sub on_ventana_principal_delete_event {Gtk2->main_quit;}
sub on_guardar2_activate {$guardar->show_all;}
sub buscar {
	my (@texto, $palabra);
	$palabra = $etiqueta_a_buscar->get_text();
	unless(-e '/tmp/gdrae'){
		mkdir('/tmp/gdrae', 0777) or die;
	}
	system("lynx -dump --nolist \"http://buscon.rae.es/draeI/SrvltGUIBusUsual?LEMA=$palabra\" > /tmp/gdrae/palabra");
	open(RESULTADO, '/tmp/gdrae/palabra') or die("No pude crear/abrir el archivo, el terminal devolviļæ½ $!");
	while(<RESULTADO>){
		push(@texto, $_);
	}
	close(RESULTADO);
	chmod(0777, '/tmp/gdrae/palabra');
	$resultado->set_markup("@texto");
}