Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
utilisateurs:kamui57:guimp3report [Le 25/08/2010, 12:57] – créée kamui57 | utilisateurs:kamui57:guimp3report [Le 25/08/2010, 14:40] (Version actuelle) – kamui57 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== GUI pour mp3report ====== | ||
+ | |||
+ | <note warning> | ||
+ | Ce script ne fonctionne pas encore, merci de ne pas l' | ||
+ | </ | ||
+ | |||
+ | ===== Captures d' | ||
+ | * Le script commence par vérifier les dépendances (zenity et mp3report). Si au moins l'une d' | ||
+ | |||
+ | {{http:// | ||
+ | |||
+ | * Ensuite, la boîte de dialogue permettant de choisir les options grâce à des cases à cocher s' | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * Si l'on a choisi l' | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * Dans ce cas, si l'on rentre un titre vide, on est averti que cette option ne sera finalement pas prise en compte. | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * Si l'on a choisi l' | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * Dans ce dernier cas (fichier), une boîte de dialogue nous invite alors à le choisir. | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * Si l'on clique sur " | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * Si l'on a choisi l' | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * C'est ce que la fenêtre suivante propose. C'est une fenêtre de même type que celle pour le fichier de sortie. | ||
+ | |||
+ | * Si l'on clique sur " | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * Dernière étape, le choix du/des répertoires à scanner, précédé encore une fois par une fenêtre d' | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * Le choix des répertoires est proposé. | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | * Si l' | ||
+ | | ||
+ | {{http:// | ||
+ | |||
+ | ===== Fichiers ===== | ||
+ | Ce script a pour but de donner une interface graphique à mp3report. Il est composé de plusieurs fichiers : | ||
+ | * GUImp3report.bash : script principal | ||
+ | * controldependencies.bash : contrôle de la présence de zenity et mp3report | ||
+ | * init.bash : initialisation des variables | ||
+ | * chooseoptions.bash : boite de choix des options (cases à cocher) | ||
+ | * chooseparameters.bash : choix des paramètres pour les options cochées qui en demandent | ||
+ | * choosedirectories.bash : choix des répertoires à scanner | ||
+ | * buildcommandline.bash : construction de la commande à exécuter | ||
+ | * executecommand.bash : confirmation de l' | ||
+ | |||
+ | ==== GUImp3report.bash ==== | ||
+ | <code bash># | ||
+ | |||
+ | ################################################################ | ||
+ | # Asks for the options and parameters for the " | ||
+ | # command and executes it, all this in a gui (zenity) | ||
+ | # # | ||
+ | # Auteur : kamui57 < kamui_57 AT yahoo DOT fr > # | ||
+ | # # | ||
+ | # Licence : Ce script est un logiciel libre ; vous pouvez le # | ||
+ | # redistribuer et/ou le modifier selon les termes de la # | ||
+ | # Licence Publique Générale GNU ( GNU GPL ) publiée par la Free# | ||
+ | # Software Foundation. | ||
+ | ################################################################ | ||
+ | |||
+ | source $HOME/ | ||
+ | |||
+ | source $HOME/ | ||
+ | |||
+ | source $HOME/ | ||
+ | |||
+ | if [ " | ||
+ | then | ||
+ | source $HOME/ | ||
+ | fi | ||
+ | |||
+ | source $HOME/ | ||
+ | |||
+ | source $HOME/ | ||
+ | |||
+ | source $HOME/ | ||
+ | # help for zenity found here | ||
+ | # http:// | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== controldependencies.bash ==== | ||
+ | <code bash># | ||
+ | |||
+ | ################################################################ | ||
+ | # Control that the required dependencies zenity and mp3report | ||
+ | # are present. | ||
+ | # # | ||
+ | # Auteur : kamui57 < kamui_57 AT yahoo DOT fr > # | ||
+ | # # | ||
+ | # Licence : Ce script est un logiciel libre ; vous pouvez le # | ||
+ | # redistribuer et/ou le modifier selon les termes de la # | ||
+ | # Licence Publique Générale GNU ( GNU GPL ) publiée par la Free# | ||
+ | # Software Foundation. | ||
+ | # # | ||
+ | ################################################################ | ||
+ | |||
+ | error="" | ||
+ | missing=0 | ||
+ | # | ||
+ | # | ||
+ | # control if the required dependencies are present | ||
+ | if [[ ! `which zenity` ]] | ||
+ | then | ||
+ | missing=1 | ||
+ | error=" | ||
+ | fi | ||
+ | |||
+ | if [[ ! `which mp3report` ]] | ||
+ | then | ||
+ | missing=1 | ||
+ | error=" | ||
+ | fi | ||
+ | |||
+ | # if not display an error message and exit | ||
+ | if [ $missing -eq 1 ] | ||
+ | then | ||
+ | zenity --error --text " | ||
+ | exit | ||
+ | fi</ | ||
+ | |||
+ | ==== init.bash ==== | ||
+ | <code bash># | ||
+ | |||
+ | ################################################################ | ||
+ | # Initialises some variables for the script : # | ||
+ | # - the list of available options | ||
+ | # - the titles of the columns for the " | ||
+ | # - the text for the " | ||
+ | # - the separator for the list of the chosen options | ||
+ | # - the chosen state of each option | ||
+ | # # | ||
+ | # Auteur : kamui57 < kamui_57 AT yahoo DOT fr > # | ||
+ | # # | ||
+ | # Licence : Ce script est un logiciel libre ; vous pouvez le # | ||
+ | # redistribuer et/ou le modifier selon les termes de la # | ||
+ | # Licence Publique Générale GNU ( GNU GPL ) publiée par la Free# | ||
+ | # Software Foundation. | ||
+ | # # | ||
+ | ################################################################ | ||
+ | |||
+ | # Variables for the options checkboxes | ||
+ | # titles | ||
+ | titre[0]=" | ||
+ | titre[1]=" | ||
+ | titre[2]=" | ||
+ | # names of the options and brief explanation | ||
+ | options[0]=" | ||
+ | explanation[0]=" | ||
+ | options[1]=" | ||
+ | explanation[1]=" | ||
+ | options[2]=" | ||
+ | explanation[2]=" | ||
+ | options[3]=" | ||
+ | explanation[3]=" | ||
+ | options[4]=" | ||
+ | explanation[4]=" | ||
+ | options[5]=" | ||
+ | explanation[5]=" | ||
+ | options[6]=" | ||
+ | explanation[6]=" | ||
+ | |||
+ | # separator of the checked options' | ||
+ | separator=":" | ||
+ | # text displayed in the box to choose options | ||
+ | texte=" | ||
+ | Copyright (C) 2000, David Parker, Neon Goat Productions. | ||
+ | www.neongoat.com - david@neongoat.com | ||
+ | |||
+ | This script lets you choose the options, the parameters and the directories | ||
+ | Please choose the options you want to use." | ||
+ | |||
+ | # initialisation of the chosen state of each option | ||
+ | # default : no option is chosen | ||
+ | for index in " | ||
+ | do | ||
+ | picked[$index]=FALSE; | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | ==== chooseoptions.bash ==== | ||
+ | <code bash># | ||
+ | |||
+ | ################################################################ | ||
+ | # Displays a zenity box to choose the options to use for # | ||
+ | # mp3report and stores the obtained list in the string named # | ||
+ | # " | ||
+ | # # | ||
+ | # Auteur : kamui57 < kamui_57 AT yahoo DOT fr > # | ||
+ | # # | ||
+ | # Licence : Ce script est un logiciel libre ; vous pouvez le # | ||
+ | # redistribuer et/ou le modifier selon les termes de la # | ||
+ | # Licence Publique Générale GNU ( GNU GPL ) publiée par la Free# | ||
+ | # Software Foundation. | ||
+ | ################################################################ | ||
+ | |||
+ | # dialog box | ||
+ | ans=$(zenity | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | FALSE " | ||
+ | FALSE " | ||
+ | FALSE " | ||
+ | FALSE " | ||
+ | FALSE " | ||
+ | FALSE " | ||
+ | FALSE " | ||
+ | --separator=$separator); | ||
+ | |||
+ | if [ " | ||
+ | then | ||
+ | chosen="" | ||
+ | else | ||
+ | # splitting options' | ||
+ | OLD_IFS=" | ||
+ | IFS=" | ||
+ | chosen=( $ans ) | ||
+ | IFS=$OLD_IFS | ||
+ | fi | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== chooseparameters.bash ==== | ||
+ | <code bash># | ||
+ | |||
+ | ################################################################ | ||
+ | # For each chosen option, if this option requires a parameter, # | ||
+ | # prompts the user to choose the corresponding parameter. | ||
+ | # # | ||
+ | # - For the option " | ||
+ | # text box. # | ||
+ | # - For the option " | ||
+ | # be on the standard output, if not open a filedialog window # | ||
+ | # to pick the output file. # | ||
+ | # - For the option " | ||
+ | # pick the template file. # | ||
+ | # # | ||
+ | # Auteur : kamui57 < kamui_57 AT yahoo DOT fr > # | ||
+ | # # | ||
+ | # Licence : Ce script est un logiciel libre ; vous pouvez le # | ||
+ | # redistribuer et/ou le modifier selon les termes de la # | ||
+ | # Licence Publique Générale GNU ( GNU GPL ) publiée par la Free# | ||
+ | # Software Foundation. | ||
+ | # # | ||
+ | ################################################################ | ||
+ | |||
+ | indexOptions=0 | ||
+ | for indexChosen in ${!chosen[@]}; | ||
+ | chosenFound=0 | ||
+ | while [ $chosenFound = 0 ] | ||
+ | do | ||
+ | if [ ${options[$indexOptions]} = ${chosen[$indexChosen]} ] | ||
+ | then | ||
+ | break | ||
+ | else | ||
+ | indexOptions=$(($indexOptions+1)) | ||
+ | fi | ||
+ | done | ||
+ | picked[$indexOptions]=TRUE; | ||
+ | done | ||
+ | |||
+ | ########### option " | ||
+ | if [ ${picked[2]} = " | ||
+ | then | ||
+ | titleInput=$(zenity --entry --text "You have picked the option \" | ||
+ | if [ " | ||
+ | then | ||
+ | zenity --warning \ | ||
+ | --text=" | ||
+ | fi | ||
+ | | ||
+ | fi | ||
+ | |||
+ | ########### option " | ||
+ | if [ ${picked[3]} = " | ||
+ | then | ||
+ | zenity --title " | ||
+ | if [ " | ||
+ | then | ||
+ | outfileInput=' | ||
+ | else # not to standard input, therefore to a file, which must be chosen | ||
+ | zenity --info \ | ||
+ | --text=" | ||
+ | outfileInput=$(zenity --file-selection --save --confirm-overwrite); | ||
+ | fi | ||
+ | if [ " | ||
+ | then | ||
+ | zenity --warning \ | ||
+ | --text=" | ||
+ | fi | ||
+ | | ||
+ | fi | ||
+ | |||
+ | ########### option " | ||
+ | if [ ${picked[4]} = " | ||
+ | then | ||
+ | zenity --info \ | ||
+ | --text=" | ||
+ | templateInput=$(zenity --file-selection); | ||
+ | |||
+ | if [ " | ||
+ | then | ||
+ | zenity --warning \ | ||
+ | --text=" | ||
+ | fi | ||
+ | fi | ||
+ | </ | ||
+ | |||
+ | ==== choosedirectories.bash ==== | ||
+ | <code bash># | ||
+ | |||
+ | ################################################################ | ||
+ | # Displays a directories selection box to choose the scanned | ||
+ | # directories. | ||
+ | # - Multiple selection is allowed | ||
+ | # - The subdirectories are included too # | ||
+ | # # | ||
+ | # Auteur : kamui57 < kamui_57 AT yahoo DOT fr > # | ||
+ | # # | ||
+ | # Licence : Ce script est un logiciel libre ; vous pouvez le # | ||
+ | # redistribuer et/ou le modifier selon les termes de la # | ||
+ | # Licence Publique Générale GNU ( GNU GPL ) publiée par la Free# | ||
+ | # Software Foundation. | ||
+ | # # | ||
+ | ################################################################ | ||
+ | |||
+ | | ||
+ | --text=" | ||
+ | |||
+ | directoriesInput=$(zenity --file-selection --directory --multiple --separator=$separator); | ||
+ | |||
+ | if [ " | ||
+ | then | ||
+ | zenity --error --text "No directory given! The script will abort." | ||
+ | exit | ||
+ | fi</ | ||
+ | |||
+ | ==== buildcommandline.bash ==== | ||
+ | <code bash># | ||
+ | |||
+ | ################################################################ | ||
+ | # Builds the command line to execute from the chosen options | ||
+ | # and parameters. | ||
+ | # # | ||
+ | # Auteur : kamui57 < kamui_57 AT yahoo DOT fr > # | ||
+ | # # | ||
+ | # Licence : Ce script est un logiciel libre ; vous pouvez le # | ||
+ | # redistribuer et/ou le modifier selon les termes de la # | ||
+ | # Licence Publique Générale GNU ( GNU GPL ) publiée par la Free# | ||
+ | # Software Foundation. | ||
+ | # # | ||
+ | ################################################################ | ||
+ | |||
+ | commande=" | ||
+ | for indexOptions in ${!options[@]}; | ||
+ | if [ ${picked[$indexOptions]} = TRUE ] | ||
+ | then | ||
+ | ligne=" | ||
+ | case $indexOptions in | ||
+ | 2) # title | ||
+ | if [ " | ||
+ | then | ||
+ | ligne=" | ||
+ | else | ||
+ | ligne="" | ||
+ | fi | ||
+ | ;; | ||
+ | 3) # outfile | ||
+ | if [ " | ||
+ | then | ||
+ | ligne=" | ||
+ | else | ||
+ | ligne="" | ||
+ | fi | ||
+ | ;; | ||
+ | 4) # template | ||
+ | if [ " | ||
+ | then | ||
+ | ligne=" | ||
+ | else | ||
+ | ligne="" | ||
+ | fi | ||
+ | ;; | ||
+ | *);; | ||
+ | esac | ||
+ | commande=" | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | commande=" | ||
+ | </ | ||
+ | |||
+ | ==== executecommand.bash ==== | ||
+ | <code bash># | ||
+ | |||
+ | ################################################################ | ||
+ | # Prompts if the command is the good command and launches it # | ||
+ | # # | ||
+ | # Auteur : kamui57 < kamui_57 AT yahoo DOT fr > # | ||
+ | # # | ||
+ | # Licence : Ce script est un logiciel libre ; vous pouvez le # | ||
+ | # redistribuer et/ou le modifier selon les termes de la # | ||
+ | # Licence Publique Générale GNU ( GNU GPL ) publiée par la Free# | ||
+ | # Software Foundation. | ||
+ | ################################################################ | ||
+ | |||
+ | zenity --title " | ||
+ | if [ " | ||
+ | then | ||
+ | echo ok | ||
+ | else # not to standard input, therefore to a file, which must be chosen | ||
+ | echo "pas ok" | ||
+ | fi | ||
+ | |||
+ | #gksudo lsof | zenity --text-info --width 530 | ||
+ | echo $commande | ||
+ | echo " | ||
+ | $commande</ | ||
+ | |||
+ | ---- |