YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
kjdixo
Posts: 153
Joined: Sun 13 Sep 2009, 21:13

#41 Post by kjdixo »

Combo box retains selection

Code: Select all

#! /bin/bash
title=$(echo "Select")
item='1.Airline Tickets!2.Cars!3.Folding Bike!4.Linux Netbook!5.Lightweight Clothes'

combo()
{ 	
choice=$(yad --title="$title" --text='Travel Items' --form --field='Show:CB' "$item" --button="Exit:1" --button="OK:0")

ret=$?
if [[ $ret -ge 1 ]]; then
exit 0
fi

choice=$(echo $choice | awk 'BEGIN {FS="|" }{print $1}')
echo $item
echo $choice
title=$(echo "$choice")
item=$(echo $item | sed "s/$choice"!"//g" | sed "s/"!"$choice//g")
echo $item
item=$choice"!"$item
}

while true ; do
combo
done 

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#42 Post by slavvo67 »

Probably a pretty easy question but how to I have the fsck command run in an open terminal from this script? I can't just pass fsck to YAD because fsck requires possible interaction via terminal.

#!/bin/bash

cd /
choice2=$(yad --title='Drives' --text='Choose Drive Prefix for Possible Defrag' --form --field='Show:CB' '0.Exit!1. SDA!2. SDB!3. SDC!4. SDD!5. SDE!6. SDF!7. SDG!8. SDH' --button="Exit:1" --button="OK:0")
ret=$?
if [[ $ret -eq 1 ]]; then
exit 0
fi
numb666=${choice2:0:2}
if [[ $numb666 = "1." ]]
then
name1="/dev/sda"
elif [[ $numb666 = "2." ]]
then
name1="/dev/sdb"
elif [[ $numb666 = "3." ]]
then
name1="/dev/sdc"
elif [[ $numb666 = "4." ]]
then
name1="/dev/sdd"
elif [[ $numb666 = "5." ]]
then
name1="/dev/sde"
elif [[ $numb666 = "6." ]]
then
name1="/dev/sdf"
elif [[ $numb666 = "7." ]]
then
name1="/dev/sdg"
elif [[ $numb666 = "8." ]]
then
name1="/dev/sdh"
fi
parted $name1 'print'|yad --geometry=900x600 --list --title "Drive Results" --text "Listing Drive Types.." --column "Types" --button="Exit:1" --button="OK:0"
ret=$?
if [[ $ret -eq 1 ]]; then
exit 0
fi
yad --text="Choose a the name of a file to obtain the most recent version:" --button="Exit:1" --button="OK:0"
ret=$?
if [[ $ret -eq 1 ]]; then
exit 0
fi
search555=$(yad --entry --entry-label="Drive to Defrag Enter as sda2" --button="Exit:1" --button="OK:0")
ret=$?
if [[ $ret -eq 1 ]]; then
exit 0
fi
cd /
###########################
fsck "/dev/$search555" -f
###########################

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

#43 Post by mikeb »

The -y parameter might help just not sure if it works for all formats...answers yes to all questions.
or the -p = no questions.

mike

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#44 Post by slavvo67 »

Hi Mikeb:

I didn't get it at first but the -y did indeed fix the issue.

Good to hear from ya,

Slavvo67

FIXED

#!/bin/bash


# Just a little GUI to defrag partitions -Slavvo67
# Needs YAD and fsck
# fsck takes a while on USB's so wait a bit longer for those.
cd /
choice2=$(yad --title='Drives' --text='Choose Drive Prefix for Possible Defrag' --form --field='Show:CB' '0. Exit!1. SDA!2. SDB!3. SDC!4. SDD!5. SDE!6. SDF!7. SDG!8. SDH' --button="Exit:1" --button="OK:0")
ret=$?
if [[ $ret -eq 1 ]]; then
exit 0
fi
numb666=${choice2:0:2}
if [[ $numb666 = "1." ]]
then
name1="/dev/sda"
elif [[ $numb666 = "2." ]]
then
name1="/dev/sdb"
elif [[ $numb666 = "3." ]]
then
name1="/dev/sdc"
elif [[ $numb666 = "4." ]]
then
name1="/dev/sdd"
elif [[ $numb666 = "5." ]]
then
name1="/dev/sde"
elif [[ $numb666 = "6." ]]
then
name1="/dev/sdf"
elif [[ $numb666 = "7." ]]
then
name1="/dev/sdg"
elif [[ $numb666 = "8." ]]
then
name1="/dev/sdh"
fi
parted $name1 'print'|yad --geometry=900x600 --list --title "Drive Results" --text "Listing Drive Types.." --column "Types" --button="Exit:1" --button="OK:0"
ret=$?
if [[ $ret -eq 1 ]]; then
exit 0
fi
search555=$(yad --entry --entry-label="Drive to Defrag Enter as sda2" --button="Exit:1" --button="OK:0")
ret=$?
if [[ $ret -eq 1 ]]; then
exit 0
fi
cd /
fsck "/dev/$search555" -fy | yad --geometry=900x600 --list --title "Defragging" --text "/dev/$search555" --column "Working..." --button="Exit:1" --button="OK:0"

