yad --list --radiolist how to position to specific section of array?

2,706 views
Skip to first unread message

rick

unread,
Apr 23, 2017, 2:21:57 PM4/23/17
to yad-common
Firstly thank you for YAD it's an awesome program.

I have a large list of directories in an array (3,000 to 20,000). I perform CRUD operations on the array. Each time the array is displayed with yad it starts at top of array. I would like to position the list to the last array entry accessed. I've set the first field to true but it only shows as selected and doesn't position the list to that section of array.

I've tried piping the directory name into yad (it's searchable on column 2) by trying:

echo "$DirName" | Record=(`yad --list ... `)

and

Record=(`yad --list ... `) <<< "$DirName"

The complete code is:

Record=(`yad --list --radiolist --separator="|" --grid-lines=hor \
    --title="bafman - Born Again File Manager - $DirCnt Directories" \
    --text="Navigate to directory and double-click or space bar to use:\
    Tag files / Edit comments / Hide Dir buttons." \
    --width=1200 --height=800 --center  --no-markup \
    --button="Tag files":$ButnTag       --button="Run command":$ButnCommand \
    --button="Edit comments":$ButnComment \
    --button="Add Dir":$ButnAdd         --button="Hide Dir":$ButnHide \
    --button="Update Dirs":$ButnUpdate  --button="$VariableCloseText":$ButnCancel \
    --button="Save":$ButnSave \
    --wrap-width=800        --wrap-cols=2               --dclick-action \
    --ellipsize=START       --ellipsize-cols=8 \
    --search-column=2       --column "Select" \
    --column "Searchable Directory Name (just start typing)" \
    --column "Modified":HD  --column "Owner":HD         --column "Status":HD \
    --column "File Cnt":NUM --column "File Sizes":SZ    --column "Comment...":TXT \
    --column "Tag Cnt":NUM  --column "Tag Sizes":SZ \
    "${DirsArr[@]}"`
)
Action=$?


Above code is called in while loop as directories are added, hidden, edited and tagged.

The "Comments..." column doesn't --ellipsize properly and displays full width. I think it was working correctly so I must have done something to break it. I've tried all the START, NONE, MIDDLE and END options but the column is still width of longest element.

To summarize: 

1) Is it possible to position yad --list to specific section of array?
2) Why are comments not being ellipsized?

Милош Павловић

unread,
Apr 23, 2017, 7:08:05 PM4/23/17
to yad-common
If I understood this, you want to add new rows without closing the list dialog.
I made this little script as an example. You can add folders to the list several times by clicking on "Add Folders" button.
This is only an example not ment for too many folders. :) Just a few to see how you can add more data to the list.
#!/bin/bash

test
-e /tmp/yadpipe03 && rm -f /tmp/yadpipe03

# Named pipe initialization
export PIPE_03=/tmp/yadpipe03
mkfifo $PIPE_03
exec 3<> $PIPE_03

function load_data
{
  DIRS
="$(yad --file --multiple --width=800 --height=600 \
         --directory --title="
Select Folders")"

  OIFS
=$IFS
  IFS
="|"

 
[[ ! -z "$DIRS" ]] && YAD_DATA=($(for DIR in "$DIRS";do echo "$DIR";done ))

  IFS
=$OIFS

 
for DATA in "${YAD_DATA[@]}";do
      echo
True     # Adds "True" for the checklist column
      echo
"${DATA}"
 
done
}
export -f load_data

function clear_all
{
  echo
-e '\f'
}
export -f clear_all

# Main Dialog
Record=($(yad --list --checklist --separator="|" --grid-lines=hor \
   
--width=1200 --height=800 --center \
   
--title="Nafman - Not Again File Manager" \
   
--text="Example" \
   
--column "Select" --column "Folder" \
   
--button="Add Folders!gtk-add":'bash -c "load_data > $PIPE_03"' \
   
--button="Clear!gtk-clear":'bash -c "clear_all > $PIPE_03"' \
   
--button="OK!gtk-ok":0 \
   
--listen --print-all < $PIPE_03))
Action=$?

echo $
{Record[@]}
I hope it helps.

Rick Lee

unread,
Apr 23, 2017, 7:21:41 PM4/23/17
to yad-c...@googlegroups.com
I never thought of using FIFO pipes! For others reading your answer it
is based on a question I posted two days ago and then deleted. This
answer is linked to a new question on the same bash script I'm
building called "bafman" (Born Again File Manager).

I had to use FIFO pipes in bafman already for complex progress
displays with --log windows. The FIFO pipe would communicate with a
spawned bash script and pass it the percent complete and "# directory
name". Trying to use yad in the main program was resulting in data
loss.

I'll study your sample script and attempt to implement a variation of
it over the next few weeks.

Thank you ! :)

Спасибо
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "yad-common" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/yad-common/KbLzRLdxlhc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> yad-common+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Victor Ananjevsky

unread,
Apr 26, 2017, 1:11:14 PM4/26/17
to yad-c...@googlegroups.com


On Sun, 23 Apr 2017 11:21:57 -0700 (PDT)
rick <rickl...@gmail.com> wrote:

> Firstly thank you for YAD it's an awesome program.
>
> I have a large list of directories in an array (3,000 to 20,000). I perform
> CRUD operations on the array. Each time the array is displayed with *yad*
> it starts at top of array. I would like to position the list to the last
> array entry accessed.

this feature will be available in upcoming release

--
Victor Ananjevsky <anan...@gmail.com>
Reply all
Reply to author
Forward
0 new messages