A custom File & Folder selector.

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#31 Post by mikeb »

Ok sussed it

NAME gives a group of file types....

But for your example its

yad --file-selection --filename=/mnt/sda3/ --geometry=600x400+20+20 --file-filter="IMAGES | *.png *.jpg"

I got caught out with the --notification in the same way... when the pipe symbol is used as a deliminator then quotes are essential otherwise bash interprets it as such. The above gives a IMAGES tab which shows png and jpg as desired...

you can specify multiple selectable types (like gimp file dialogs) by --file-filter=*.jpg --file-filter=*.png or NAMED like above. For example that could give a 'show all files' option eg
--file-filter="IMAGES | *.png *.jpg" --file-filter="ALL | *.*"

I saw mention of a 'manual' for yad but it eludes me.

mike

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#32 Post by sunburnt »

I`m not sure what the group thing is all about, but the double quotes worked with or without it.
Both these lines work:

Code: Select all

# yad --file-selection --filename=/mnt/sda3/ --geometry=600x400+20+20 --file-filter="IMAGES |*.png *.jpg"
# yad --file-selection --filename=/mnt/sda3/ --geometry=600x400+20+20 --file-filter="*.png *.jpg"
However it`s touchy about variables.
The geometry has to be separated and double-quoted (--geometry="$yadW"x"$yadH"+"$yadX"+"$yadY").
Strangely the file path doesn`t have to be quoted at all.

This works nicely:

Code: Select all

#####	Show Yad filer dialog at upper right corner of screen.

								#####	Path must have ending /		eg: /path/
pf=/mnt/sda3/docs/pics/girls/

yadW=600

scrW=`xwininfo -root |grep '\-geo' |sed 's#.* ##;s#x.*##'`

yadX=$((scrW-yadW-5))

ext='*.png *.jpg'

yad --file-selection --filename= --geometry="$yadW"x400+"$yadX"+0 --file-filter="$ext"

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#33 Post by mikeb »

Hmm geometry was unquoted for me .. oddness.

grouping..... in the example the dialog would show 'IMAGES' rather than the '*.png *.jpg' eg you could have a dozen extensions but only show IMAGES so avoiding a long list and less confusing for a casual user..

Actually the quotes solve having multiple types I just realised.

I find software like crossword puzzles... you get to know the authors style :)

mike

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#34 Post by sunburnt »

And perhaps not so much "style", as what`s forced upon us... :roll:

Are the group files types shown in a list somewhere?

Yeah, the geometry and filter patterns need double quoting.
But the /path/file doesn`t.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#35 Post by mikeb »

Well its Linux...anything goes lol. This weeks kernel says this, next week that, simon says .... consistancy and gtk in particular are sworn enemies.
Are the group files types shown in a list somewhere?
the list of *.jpg *.png *.gif would be replaced by 'IMAGES' in the dialog. In other words its an alias for a group of file extensions.
Yeah, the geometry and filter patterns need double quoting.
But the /path/file doesn`t.
Unless there are spaces in names in the usual unix way.

mike

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#36 Post by sunburnt »

Good point, then the /path/file needs quotes too.

So is there a list of aliases, or how do you make your own? images='*.png" "*.jpg"'

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#37 Post by mikeb »

--file-filter="IMAGES |*.png *.jpg"

IMAGES IS the alias for png/jpg above.... it could be ALLOWED or PYJAMAS....


on a general note I get caught out in the end not adding quotes with command lines....

mike

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#38 Post by sunburnt »

I guess I`m not clear on what`s the purpose of aliases ?
Last edited by sunburnt on Thu 15 Aug 2013, 07:58, edited 1 time in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#39 Post by sunburnt »

And another Q:
I just don`t get " --confirm-overwrite=[TEXT] ".
I mean "TEXT". :?
Can`t programmers communicate like the rest of us do?

# I know what overwrite does. What`s the purpose of TEXT ?
Boolean TRUE / FALSE ? . y / n ?

Code: Select all

File selection options
  --file                                         Display file selection dialog
  --file-selection                               Alias for --file
  --filename=FILENAME                            Set the filename
  --multiple                                     Allow multiple files to be selected
  --directory                                    Activate directory-only selection
  --save                                         Activate save mode
  --separator=SEPARATOR                          Set output separator character
  --confirm-overwrite=[TEXT]                     Confirm file selection if filename already exists
  --file-filter=NAME | PATTERN1 PATTERN2 ...     Sets a filename filter
