Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.75 KB | None | 0 0
  1. #!/bin/bash
  2. FIND_BOOK()
  3. {
  4. if [[ -n "$TARGET_ITEM" ]] && [ "${#TARGET_ITEM}" -ge 3 ]; then
  5. if [ "$VAR_TITOLO" = true ]; then
  6. LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $2}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
  7. _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
  8. elif [ "$VAR_AUTORE" = true ]; then
  9. LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $3}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
  10. _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
  11. elif [ "$VAR_GENERE" = true ]; then
  12. LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $4}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
  13. _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
  14. elif [ "$VAR_ANNO" = true ]; then
  15. LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $5}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
  16. _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
  17. elif [ "$VAR_EDITORE" = true ]; then
  18. LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $6}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
  19. _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
  20. elif [ "$VAR_FORMATO" = true ]; then
  21. LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $7}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
  22. _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
  23. echo "$_RESULT_PUBBL_"
  24. else
  25. _RESULT_PUBBL_=`cat "$_DATA_BASE_" | grep -i "$TARGET_ITEM"`
  26. fi
  27. echo "$_RESULT_PUBBL_"
  28. fi
  29. }
  30.    
  31. export CARTELLA_FILES=`dirname "$0"`
  32. export _DATA_BASE_="$CARTELLA_FILES/database"
  33. export AGGIUNGI_LIBRO="$CARTELLA_FILES/agg_book"
  34. export -f FIND_BOOK
  35. export MAIN_DIALOG='
  36. <window title="Libreria" window_position="1">
  37.   <vbox>
  38.     <hbox>
  39.       <tree file-monitor="true" auto-refresh="true" selection-mode="1">
  40.         <width>750</width><height>350</height>
  41.         <variable>TABLE</variable>
  42.         <label>ID | Titolo                        | Autore                   | Genere              | Anno | Editore                 |  Formato  | Note                         </label>
  43.         <input file>'$_DATA_BASE_'</input>
  44.         <action>refresh:TABLE</action>
  45.       </tree>
  46.     </hbox>
  47.     <hbox>
  48.       <button use-stock="true" label="gtk-remove">
  49.         <action>sed -i "/^$TABLE/d" '$_DATA_BASE_'</action>
  50.         <action>sed -i "/^$/d" '$_DATA_BASE_'</action>
  51.         <action>refresh:TABLE</action>
  52.       </button>
  53.       <button use-stock="true" label="gtk-add">
  54.         <action signal="clicked">'$AGGIUNGI_LIBRO'</action>
  55.       </button>
  56.     </hbox>
  57.     <hbox>
  58.       <radiobutton>
  59.         <label>Generico</label>
  60.         <default>true</default>
  61.         <variable>VAR_GENERICO</variable>
  62.       </radiobutton>
  63.       <radiobutton>
  64.         <label>Titolo</label>
  65.         <variable>VAR_TITOLO</variable>
  66.         <action>refresh:TARGET_ITEM</action>
  67.       </radiobutton>
  68.       <radiobutton>
  69.         <label>Autore</label>
  70.         <variable>VAR_AUTORE</variable>
  71.         <action>refresh:TARGET_ITEM</action>
  72.       </radiobutton>
  73.       <radiobutton>
  74.         <label>Genere</label>
  75.         <variable>VAR_GENERE</variable>
  76.       </radiobutton>
  77.       <radiobutton>
  78.         <label>Anno</label>
  79.         <variable>VAR_ANNO</variable>
  80.       </radiobutton>
  81.       <radiobutton>
  82.         <label>Editore</label>
  83.         <variable>VAR_EDITORE</variable>
  84.       </radiobutton>
  85.       <radiobutton>
  86.         <label>Formato</label>
  87.         <variable>VAR_FORMATO</variable>
  88.       </radiobutton>
  89.     </hbox>
  90.     <hbox>
  91.       <tree rules-hint="true">
  92.         <width>750</width><height>150</height>
  93.         <variable>CERCA</variable>
  94.         <label>ID | Titolo                        | Autore                   | Genere              | Anno | Editore                 |  Formato  | Note                         </label>
  95.         <input>"FIND_BOOK"</input>    
  96.       </tree>        
  97.     </hbox>    
  98.     <hbox>
  99.       <text>
  100.         <label> Cerca Qui, Inserire Titolo o...</label>
  101.       </text>
  102.         <entry editable="true" space-expand="false">
  103.         <height>30</height> <width>400</width>
  104.         <variable>TARGET_ITEM</variable>
  105.         <action>"FIND_BOOK $TARGET_ITEM"</action>
  106.         <action>refresh:CERCA</action>
  107.       </entry>
  108.     </hbox>
  109.     <hbox>
  110.       <button>
  111.          <label> Esci </label>
  112.          <input file icon="exit"></input>
  113.        <action type="exit">Exit</action>
  114.      </button>
  115.    </hbox>
  116.  </vbox>
  117. </window>
  118. '
  119. gtkdialog --program=MAIN_DIALOG
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement