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 Wed 18 Sep 2019, 20:27
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
YAD - Tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 14 of 48 [718 Posts]   Goto page: Previous 1, 2, 3, ..., 12, 13, 14, 15, 16, ..., 46, 47, 48 Next
Author Message
01micko


Joined: 11 Oct 2008
Posts: 8707
Location: qld

PostPosted: Sat 14 May 2016, 00:25    Post subject:  

SFR wrote:
Not only YAD - also SpaceFM as well as Gtkdialog (for icons in titlebar).
http://www.murga-linux.com/puppy/viewtopic.php?p=820355#820355


My guess is that gtk+ developers all have an icon theme installed. Lazy in other words.

Try this one
icon.png
 Description   
 Filesize   9.53 KB
 Viewed   1703 Time(s)

icon.png


_________________
Puppy Linux Blog - contact me for access
Back to top
View user's profile Send private message Visit poster's website 
SFR


Joined: 26 Oct 2011
Posts: 1731

PostPosted: Sat 14 May 2016, 08:43    Post subject:  

MochiMoppel wrote:
For searching icons in my system I normally use SFR's excellent Icon Finder. The only drawback: this thing can be terribly slow.

Yeah, it's slow indeed... It was even slower before v1.4:
changelog wrote:
- ~250% faster image filtering;

The worst part is that if there's a lot (thousands) of icons, it takes ages for Gtkdialog to digest all that stuff before it displays the window.

MochiMoppel wrote:
I tried yad as a faster alternative and was impressed by the speed.

Nice, light alternative. Only had to add '-L' to find, because in Fatdog /usr/local/lib/X11/pixmaps is a symlink.
___________

01micko wrote:
My guess is that gtk+ developers all have an icon theme installed. Lazy in other words.

Most likely... Also, all "big" distros have some full icon theme preinstalled, so nobody is noticing that something's not right.

01micko wrote:
Try this one

Yeah, I downloaded it some time ago - an excellent collection of tiny (size) icons to have!

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1897
Location: Japan

PostPosted: Sun 15 May 2016, 01:00    Post subject:  

Compared with gtkdialog's tree widget the yad -list option has a big advantage. While gtkdialog requires to define the "exported-column" beforehand and then can do stuff only with this specified column value, yad allows access to the values of all columns.

However it seems that in yad you can't do much with these values. There is the --dclick-action, which I used in my previous demo. There is also the --select-action, which I didn't use because I simply can't think of anything useful to do with it. It would also interfere with the --editable option.

It would be nice to select a row and then do all sorts of stuff with any column value. Impossible? Not really. Below is an example that adds buttons to the list which perform different actions. The trick is to let the --select-action write all row values to a tmp file and let the buttons and their associated functions read these values.

The "Info" button uses exiv2 to show (mostly non-existent) exif data, the "Show Location" button does the same thing that double clicking did in the previous demo and the "Copy Path" button uses xclip to copy the path to the clipboard. None of the functions use any other value than the 4th column, but this is only due to my lack of fantasy and the limited usefulness of an icon list.
Code:
#!/bin/bash
export TMPFILE=/tmp/yadvalues
function savevalues { echo -e "IMGNAME=\"$2\"\nIMGSIZE=$3\nIMGPATH=\"$4\"" > $TMPFILE ;} ; export -f savevalues
function showinfo   { source $TMPFILE ; exiv2   "$IMGPATH" 2>/dev/null | gxmessage -c -fn mono -file -  ;} ; export -f showinfo
function showinrox  { source $TMPFILE ; rox -s  "$IMGPATH"  ;} ; export -f showinrox
function copypath   { source $TMPFILE ; echo -n "$IMGPATH" | xclip -i -selection clipboard  ;} ; export -f copypath
SEP=";"
FOUND=$(find -L /usr/local/lib/X11/pixmaps -regextype gnu-awk -iregex  ".*\.(png|jpg|gif|xpm)$" -printf "%p${SEP}%f${SEP}%s${SEP}%p${SEP}")
IFS=$SEP
yad --list  --geometry=700x500 \
--select-action='sh -c "savevalues %s"' \
--column=icon:IMG \
--column=name \
--column=size:NUM \
--column=path \
--button="Info":'sh -c "showinfo"' \
--button="Show Location":'sh -c "showinrox"' \
--button="Copy Path":'sh -c "copypath"' \
--button="gtk-ok":0 \
--button="gtk-cancel":1 \
$FOUND

Edit: To prevent the replacement of the separator with a space character should the FOUND variable ever be echoed to a file or stdout I changed
      IFS=";"
      FOUND=$(find .... -printf "%p${IFS}%f${IFS}%s${IFS}%p${IFS}")
      yad ....
