#!/bin/bash

[ "`echo "$*" | grep -F '-eq'`" ] && GUI_PEQUALIZER="`/usr/local/pequalizer/pequalizer -e 2> /dev/null`" #for those that has eq built in main gui

GUI_PROGRESS='
<timer visible="false" milliseconds="true" interval="'$UPDATE_INTERVAL'">
 <variable export="false">TIMER</variable>
 <action>[ ! "`ps -e | grep -F func_progressba`" ] && nice -n 18 '$APPDIR'/func_progressbar</action>
 <action>refresh:PROGRESS</action>
 <action>refresh:STATUSBAR</action>
 <action>refresh:UPDATE_SOURCELIST</action>
 <action>refresh:UPDATE_GUI</action>
 <action>echo false > '$WORKDIR'/UPDATE_SOURCELIST</action>
 <action>echo false > '$WORKDIR'/UPDATE_GUI</action>
</timer>

##here follows switches that updates parts of gui without user interaction (and update sourcelist when browsing+++) 
<checkbox visible="false"> ##this updates sourcelist but NOT search field.
 <variable>UPDATE_SOURCELIST</variable>
 <input file>'$WORKDIR'/UPDATE_SOURCELIST</input>
 <action>if true refresh:SOURCE</action>
 <action>if true refresh:SEARCH</action>
</checkbox>

<button visible="false">
 <variable>ALBUMART_SEARCH_ACTIVATE</variable>
 <action condition="active_is_false(SEARCH_ALBUMART)" function="break">""</action>
 <action>refresh:ALBUMART_SEARCH_PREV</action>
 <action>refresh:ALBUMART_SEARCH_NEXT</action>
 <action>refresh:ALBUMART_SEARCH1</action>
 <action>refresh:ALBUMART_SEARCH2</action>
 <action>refresh:ALBUMART_SEARCH3</action>
 <action>refresh:ALBUMART_SEARCH4</action>
 <action>refresh:ALBUMART_SEARCH5</action>
 <action>refresh:ALBUMART_SEARCH6</action>
 <action>refresh:ALBUMART_SEARCH7</action>
 <action>refresh:ALBUMART_SEARCH8</action>
 <action>refresh:ALBUMART_SEARCH9</action>
 <action>refresh:ALBUMART_SEARCH10</action>
 <action>refresh:ALBUMART_SEARCH11</action>
 <action>refresh:ALBUMART_SEARCH12</action>
 <action>refresh:ALBUMART_SEARCH13</action>
 <action>refresh:ALBUMART_SEARCH14</action>
 <action>refresh:ALBUMART_SEARCH15</action>
 <action>refresh:ALBUMART_SEARCH16</action>
 <action>refresh:ALBUMART_SEARCH17</action>
 <action>refresh:ALBUMART_SEARCH18</action>
 <action>refresh:ALBUMART_SEARCH19</action>
 <action>refresh:ALBUMART_SEARCH20</action>
</button>

<checkbox visible="false">
 <variable>UPDATE_GUI</variable>
 <input file>'$WORKDIR'/UPDATE_GUI</input>
 <action>if true refresh:PLAYLIST</action>
 <action>if true refresh:SVG_NOWPLAYING</action>
 <action>if true refresh:BUTTON_PLAY</action> ##play or pause icon
 <action>if true refresh:WINDOW_TITLE</action>
 <action>if true refresh:ARTWORK</action>
 <action>if true refresh:NOTEBOOK_MAINGUI</action>
</checkbox>
'

GUI_PROGRESSBAR='
<hscale draw-value="false" block-function-signals="true" update-policy="1" scale-step="1" scale-min="0" scale-max="100"> ##update-policy: 0=constantly 1=button-activated 2=delayed
 <variable>PROGRESS</variable>
 <input file>'$WORKDIR'/PERCENT_BAR</input>
 <action signal="button-press-event">disable:TIMER</action>
 <action signal="button-press-event">'$APPDIR'/func_kill -audio</action>
 <action>'$APPDIR'/func_player -jump_to_percent $PROGRESS</action>
 <action>enable:TIMER</action>
</hscale>'

GUI_STATUSBAR='
<statusbar>
 <variable>STATUSBAR</variable>
 <input file>'$WORKDIR'/statusbar</input>
</statusbar>'

GUI_MSG='
<hbox space-expand="true" space-fill="true">
 <text xalign="0,05" width-chars="25" space-expand="true" space-fill="true"><label>'$(gettext 'Added track not found in the music database. Scan its source directory?')'</label></text>
 <button image-position="2">
  <input file stock="gtk-apply"></input>
  <label>'$(gettext 'Scan')'</label>
  <action>TMP="`cat '$WORKDIR'/source_checked`"; '$APPDIR'/func_index -msg_quick_update "$(dirname "$TMP")" &</action>
 </button>
 <button image-position="2">
  <input file stock="gtk-close"></input>
  <label>'$(gettext 'Skip')'</label>
  <action>echo 0 > '$WORKDIR'/maingui_notebook_page</action>
  <action>[ -f '$HOME'/.pmusic/nowplaying_albumart.jpg ] && cp -f '$HOME'/.pmusic/nowplaying_albumart.jpg '$WORKDIR'/albumart.jpg || cp -f "'$APPDIR'/themes/'$THEME'/album_art.svg" '$WORKDIR'/albumart.jpg</action>
  <action>refresh:NOTEBOOK_MAINGUI</action>
  <action>refresh:ARTWORK</action>
 </button>
 <vseparator space-expand="false" space-fill="false"></vseparator>
</hbox>
'

GUI_MSG2='
<text xalign="0,05" space-expand="true" space-fill="true"><label>"'$(gettext 'Scanning for local music')'
'$(gettext 'Please wait')'..."</label></text>
'