### I`ve got a script I`ll post that utilizes all of the Yad Filer options in a simple CLI command.
.
Last edited by sunburnt on Thu 15 Aug 2013, 08:06, edited 3 times in total.

Jasper

#40 Post by Jasper »

Hi,

I'm a lousy typist so here is my longest alias:

alias t="cd /root/.etc/X11 && sleep 1 && mv xorg.conf zxorg.conf && sleep 1 && mv zzxorg.conf xorg.conf && sleep 1 && mv zxorg.conf zzxorg.conf && sleep 1 && restartwm"

I just type t (which is short reminder for transfer) and Return.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#41 Post by sunburnt »

Thanks Jasper; A command sequence, instead of a value ( sort of...).

But isn`t the "$" needed on the alias to make it work?

Jasper

#42 Post by Jasper »

Hi again

No it doesn't need a $.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#43 Post by mikeb »

Ok screenies are the only way here...

yad --file-selection --file-filter="IMAGES | *.png *.jpg" --file-filter="ALL | *.*"

produces the first... see the options list....

yad --file-selection --filename=/root/vincent.jpg --save --confirm-overwrite="Eat More Bananas?"

Provides alternative text for the confirm dialog...second image.

By the way how can GTK2 be set for single click in theshortcuts pane? Set at compile time?

mike
Attachments
alias.png
(10.32 KiB) Downloaded 1069 times
over.png
(28.39 KiB) Downloaded 1069 times

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#44 Post by mikeb »

Hmm i fiddled with the sources a little...

--form spinwheel output is now an integer and not floating... seemed logical and easier for scripts.

Color selector in -form dialog now has 6 digit result not 12.

Removed mysterious error with --notification dialog connected with middle click exit...removed option...in any case it could be added to the right click menu if required.

mike

edit ..update see later post
Last edited by mikeb on Tue 27 Aug 2013, 21:18, edited 1 time in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#45 Post by sunburnt »

mikeb; Downloaded your modded Yad dialog, I`ll look at it.
Haven`t seen the shortcuts pane, so I haven`t a clue...

It`s senseable to make a std. filter list to be used for all of the file dialogs.
So to set it in code at startup don`t use an alias with "--file-filter=".

Q: Can no alias and a std. set of aliases be used together? . A: YES...
So filtering at startup, and the popup menu works to choose new filtering.


Mike, you do C programming it appears, ever mess with X ( custom windows ) ?
A way to do away with GTK and QT, and have a rational GUI foundation.


Jasper; Ah yes, that`s what the alias command does, it makes cli commands.
.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#46 Post by mikeb »

Well its nice to have an option...eg for pburn I can avoid a huge list of mp3 when all I want is the pburn file....the alias option is just for user friendliness and not essential....
A way to do away with GTK and QT, and have a rational GUI foundation.
I am a bad hacker,,,I find C akin to double dutch though realising what a low level language it is it at least makes a little more sense to me....as for C++..
It does not come naturally like other languages I play with.

FLTK looks nice but has never taken off as a major alternative.

The shortcut pane is... see piccie... see how skilled I am with a mouse.
mike
Attachments
short.png
(69.91 KiB) Downloaded 469 times

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#47 Post by sunburnt »

You`re very skilled Mike, don`t ever let anyone tell you otherwise. :wink:

FLTK is pretty spartan from what I`ve seen in Tiny Core Linux.

Ahhh, the Places pane...


I hate wasted space, the file dialog puts the filter aliases above the buttons.
It should be next to the buttons, then the panes would be proper full height.
.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#48 Post by greengeek »

sunburnt wrote:You`re very skilled Mike, don`t ever let anyone tell you otherwise. :wink: .
Except when it comes to making straight arrows :)

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#49 Post by mikeb »

Yes I forgot there was a drawing tablet attached.... Mr smiley was relieved I noticed it eventually,

I wonder if this is why I have only once been asked to write technical documentation?

I am on the blunt side of the cutting edge....

mike

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#50 Post by sunburnt »

Got most of it working, but the file filters is just kicking my arse.

