Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 19 Sep 2019, 09:38
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Development of 'trans_tray' (translation program)
Post new topic   Reply to topic View previous topic :: View next topic
Page 4 of 7 [100 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Author Message
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Sun 01 Sep 2019, 12:51    Post subject:  

Needed a fix, so re-attached here, (see EDIT2):
http://murga-linux.com/puppy/viewtopic.php?p=1035783#1035783
(got report few hours ago through PM about problems on Busterpup, which has old 'trans' included)

@vovchik, thanks !

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Mon 02 Sep 2019, 03:16    Post subject:  

Hi Fred

Can you get this refresh savedtexts list to work properly?

Code:
function savedtranstexts (){
   rm -f /tmp/trans_tray/TP
   stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts
function refresh (){
   echo -e '\f' >$ptxts
   echo $(ls $HOME/.trans_tray/savedtexts/* | tr ' ' '\n') >$ptxts
}; export -f refresh
trap "rm -f $stxtp" EXIT

yad --plug=$$ --tabnum=1 --list --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
    --select-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; cat  "%s" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP \"" <&6  &
yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
yad --center --window-icon=gtk-save --width=700 --height=540 --button="Refresh!gtk-refresh:bash -c refresh" --on-top --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal

}; export -f savedtranstexts


On my version I have retained yandex, and added Roman - rm as a translation option (for pinyin).

stemsee
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Mon 02 Sep 2019, 04:07    Post subject:  

Hi stemsee, this change in function refresh works for me (using the same as is in the list code)
Code:
function refresh (){
   echo -e '\f' >$ptxts
   echo "$(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done)" >$ptxts
}; export -f refresh


Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Mon 02 Sep 2019, 04:43    Post subject:  

yes, i got up too early....i thought about it after posting and realised the same version. In fact I had tried that first but i had two versions of the same script open and edited the wrong one so I didn't see it work...ha ha

Code:
function savedtranstexts (){
   rm -f /tmp/trans_tray/TP
   stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts
function refresh (){
   echo -e '\f' >$ptxts
for f in $HOME/.trans_tray/savedtexts/trans-*_*
do
[[ -f "${f}" ]] && echo "${f##*/}" >$ptxts
done
}; export -f refresh
trap "rm -f $stxtp" EXIT

yad --plug=$$ --tabnum=1 --list --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
    --select-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; cat  "%s" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP \"" <&6  &
yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
yad --center --window-icon=gtk-save --width=700 --height=540 --button="Refresh!gtk-refresh:bash -c refresh" --on-top --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal

}; export -f savedtranstexts


Also in my version $ONTOP is applied to every windows so all are on-top or none.
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Mon 02 Sep 2019, 05:40    Post subject:  

hi Fred

howabout --dclick-action deletes selected saved text.
Code:

function savedtranstexts (){
   rm -f /tmp/trans_tray/TP
   stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts
function refresh (){
   echo -e '\f' >$ptxts
for f in $HOME/.trans_tray/savedtexts/trans-*_*
do
[[ -f "${f}" ]] && echo "${f##*/}" >$ptxts
done
}; export -f refresh
trap "rm -f $stxtp" EXIT

yad --plug=$$ --tabnum=1 --list --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
    --dclick-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; rm -f  "%s" ; bash -c refresh\"" \
    --select-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; cat  "%s" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP \"" <&6  &
yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
yad --center --window-icon=gtk-save --width=700 --height=540 --button="Refresh!gtk-refresh:bash -c refresh" $ONTOP --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal

}; export -f savedtranstexts

Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Mon 02 Sep 2019, 06:00    Post subject:  

here is my version

includes xclip (x64), trans, trans_tray (4)
trans_tray-stemsV4.sfs.gz
Description 
gz

 Download 
Filename  trans_tray-stemsV4.sfs.gz 
Filesize  80 KB 
Downloaded  13 Time(s) 
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Mon 02 Sep 2019, 06:28    Post subject:  

Hi stemsee, here's with Delete button (with dclick-action works also, but I thought that this is better):
Code:
function savedtranstexts (){
   rm -f /tmp/trans_tray/TP
   stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts

function refresh (){
   echo -e '\f' >$ptxts
   echo "$(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done)" >$ptxts
}; export -f refresh

function delete (){
rm -f $HOME/.trans_tray/savedtexts/$(cat /tmp/trans_tray/sel-file)
refresh
echo -e '\f' >/tmp/trans_tray/TP
rm -f /tmp/trans_tray/sel-file
}; export -f delete

trap "rm -f $stxtp" EXIT

yad --plug=$$ --tabnum=1 --list --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
    --select-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; echo "%s" >/tmp/trans_tray/sel-file; cat  "%s" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP \"" <&6  &

yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
yad --center --window-icon=gtk-save --width=700 --height=540 --button="Delete!gtk-delete:bash -c delete"  --button="Refresh!gtk-refresh:bash -c refresh" --on-top --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal --buttons-layout=spread

}; export -f savedtranstexts


EDIT: best to add a message if nothing selected in delete function

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Mon 02 Sep 2019, 16:17    Post subject:  

Hi Fred

The button is better. More difficult to accidentally delete needed translations.

Maybe the dclick function could be to open in external editor, or print as pdf.

stemsee

EDIT: maybe you could add to preferences the ability to set a default text editor as variable $TEXTEDITOR. I will hardcode geany for myself, as dclick open in editor.
Back to top
View user's profile Send private message MSN Messenger 
misko_2083


Joined: 08 Nov 2016
Posts: 81

PostPosted: Tue 03 Sep 2019, 05:23    Post subject:  

stemsee wrote:
Hi Fred
Maybe the dclick function could be to open in external editor,

Or internal
Code:

function savedtranstexts (){
   rm -f /tmp/trans_tray/TP
   stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts

function refresh (){
   echo -e '\f' >$ptxts
   echo "$(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done)" >$ptxts
}; export -f refresh

function delete (){
rm -f $HOME/.trans_tray/savedtexts/$(cat /tmp/trans_tray/sel-file)
refresh
echo -e '\f' >/tmp/trans_tray/TP
rm -f /tmp/trans_tray/sel-file
}; export -f delete

function edit_traslation (){
   cd "$HOME/.trans_tray/savedtexts"
   cat "$1" | yad  --title="Edit: $1" --editable --text-info --listen --on-top > /tmp/Trans-Text-tmp
   if [ $? -eq 0 ]
   then
      mv /tmp/Trans-Text-tmp "$1"
      rm -f /tmp/Trans-Text-tmp
      echo -e '\f' >/tmp/TP
      cat  "$1" >/tmp/TP
      echo -e '\n' >/tmp/TP
   fi
}; export -f edit_traslation

trap "rm -f $stxtp" EXIT

yad --plug=$$ --tabnum=1 --list --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
   --dclick-action="bash -c \"edit_traslation "%s"\"" \
    --select-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; echo "%s" >/tmp/trans_tray/sel-file; cat  "%s" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP \"" <&6  &

yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
yad --center --window-icon=gtk-save --width=700 --height=540 --button="Delete!gtk-delete:bash -c delete"  --button="Refresh!gtk-refresh:bash -c refresh" --on-top --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal --buttons-layout=spread

}; export -f savedtranstexts

If it's necessary to asign several options to the right click,
you can use the list dialog that opens at mouse pointer (also --on-top) and lists those options.

Make that dialog close when unfocused and it will emulate the context menu, sort of, behaviour.
Edit: here's with the menu.
Code:

function savedtranstexts (){
   rm -f /tmp/trans_tray/TP
   stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts

function refresh (){
   echo -e '\f' >$ptxts
   echo "$(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done)" >$ptxts
}; export -f refresh

function delete (){
rm -f $HOME/.trans_tray/savedtexts/$(cat /tmp/trans_tray/sel-file)
refresh
echo -e '\f' >/tmp/trans_tray/TP
rm -f /tmp/trans_tray/sel-file
}; export -f delete

function menu_action () {
  # figure out what was selected
  case "$2" in
     "edit")  cd "$HOME/.trans_tray/savedtexts"
             cat "$1" | yad  --width=600 --height=400 --title="Edit: $1" --editable --text-info --listen --on-top > /tmp/Trans-Text-tmp
              if [ $? -eq 0 ]
              then
                  mv /tmp/Trans-Text-tmp "$1"
                  rm -f /tmp/Trans-Text-tmp
                  echo -e '\f' >/tmp/TP
                  cat  "$1" >/tmp/TP
                  echo -e '\n' >/tmp/TP
               fi
               ;;
     "print") yad --text "Print action activated" --on-top;;
     "delete") yad --text "Delete action activated" --on-top;;
   esac
     
}; export -f menu_action

function menu (){
   yad  --list --width=200 --height=100 --mouse \
        --column action --no-headers "edit" "print" "delete" \
        --close-on-unfocus --on-top --no-buttons --undecorated \
        --select-action="bash -c \"menu_action "$1" "%s"\""
}; export -f menu

trap "rm -f $stxtp" EXIT

yad --plug=$$ --tabnum=1 --list --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
   --dclick-action="bash -c \"menu "%s"\"" \
    --select-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; echo "%s" >/tmp/trans_tray/sel-file; cat  "%s" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP \"" <&6  &

yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
yad --center --window-icon=gtk-save --width=700 --height=540 --button="Delete!gtk-delete:bash -c delete"  --button="Refresh!gtk-refresh:bash -c refresh" --on-top --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal --buttons-layout=spread

}; export -f savedtranstexts


Note, after a menu/list item is activated, either focus needs to change or the menu/list dialog has to be closed, e.g. with SIGUSR1.
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Tue 03 Sep 2019, 08:15    Post subject:  

Thanks misko

that's very useful. I will play with these options for awhile to see what I can come up with.

stem
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Tue 03 Sep 2019, 08:20    Post subject:  

Thanks Misko !! We have a lot to choose from now, here's another, inspired by your "internal" code but with Edit button instead of double-click:
Code:
function savedtranstexts (){
   rm -f /tmp/trans_tray/sel-file
   rm -f /tmp/trans_tray/TP
   stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts

function refresh (){
   echo -e '\f' >$ptxts
   echo "$(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done)" >$ptxts
}; export -f refresh

function delete (){
rm -f $HOME/.trans_tray/savedtexts/$(cat /tmp/trans_tray/sel-file)
refresh
echo -e '\f' >/tmp/trans_tray/TP
rm -f /tmp/trans_tray/sel-file
}; export -f delete

function edit_translation (){
EDIT="$(cat /tmp/trans_tray/sel-file 2> /dev/null)"
[ -z "$EDIT" ] && exit
   cd "$HOME/.trans_tray/savedtexts"
   cat "$EDIT" | yad  --title="Edit: $EDIT" --window-icon=gtk-save --editable --text-info --width=700 --height=540 --wrap --listen --on-top --button="Cancel!gtk-cancel:1" --button="Save!gtk-save:0" > /tmp/trans_tray/Trans-Text-tmp
   if [ $? -eq 0 ]
   then
      mv /tmp/trans_tray/Trans-Text-tmp "$EDIT"
      rm -f /tmp/trans_tray/Trans-Text-tmp
      echo -e '\f' >/tmp/trans_tray/TP
      cat  "$EDIT" >/tmp/trans_tray/TP
      echo -e '\n' >/tmp/trans_tray/TP
   fi
}; export -f edit_translation

trap "rm -f $stxtp $ptxts" EXIT

yad --plug=$$ --tabnum=1 --list --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
    --select-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; echo "%s" >/tmp/trans_tray/sel-file; cat  "%s" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP \"" <&6  &

yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
TEXT="  <b>Select an item from the list</b>"
yad --center --text="$TEXT" --window-icon=gtk-save --width=700 --height=540 --button="Edit!gtk-edit:bash -c edit_translation" --button="Delete!gtk-delete:bash -c delete"  --button="Refresh!gtk-refresh:bash -c refresh" --on-top --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal --buttons-layout=spread

}; export -f savedtranstexts


@stemsee which one do you prefer ?

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Tue 03 Sep 2019, 08:38    Post subject:  

Hi Fred

It's a no brainer! The versatility and future possibilities with the list menu opening at mouse is just awesome. If three more buttons are added on the other hand then minimum geometries are imposed.

In fact refresh and delete buttons should be moved to this list menu. Giving back that lovely clean look we started with.

stemsee

EDIT: But edit is already possible in dual pane window. The limited editing possibilities in yad are not worth employing more than already is the case. geany, swriter, wps etc take it to the next level and beyond.
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Tue 03 Sep 2019, 12:28    Post subject:  

stemsee wrote:
Hi Fred

It's a no brainer! The versatility and future possibilities with the list menu opening at mouse is just awesome. If three more buttons are added on the other hand then minimum geometries are imposed.

In fact refresh and delete buttons should be moved to this list menu. Giving back that lovely clean look we started with.
.


Ok! Would you mind making that ?, so we add it to next version then.
EDIT: Maybe best to put some text on top that says double-click brings up menu.

Quote:
EDIT: But edit is already possible in dual pane window. The limited editing possibilities in yad are not worth employing more than already is the case. geany, swriter, wps etc take it to the next level and beyond

I may be missing something, which dual pane window you mean ?

Btw, how is Yandex working for you ?, for me it works only sometimes.

