Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- FIND_BOOK()
- {
- if [[ -n "$TARGET_ITEM" ]] && [ "${#TARGET_ITEM}" -ge 3 ]; then
- if [ "$VAR_TITOLO" = true ]; then
- LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $2}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
- _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
- elif [ "$VAR_AUTORE" = true ]; then
- LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $3}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
- _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
- elif [ "$VAR_GENERE" = true ]; then
- LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $4}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
- _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
- elif [ "$VAR_ANNO" = true ]; then
- LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $5}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
- _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
- elif [ "$VAR_EDITORE" = true ]; then
- LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $6}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
- _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
- elif [ "$VAR_FORMATO" = true ]; then
- LINEA_FIND_=`eval cat "$_DATA_BASE_" | awk 'BEGIN { FS="|" } {print NR, $7}' | grep -i "$TARGET_ITEM" | sed "s/ .*$//g"`
- _RESULT_PUBBL_=`for PRE_RESULT_ in $LINEA_FIND_; do sed -n ${PRE_RESULT_}p $_DATA_BASE_ ; done`
- echo "$_RESULT_PUBBL_"
- else
- _RESULT_PUBBL_=`cat "$_DATA_BASE_" | grep -i "$TARGET_ITEM"`
- fi
- echo "$_RESULT_PUBBL_"
- fi
- }
- export CARTELLA_FILES=`dirname "$0"`
- export _DATA_BASE_="$CARTELLA_FILES/database"
- export AGGIUNGI_LIBRO="$CARTELLA_FILES/agg_book"
- export -f FIND_BOOK
- export MAIN_DIALOG='
- <window title="Libreria" window_position="1">
- <vbox>
- <hbox>
- <tree file-monitor="true" auto-refresh="true" selection-mode="1">
- <width>750</width><height>350</height>
- <variable>TABLE</variable>
- <label>ID | Titolo | Autore | Genere | Anno | Editore | Formato | Note </label>
- <input file>'$_DATA_BASE_'</input>
- <action>refresh:TABLE</action>
- </tree>
- </hbox>
- <hbox>
- <button use-stock="true" label="gtk-remove">
- <action>sed -i "/^$TABLE/d" '$_DATA_BASE_'</action>
- <action>sed -i "/^$/d" '$_DATA_BASE_'</action>
- <action>refresh:TABLE</action>
- </button>
- <button use-stock="true" label="gtk-add">
- <action signal="clicked">'$AGGIUNGI_LIBRO'</action>
- </button>
- </hbox>
- <hbox>
- <radiobutton>
- <label>Generico</label>
- <default>true</default>
- <variable>VAR_GENERICO</variable>
- </radiobutton>
- <radiobutton>
- <label>Titolo</label>
- <variable>VAR_TITOLO</variable>
- <action>refresh:TARGET_ITEM</action>
- </radiobutton>
- <radiobutton>
- <label>Autore</label>
- <variable>VAR_AUTORE</variable>
- <action>refresh:TARGET_ITEM</action>
- </radiobutton>
- <radiobutton>
- <label>Genere</label>
- <variable>VAR_GENERE</variable>
- </radiobutton>
- <radiobutton>
- <label>Anno</label>
- <variable>VAR_ANNO</variable>
- </radiobutton>
- <radiobutton>
- <label>Editore</label>
- <variable>VAR_EDITORE</variable>
- </radiobutton>
- <radiobutton>
- <label>Formato</label>
- <variable>VAR_FORMATO</variable>
- </radiobutton>
- </hbox>
- <hbox>
- <tree rules-hint="true">
- <width>750</width><height>150</height>
- <variable>CERCA</variable>
- <label>ID | Titolo | Autore | Genere | Anno | Editore | Formato | Note </label>
- <input>"FIND_BOOK"</input>
- </tree>
- </hbox>
- <hbox>
- <text>
- <label> Cerca Qui, Inserire Titolo o...</label>
- </text>
- <entry editable="true" space-expand="false">
- <height>30</height> <width>400</width>
- <variable>TARGET_ITEM</variable>
- <action>"FIND_BOOK $TARGET_ITEM"</action>
- <action>refresh:CERCA</action>
- </entry>
- </hbox>
- <hbox>
- <button>
- <label> Esci </label>
- <input file icon="exit"></input>
- <action type="exit">Exit</action>
- </button>
- </hbox>
- </vbox>
- </window>
- '
- gtkdialog --program=MAIN_DIALOG
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement