#!/usr/bin/perl -w
#This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# use strict ;
use Gtk2 '-init' ;
use constant TRUE => 1 ;
use constant FALSE => 0 ;
$window = Gtk2::Window->new('toplevel');
$window->set_title('flv->mp3 converter');
$window->signal_connect(delete_event => \&delete_event);
$window->set_border_width(10);
$box1 = Gtk2::HBox->new(FALSE, 0);
$window->add($box1);
$window->show;
$box1->show;
$button = Gtk2::Button->new("fichier a ouvrir");
$button->signal_connect(clicked => \&input);
$box1->pack_start($button, TRUE, TRUE, 0);
$button->show;
$button = Gtk2::Button->new("nom du fichier mp3");
$button->signal_connect(clicked => \&output);
$box1->pack_start($button, TRUE, TRUE, 0);
$button->show;
$button = Gtk2::Button->new("convertir");
$button->signal_connect(clicked => \&convert);
$box1->pack_start($button, TRUE, TRUE, 0);
$button->show;
sub delete_event
{
Gtk2->main_quit;
return FALSE;
}
sub input
{
sub main_quit {Gtk2->main_quit;}
# Crée un nouveau widget de sélection de fichiers
$file_dialog = Gtk2::FileSelection->new( "Sélection de fichier" ) ;
$file_dialog->signal_connect(destroy => \&main_quit);
# Connecte le bouton ok à la fonction file_ok_sel
$file_dialog->ok_button->signal_connect( "clicked" ,\&file_ok_sel,$file_dialog ) ;
# Connecte le bouton cancel à la fonction qui détruit le widget
$file_dialog->cancel_button->signal_connect( "clicked" ,sub { Gtk2->main_quit ; } ) ;
# éclare une nom de fichier, comme quand on veut sauver un fichier
# $file_dialog->set_filename( "penguin.png" ) ;
$file_dialog->set_filename( "/home/gentux/" );
$file_dialog->show() ;
# main Gtk2 ;
Gtk2->main;
# Récupère le nom du fichier et l'imprime sur la console
sub file_ok_sel {
( $widget, $file_selection ) = @_ ;
$file_orig = $file_selection->get_filename() ;
print( "$file_orig\n" ) ;
Gtk2->main_quit;
}
}
sub output
{
# Crée un nouveau widget de sélection de fichiers
$file_dialog = Gtk2::FileSelection->new( "Sélection de fichier" ) ;
$file_dialog->signal_connect( "destroy" , sub { Gtk2->main_quit() ; } ) ;
# Connecte le bouton ok à la fonction file_ok_sel
$file_dialog->ok_button->signal_connect( "clicked" ,\&file_ok_sel,$file_dialog ) ;
# Connecte le bouton cancel à la fonction qui détruit le widget
$file_dialog->cancel_button->signal_connect( "clicked" ,sub { Gtk2->main_quit ; } ) ;
# éclare une nom de fichier, comme quand on veut sauver un fichier
# $file_dialog->set_filename( "penguin.png" ) ;
$file_dialog->set_filename( "~" );
$file_dialog->show() ;
Gtk2->main;
# Récupère le nom du fichier et l'imprime sur la console
sub file_ok_sel {
( $widget, $file_selection ) = @_ ;
$file_dest = $file_selection->get_filename() ;
print( "$file_dest\n" ) ;
}
}
sub convertir
{
print "convertit $file_orig en $file_dest /n";
print "do some processing";
}
Gtk2->main;