Anyone see anything that`s wrong with this picture?

There`s test code at the bottom that shows the command line.

For help type: yfiledlg -h

Code: Select all

#!/bin/sh
#########	Setup a Yad file/dir. selector.

#####	Usage:  yad_filer [-f,-d,-m,-s,-t][-o /path/file][-p /path,-g W, H, X, Y][-x ext.]


appP=`dirname $0`
i=1

all='--file-filter="All | *"'				#####	Combo list of file groups.
hid='--file-filter="Hidden | .*"'
doc='--file-filter="Document | *.txt *.pdf *.doc *.docx *.xml *.htm* *.pps *.ppt* *.csv"'
img='--file-filter="Image | *.jpg *.jpeg *.png *.xpm *.svg *.ico *.bmp *.tif, *.gif"'
aud='--file-filter="Audio | *.mp3 *.mp2 *.wma *.ogg *.aac *.ac3 *.flac *.m4a *.wav'
aud=$aud' *.m4a *.m4b *.m3u *.m1a *.mka *.mpa *.pcm *.midi *.mid *.m4p *.m4r"'
vid='--file-filter="Video | *.mp4 *.m4v *.ogm *.wmv *.wmx *.mpe *.mpeg *.mpg *.avi *.vob'
vid=$vid' *.mov *.qt *.mpeg-1 *.mpeg-2 *.mp2v *.m2v *.m2s *.mpa *.mp2 *.m2a *.asf *.asx *.swf"'


while [ $i -le $# ]							#####	Loop:  Parse command args.
do
	case `echo $@ |cut -d' ' -f$i` in

	-f) args="$args --file" ; ((i=i+1)) ;;										# file dialog

	-d) args="$args --directory" ; ((i=i+1)) ;;									# folder dialog

	-m) args="$args --multiple" ; ((i=i+1)) ;;									# multi. select

	-s) args="$args --save" ; ((i=i+1)) ;;										# save file

	-o) eval O=\${$((i+1))} ; Txt=`cat $O`										# overwrite file
			args="$args --confirm-overwrite=$Txt" ; ((i=i+2)) ;;

	-p) eval O=\${$((i+1))} ; args="$args --filename=$O" ; ((i=i+2)) ;;			# startup /path

	-x) eval O=\${$((i+1))} ; args="$args --file-filter=$O" ; ((i=i+2)) ;;		# extension filters

	-t) TB=55 ; ((i=i+1)) ;;													# taskbar offset

																				# window geometry
	-g) eval W=\${$((i+1))} ; eval H=\${$((i+2))} ; eval X=\${$((i+3))} ; eval Y=\${$((i+4))}

			scrW=$((`xwininfo -root |grep '\-geo' |sed 's#.* ##;s#x.*##'`-5))
#			scrW=`xwininfo -root |grep '\-geo' |sed 's#.* ##;s#x.*##'`
			[ $W -gt $scrW ]&& W=$scrW											# fix W
			[ $((W+X)) -gt $scrW ]&& X=$((scrW-W))								# fix X

			scrH=`xwininfo -root |grep '\-geo' |sed 's#.*x##;s#+.*##'`
			[ $H -gt $scrH ]&& H=$((scrH-TB))									# fix H
			[ $((H+Y)) -gt $scrH ]&& Y=$((scrH-H-TB))							# fix Y

			args="$args --geometry=${W}x${H}+${X}+${Y}" ; ((i=i+5)) ;;
																				# help
	-h) echo -e '\n\t\t#####\tyFileDlg\n\n\t# Usage:  yFileDlg [opt.1] [opt.2] ...\n'
			echo -e '\tFile open:  -f\n\tDirectory open:  -d\n\tPath:  -p /path/'
			echo -e '\tSave file:  -s\n\tOverwrite file:  -o filename'
			echo -e '\tMultiple files & folders:  -m\n\tExtension patterns:  -x *.txt *.doc'
			echo -e '\tGeometry:  -g W H X Y\n\tTaskbar offset:  -t  ( Comes before -g )\n'
			exit ;;
	esac
done


echo -e "\nScreen W x H  =  $scrW x $scrH\n\nYAD$args $all $hid $doc $img $aud $vid\n"

yad $args $all $hid $doc $img $aud $vid

Post Reply