stemsee

thumbnails

#45 Post by stemsee »

How to get yad to display a list of thumbnails from backgrounds directory. I know the --image switch to display one full sized image, but that's all.

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#46 Post by Geoffrey »

The only way I know of displaying an image from a list, is in a file selector with a preview

Code: Select all

yad --file-selection --add-preview
Attachments
yad-preview.png
(108.24 KiB) Downloaded 1651 times
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

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

#47 Post by mikeb »

Hmm could the icons box be used in some way...might be messy though as its intended as a launcher dialog for desktop files...

yad --help-icons

mike

stemsee

#48 Post by stemsee »

Thanks Geoffrey

That is better than what I have now.

stemsee

#49 Post by stemsee »

In fact I am getting thumbnails in yad and preview.

Code: Select all

wp=`yad --title "Select Wallpapers" --geometry=400x500 --file-selection --multiple --add-preview` 
Attachments
capture30443.jpg
(46.79 KiB) Downloaded 1519 times
capture32134.jpg
(40.12 KiB) Downloaded 1517 times

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#50 Post by Geoffrey »

stemsee wrote:In fact I am getting thumbnails in yad and preview.
Yeah, me too now, the thumbnailer was a little slow creating them.
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#51 Post by slavvo67 »

Importantly, the above does not work in some older versions of YAD. I think Quirky Unicorn has an old version that would need updating first.

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#52 Post by smokey01 »

Two nice things about YAD, it easy to compile and is a single binary so very easy to update.

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

#53 Post by mikeb »

I did manage to build YAD for puppy 4.12 and similar but that does not allow the newer features mentioned.... but hardly a reason to not do tarty things with it :)

And yes...a delight to build... nice coding and easy to hack :)

mike

User avatar
rg66
Posts: 1158
Joined: Mon 23 Jul 2012, 05:53
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

#54 Post by rg66 »

slavvo67 wrote:Importantly, the above does not work in some older versions of YAD. I think Quirky Unicorn has an old version that would need updating first.
Most puppies come with yad-0.12.4, slacko doesn't have it at all. Current is 0.28.1, you can get it here: http://smokey01.com/rg66/X-slacko/pet_p ... 0.28.1.pet, should work in any puppy.
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#55 Post by slavvo67 »

Thanks RG66. I have a new version but as you pointed out, not all puppies have YAD and some contain older versions.

One small item that is puzzling me is how to display hidden files / directories in YAD. Had anyone solved this one?

Thanks,

Slavvo67

User avatar
rg66
Posts: 1158
Joined: Mon 23 Jul 2012, 05:53
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

#56 Post by rg66 »

slavvo67 wrote:One small item that is puzzling me is how to display hidden files / directories in YAD. Had anyone solved this one?

Thanks,

Slavvo67
I did request a "--show-hidden-folders" and he said was going to do it but it never happened. You can do

Code: Select all

 yad --file
right click on the right pane and click "show hidden files".
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#57 Post by slavvo67 »

rg66:

Thank you for the right-click tip. I didn't think about something so obvious but sure enough, it works. Not quite the same as programming it in from the beginning but it'll certainly do.

Thanks again,

Slavvo67

User avatar
rg66
Posts: 1158
Joined: Mon 23 Jul 2012, 05:53
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

#58 Post by rg66 »

I suppose something like this would do:

Code: Select all

yad --file --text="<span color='blue'>To see hidden files, right click and choose 'show hidden files'</span>" --text-align="center" --width="500" --height="400"
Attachments
Screenshot.jpg
(46.21 KiB) Downloaded 1348 times
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]

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

#59 Post by mikeb »

I suppose something like this would do:
good thinking indeed :)

the right click hidden files option seems to be standard gtk2 behaviour but not well known about.

mike

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

right click hidden files option

#60 Post by seaside »

Try this.

Create below file and put at " /root/.config/gtk-2.0/gtkfilechooser.ini"

Code: Select all

# /root/.config/gtk-2.0/gtkfilechooser.ini
[Filechooser Settings]
ShowHidden=true
All gtkfilechooser calls should now show hidden files.

Cheers,
s

Post Reply