EDIT: Tried your sfs version and your use of $ONTOP is a good idea to implement in next version but doesn't work well how you did, this works to set it where needed:
Code:
. $HOME/.trans_tray/prefs
[ "$ON_TOP" = "TRUE" ] && ONTOP="--on-top"


Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Tue 03 Sep 2019, 16:03    Post subject:  

Just experimenting Smile Using misko's menu option by only select rather than double-clicking it (has small delay to avoid clicking on menu item when accidentally double-clicking (but maybe delay needs to be increased)):
Code:
function savedtranstexts (){
   rm -f /tmp/trans_tray/TP
   stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts

function refresh (){
   echo -e '\f' >$ptxts
   echo "$(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done)" >$ptxts
}; export -f refresh

function delete (){
rm -f $HOME/.trans_tray/savedtexts/$(cat /tmp/trans_tray/sel-file)
refresh
echo -e '\f' >/tmp/trans_tray/TP
rm -f /tmp/trans_tray/sel-file
}; export -f delete

function menu_action () {
  # figure out what was selected

  case "$2" in
     "edit")  cd "$HOME/.trans_tray/savedtexts"
             cat "$1" | yad  --width=600 --height=400 --title="Edit: $1" --editable --text-info --listen --on-top > /tmp/Trans-Text-tmp
              if [ $? -eq 0 ]
              then
                  mv /tmp/Trans-Text-tmp "$1"
                  rm -f /tmp/Trans-Text-tmp
                  echo -e '\f' >/tmp/trans_tray/TP
                  cat  "$1" >/tmp/trans_tray/TP
                  echo -e '\n' >/tmp/trans_tray/TP
               fi
               ;;
     "print") yad --text "Print action activated" --on-top;;
     "delete") yad --text "Delete action activated" --on-top;;
   esac
     
}; export -f menu_action

function menu (){
 echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; echo "$1" >/tmp/trans_tray/sel-file; cat  "$1" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP
sleep 0.5
   yad --title=savedtranstextsmenu --list --width=200 --height=100 --mouse \
        --column action --no-headers "edit" "print" "delete" \
        --close-on-unfocus --on-top --no-buttons --undecorated \
        --select-action="bash -c \"menu_action "$1" "%s"\""
}; export -f menu

trap "rm -f $stxtp $ptxts" EXIT

yad --plug=$$ --tabnum=1 --list --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
   --select-action="bash -c \"menu "%s"\"" <&6 &

yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
yad --center --window-icon=gtk-save --width=700 --height=540 --button="Delete!gtk-delete:bash -c delete"  --button="Refresh!gtk-refresh:bash -c refresh" --on-top --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal --buttons-layout=spread

}; export -f savedtranstexts


Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Tue 03 Sep 2019, 20:16    Post subject:  

fredx181 wrote:

EDIT: Tried your sfs version and your use of $ONTOP is a good idea to implement in next version but doesn't work well how you did, this works to set it where needed:
Code:
. $HOME/.trans_tray/prefs
[ "$ON_TOP" = "TRUE" ] && ONTOP="--on-top"


Fred

should it be exported?
Code:
. $HOME/.trans_tray/prefs
[ "$ON_TOP" = "TRUE" ] && export ONTOP="--on-top"


I already implemented the list. And made refresh a 2 second loop. Also added echo -e '\f' to preview pane.
Code:
function savedtranstexts (){
   rm -f /tmp/trans_tray/TP
   stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts

function refresh (){
   [ -f /tmp/trans_tray/fresh ] && exit
   [ ! -f /tmp/trans_tray/fresh ] && touch /tmp/trans_tray/fresh
   while sleep 2
   do
      echo -e '\f' >$ptxts
      echo "$(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done)" >$ptxts
   done

}; export -f refresh

function delete (){
rm -f $HOME/.trans_tray/savedtexts/$(cat /tmp/trans_tray/sel-file)
refresh
echo -e '\f' >/tmp/trans_tray/TP
echo -e '\f' >$stxtp
rm -f /tmp/trans_tray/sel-file
}; export -f delete

function menu_action () {
  # figure out what was selected
  case "$2" in
     "edit")  cd "$HOME/.trans_tray/savedtexts"
             cat "$1" | yad  --width=600 --height=400 --title="Edit: $1" --editable --text-info --mouse --listen --on-top > /tmp/Trans-Text-tmp
              if [ $? -eq 0 ]
              then
                  mv /tmp/Trans-Text-tmp "$1"
                  rm -f /tmp/Trans-Text-tmp
                  echo -e '\f' >/tmp/TP
                  cat  "$1" >/tmp/TP
                  echo -e '\n' >/tmp/TP
               fi
               ;;
     "print") yad --text "Print action activated" --mouse $ONTOP;;
     "delete") bash -c delete;;
     "refresh") bash -c refresh;;
     "ext.editor") cd "$HOME/.trans_tray/savedtexts"
     EDITOR=$(yad --window-icon="/tmp/trans_tray/all.svg" $ONTOP --mouse --entry --text="Enter the editor to use e.g. geany")
     "$EDITOR" "$1";;
     "copy") cd "$HOME/.trans_tray/savedtexts"
      yad --window-icon="/tmp/trans_tray/all.svg" $ONTOP --mouse --file --save --text="Copy to location / rename";;
   esac
     
}; export -f menu_action

function menu (){
   yad  --list --width=200 --height=100 --mouse \
        --column action --no-headers "delete" "refresh" "print" "external editor" "copy" "internal edit" \
        --close-on-unfocus $ONTOP --no-buttons --undecorated \
        --select-action="bash -c \"menu_action "$1" "%s"\""
}; export -f menu

trap "rm -f $stxtp" EXIT

yad --plug=$$ --tabnum=1 --list --text="Double click raises menu" --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
   --dclick-action="bash -c \"menu "%s"\"" \
    --select-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; echo "%s" >/tmp/trans_tray/sel-file; cat  "%s" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP \"" <&6  &

yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
yad --center --window-icon=gtk-save --width=700 --height=540 $ONTOP --no-buttons --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal

}; export -f savedtranstexts

Last edited by stemsee on Wed 04 Sep 2019, 07:53; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
Display posts from previous:   Sort by:   
Page 4 of 7 [100 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0944s ][ Queries: 12 (0.0159s) ][ GZIP on ]