to
      SEP=";"
      FOUND=$(find .... -printf "%p${SEP}%f${SEP}%s${SEP}%p${SEP}")
      IFS=$SEP
      yad ....
yad_list_ with_custom_buttons.png
 Description   
 Filesize   43.75 KB
 Viewed   1710 Time(s)

yad_list_ with_custom_buttons.png


Last edited by MochiMoppel on Sun 15 May 2016, 23:06; edited 1 time in total
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1197

PostPosted: Sun 15 May 2016, 17:05    Post subject:  

Very nice, thanks MochiMoppel.

Do I need a specific yad version? I have 0.28.1 and when I select a row with one left click then press one of the buttons stderr prints "sh: /tmp/yadvalues: No such file or directory".

@others: the forum seems to have added a space character at the end of each line in MochiMoppel's script. Make sure to delete such characters or yad will print an error message "No column titles specified for List dialog."

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
smokey01


Joined: 30 Dec 2006
Posts: 2811
Location: South Australia :-(

PostPosted: Sun 15 May 2016, 19:14    Post subject:  

step a later version can be found here:
http://www.smokey01.com/software/utility/yad-0.36.2.pet
or for Fatdog64-700
http://smokey01.com/fd700/packages/yad-0.36.2-x86_64-1.txz

_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1897
Location: Japan

PostPosted: Sun 15 May 2016, 20:12    Post subject:  

I'm using smokey01's yad-0.36.2.

step wrote:
the forum seems to have added a space character at the end of each line in MochiMoppel's script. Make sure to delete such characters or yad will print an error message "No column titles specified for List dialog."
It's not the forum, it's your browser. Some browsers (Opera!) add spaces to the end of each line when you copy text from the browser window. An old and well known (but often forgotten Wink ) bug.

Not a yad issue, but a naming annoyance: Many icons in the directory /usr/local/lib/X11/mini-icons are named mini-something.xpm or mini.something.xpm. When sorting by name they all start with mini. Not very useful. I prefer to strip the mini- or mini. from the name. RIght after the find command I add the line
Code:
FOUND=${FOUND//${SEP}mini[-.]/$SEP}
(note that I edited the original code. Now it's SEP instead of IFS - though the latter would work). As a result it's easier to find similar icons, e.g. all home icons:
eliminated_mini.png
 Description   
 Filesize   36.15 KB
 Viewed   1574 Time(s)

eliminated_mini.png


Last edited by MochiMoppel on Mon 16 May 2016, 04:16; edited 1 time in total
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1197

PostPosted: Mon 16 May 2016, 04:00    Post subject:  

@smokey01, Got it, thanks. It does fix the issue.

@MochiMoppel, you're right, it's Opera not the forum. I'm appalled that the new Opera, which is based on Chromium, still has that bug. Bug or feature? Featured-bug compatibility?

It's a nice script. On Fatdog710 gxmessage and exiv2 aren't native. So I changed one line to replace both gxmessage and exiv2 with runexiftool, which is included in my Very Happy exiftool package for Fatdog64 (in contrib repo, needs perl package or devx)
Code:

function showinfo   { source $TMPFILE ; runexiftool "$IMGPATH" 2>/dev/null;} ; export -f showinfo

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1897
Location: Japan

PostPosted: Tue 17 May 2016, 00:13    Post subject:  

So --list is pretty powerful, but still it seems impossible to refresh the list while the dialog is running.

This trick can be achieved with the --form option and the special @ character, which makes it possible to send output to a field instead of stdout. For the demo I use a field of type TXT (multiline text) and turn it into a poor man's list.

The demo copies files selected in ROX into a target directory. To see this in action, open a ROX window and run the demo. If you had selected files already, they will appear in the multiline field, if not, do it now and push the "Refresh" button (do not drag&drop the files!). The field should update. Make a different selection and press "Refresh" again. If all goes well the field will replace the old contents with a list of the selected files. Choose a target directory and press "Copy" if you like. The listed files/directories will be copied to the target. Of course you can delete files from the list to exclude them from copying.
Code:
#!/bin/sh
function multiline {
  X=$(xclip -o)
  [[ ${X::1} = / ]] && echo  "${1}${X// \//\\n/}" || echo -e "\n\tSelect files in ROX, then push Refresh button"
} ; export -f multiline

yad --width=500 --form  \
--field="Source files":TXT                      "$(multiline)" \
--field="Target directory":CDIR                 "/archive" \
--field="Refresh file list!gtk-refresh":FBTN    '@bash -c "multiline 1:"' \
--field="Copy to target!gtk-copy":FBTN          'bash  -c "F=%1; F=${F//\\\n/|}; IFS=\|; rsync -a $F %2"'
yad_multilinetext.png
 Description   
 Filesize   35.95 KB
 Viewed   1492 Time(s)

yad_multilinetext.png

Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1197

PostPosted: Sat 18 Jun 2016, 17:41    Post subject: yad drop list collector revisited
Subject description: expanded script
 

This conversation started here:
stemsee wrote:
Here is a yad drag'n'drop pane that sits on your desktop and adds the path of everything you drop there to /root/list.txt...

smokey01 wrote:
stemsee, nice. I prefer not to background it and keep the decorations.
Have a look at this?
Code:
yad --geometry=100x100 --on-top --text="Drag-n-drop directory or files here \nThey will be added to ref list" --no-buttons --skip-taskbar --dnd --cmd echo $1 | sed 's/^.......//' >> /root/references.txt

stemsee wrote:
That would have been a better solution. i was trying to find the expression to get rid of 'file://' yesterday!

However for some reason nothing is getting added to the file /root/references.txt with your code as it is! sed 's/^' isn't that to insert?

smokey01 wrote:
Once you close the dnd gui the files will be written to your file.

Well I found a way to update the list file in "real time" without the need to close the drag-and-drop window.
Code:

script -q -c 'yad --geometry=100x100 --on-top --text="Drag-n-drop items here\nThey will be added to ref list\n---" --no-buttons --skip-taskbar --dnd --cmd printf "%s\n" "$1" | sed -e "s,^file://,,"' >> /root/references.txt

How this works is better explained in a SO article - URL's listed further down. I also changed sed to delete "file://" only. Since you can also drop URLs from your browser, the protocol selector, http, ftp, ... is preserved in that case.
It would be nice to keep the drop target and the result list together in a single mini-app. Here it is. It uses the notebook interface. Save the code to a file, don't be tempted to run it directly from the command line.

edit: Read the CAVEAT section in this post
The final script is in this other post.

Code:

#!/bin/sh
# {da,a}sh compatible.

lf=${SHOM:-$HOME}/references.txt
lf=/tmp/references.txt # or even /tmp/references-$$.txt for separate sessions.

# Accepted items: files, folders, URLs from browser. Folders won't be expanded.

# https://unix.stackexchange.com/a/61833
#script -q -c 'yad --geometry=100x100 --on-top --text="Drag-n-drop items here\nThey will be added to ref list\n---" --no-buttons --skip-taskbar --dnd --cmd printf "%s\n" "$1" | sed -e "s,^file://,,"' >> "$lf"

# Don't run these lines from terminal or you may incur bug https://sourceforge.net/p/yad-dialog/tickets/205/
script -q -c 'yad --plug='$$' --tabnum=1 --text="Drag-n-drop items here\nThey will be added to ref list\n---" --dnd --cmd printf "%s\n" "$1" | sed -e "s,^file://,,"' >> "$lf" &
script -q -c 'tail -f "'"$lf"'" | yad --plug='$$' --tabnum=2 --listen --tail --text-info' &
yad --no-buttons --skip-taskbar --notebook --key=$$ --tab="Drop" --tab="List"
yad_drop_list.png
 Description   
 Filesize   10.39 KB
 Viewed   1304 Time(s)

yad_drop_list.png

yad_drop_list.tar.gz
Description  same script as above
gz

 Download 
Filename  yad_drop_list.tar.gz 
Filesize  624 Bytes 
Downloaded  148 Time(s) 

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus

Last edited by step on Mon 20 Jun 2016, 17:46; edited 2 times in total
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Sat 18 Jun 2016, 18:40    Post subject:  

can you check your script ... it doesn't work here!

Still it will be great to get your improvements. After writing that script I developed the dnd idea to become DnD-Widget which is my desktop file router, which acceps dirs and files and sends them to default apps; media fies, documents, scripts, html, pdf, etc That script also needs a realtime updater in several places. Maybe you could implement your code there too ... that woud be great!
Back to top
View user's profile Send private message MSN Messenger 
step

Joined: 04 May 2012
Posts: 1197

PostPosted: Sun 19 Jun 2016, 04:03    Post subject: 'script' and yad CAVEAT
Subject description: 'script' appends \r to each line
 

stemsee wrote:
can you check your script ... it doesn't work here!
It works here. Can you tell me which puplet and show terminal output (although I suppose you had none). Can you please test just the commented line that starts with "#script" too? That way we can make sure your puplet can run 'script' correctly.

CAVEAT
However, I just found out a caveat with 'script' itself.
man script wrote:

BUGS
script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects.

So I went looking for possible impacts of this bug and sadly I found one. 'Script' ends each line with \r\n, that means that all lines in /tmp/references.txt end with \r. So you have to keep that in mind when you're re-using the real-time output list, you need to strip the \r before you can use the filepath. Gotcha: your text editor may not actually display the \r, but it's there! You 'cat -v' to check the file.

Note that this issue can't be fixed by simply piping 'script' into 'sed' to delete the \r character. If we did, we would undo the 'script' magic of unbuffering the whole command, and we'd be back to square one. There are ways around this, but I suspect none of them revolves around using 'script' anymore. I need to think about it.

Meanwhile, if you can strip \r in your downstream processing, the 'script' unbuffered solution should work for you just fine.

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1197

PostPosted: Sun 19 Jun 2016, 06:09    Post subject: solution for the 'script' command CAVEAT
Subject description: don't use 'sed' nor 'script'
 

I found a way around the whole unbuffered issue. For starters, fix your yad options! --dnd --cmd isn't valid.
man yad wrote:

Drag-and-Drop box options
--command=CMD
Run command when data received. Data strings pass to command as an agrument. By default data just prints to stdout.

So it's --dnd --command. If you want to run a shell builtin, like echo, then use
Code:

--command "bash -c 'echo \$0"

but better use printf instead of echo so you're not exposed to issues with file names that start with '-e'. And of course $0 should be quoted.

Then we can get rid of the buffering issue by using bash shell modifiers to delete "file://".

Finally there's the whole shell escape character ordeal... In summary, the one-liner that works for me is:
Code:

yad --geometry=100x100 --on-top --text="Drag-n-drop items here\nThey will be added to ref list\n---" --no-buttons --skip-taskbar --dnd --command "bash -c 'printf %s\\\\n \"\${0//file:\/\//}\"'" >> /tmp/reference.txt


Adapting to the notebook script is left as an exercise for the reader Smile (sorry, I'm running out of time).

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1197

PostPosted: Mon 20 Jun 2016, 17:43    Post subject: yad drop list collector revisited
Subject description: final script
 

This is the final version of the drop list collector tabbed dialog. It solves open issues, and it by-passes caveats.
Code:

#!/bin/sh
# {da,a}sh compatible.

lf=${SHOM:-$HOME}/references.txt
lf=/tmp/references.txt # or even /tmp/references-$$.txt for separate sessions.

# Accepted items: files, folders, URLs from browser. Folders won't be expanded.
# Dropped icon GROUP output order may not match ROX-Filer's icon order.

# One-liner version
#yad --geometry=100x100 --on-top --text="Drag-n-drop items here\nThey will be added to ref list\n---" --no-buttons --skip-taskbar --dnd --command "bash -c 'printf %s\\\\n \"\${0//file:\/\//}\"'" >> "$lf"

# Two-tab version
# Don't run these lines from terminal or you may incur bug
# https://sourceforge.net/p/yad-dialog/tickets/205/
yad --plug=$$ --tabnum=1 \
  --text="Drag-n-drop items here\nThey will be added to ref list\n---" \
  --dnd --command "bash -c 'printf %s\\\\n \"\${0//file:\/\//}\"'" \
  >> "$lf" &

tail --pid=$$ -f "$lf" |
awk '{fflush();print;fflush()}' |
yad --plug=$$ --tabnum=2 --listen --tail --text-info &

yad --no-buttons --skip-taskbar --notebook \
  --key=$$ --tab="Drop" --tab="List"
yad_drop.tar.gz
Description 
gz

 Download 
Filename  yad_drop.tar.gz 
Filesize  689 Bytes 
Downloaded  160 Time(s) 

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Tue 21 Jun 2016, 05:44    Post subject:  

The gui pops up but nothing gets added to references.tx, in fact that file doesn't get created! Maybe it needs to be in existence to start with.
Back to top
View user's profile Send private message MSN Messenger 
step

Joined: 04 May 2012
Posts: 1197

PostPosted: Tue 21 Jun 2016, 10:09    Post subject:  

Open terminal in the folder where you placed yad_drop.sh, run
sh -x ./had_drop.sh
Copy entire output into your reply.
Tell me on which puplet you ran the command.

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 14 of 48 [718 Posts]   Goto page: Previous 1, 2, 3, ..., 12, 13, 14, 15, 16, ..., 46, 47, 48 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.1070s ][ Queries: 13 (0.0338s) ][ GZIP on ]