Improving the Trash Can

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

Improving the Trash Can

#1 Post by dvw86 »

Some people have complained that the Trash Can does not work as expected. This is only a problem when dragging items to the trash from the Rox desktop. In Rox the desktop is a "Pin board" not a directory like it is in so many large operating systems and window managers. The desktop icons are links to the actual file. The links are stored in a text file in the Rox configuration directory. When an icon is dragged to the trash, Rox passes the file's path to the trash can script and the Trash Can proceeds to move that file to the trash directory. This leaves the link still in the Rox configuration file. Only now that link points to nothing, so Rox displays a "broken" link icon on the desktop.

To fix this you could ask the user if they want to remove the actual file, or just the link from the desktop. If they chose to remove the file, the Trash Can would move the file as it does now and then parse the Rox configuration file removing the entry. If they chose to just remove the icon from the desktop, the Trash Can would then just parse the Rox configuration file and remove the entry.

My problem is this. How can I test to see if the item dragged onto the Trash Can is a file or a link from the desktop?

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#2 Post by GuestToo »

How can I test to see if the item dragged onto the Trash Can is a file or a link from the desktop?
that's the whole point ... i don't think you can

i suspect all you could do is check every item dragged to the Trash Can to see if there is a desktop link to it, and if there is, act accordingly

personally, my choice would be to not try to build this feature into the Trash can ... the way desktop icons are supposed to be removed is to right click the selected icon(s), and click Remove Item(s)

another way to do it would be to have another desktop icon just for Trashing desktop icons ... but i don't think i would do that either

User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

#3 Post by dvw86 »

OK, here is a test version of the "improved" Trash Can. Personally I think I liked it better the other way, but this may cause less confusion to newbies. It works just like the current version except that it will remove any desktop icons to the file or directory that is being "trashed".

The downside is that the only way I could find to update the PinBoard was to restart it. This can look kind of ugly if you have a slower machine or if you have something like a newer version of Rox setting the Wallpaper. The code needs cleaned up, but right now I just wanted to make sure it worked.

Be sure to remove the current Trash Can from your desktop before trying this one.
Attachments
test-trash.tar.gz
Test Version of Trash
(83.01 KiB) Downloaded 496 times

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#4 Post by Lobster »

:) I was in an ideal situation to test this
just entering standard Puppy - two icons on the desktop saying error (I had deleted their directories whilst in SimplePup)

deleted old trashcan
downloaded and clicked on gzip file to almost auto extract it
dragged your trashcan onto the desktop

dragged the non icon showing desktop icons with the ERROR messages
and they were gone

(does not yet tell me what I am deleting when emptying the trash can)
So I would say it did exactly what I expected and is already more useful than the old trashcan

Many thanks - can we have it in 1.0.9?
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

#5 Post by dvw86 »

Lobster wrote: (does not yet tell me what I am deleting when emptying the trash can)
It would have if the directories weren't already deleted. Since you had already removed the original directories, all the trash had to do was remove the links from the PinBoard file. I'm glad it apears to be working for you. I'm tempted to add a restore feature that someone else has mentioned.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#6 Post by GuestToo »

the only way I could find to update the PinBoard was to restart it
i think you can add / remove desktop shortcuts using SOAP ... Rox 2.4.1 seems to be able to do this, but Puppy's Rox 1.2 does not seem to have this feature implemented ... from the docs:

PinboardAdd(Path, X, Y, [Label, Shortcut, Args]) Add Path to the pinboard at position (X, Y), giving it the (optional) label Label. If Shortcut is given it is the keyboard shortcut to trigger this item. If Args is given it is the argument string to append to the item when run if it is a program.

PinboardRemove(Path, [Label]) Remove Path from the pinboard. If Label is given then this must match the label of the item. If more than one item matches, only one is removed.

User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

#7 Post by dvw86 »

Interesting... I've never used SOAP before. Could you post a quick example and possibly a link to a good article/tutorial?

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#8 Post by GuestToo »

i haven't used SOAP - Simple Object Access Protocol with rox either ... rarsa wrote a program to set Rox's wallpaper using soap ... it seemed to work well, and it seems to be easy to do, just have rox read the parameters in the command line options ... there's more information in the rox documentation ... rarsa's program

User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

#9 Post by dvw86 »

Well here is some SOAP code that I took from rasa's script. It works well.

Code: Select all

#!/bin/sh

rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  <SetBackdrop>
   <Filename>/root/Downloads/wallpapers/3tsytux.jpg</Filename>
   <Style>Stretch</Style>
  </SetBackdrop>
 </env:Body>
</env:Envelope>
EOF
Here is some code that "should" remove the item "test" from the desktop. It does not work.

Code: Select all

#!/bin/sh

rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  <PinboardRemove>
   <Path>/root/test</Path>
  </PinboardRemove>
 </env:Body>
</env:Envelope>
EOF
I can not tell why it will not work.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#10 Post by GuestToo »

i just tried your code ... i created a folder /root/test ... i dragged it to the desktop to make a shortcut to /root/test ... i ran the script, and the shortcut was removed from the desktop

i am using Rox 2.4.1 ... i don't think Rox 1.2 has the capability to remove desktop icons using soap

User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

#11 Post by dvw86 »

Okay this is odd. I am using Rox 2.4.1 as well and it does not work on my computer. I had to remove the "EOF" at the end of the script to get it to work. I tried running it from a shell and got this error

Code: Select all

# sh NewFile
-:9: parser error : Extra content at the end of the document
EOF
^

** ERROR **: Invalid XML in RPC
aborting...
Aborted
I'm not sure why that last line wouldn't effect the other (rarsa's) script or why your system would work with it and mine wouldn't? Obviously I am no SOAP expert.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#12 Post by GuestToo »

here's a couple of scripts that work on my machine, with Rox 2.4.1 ... there should be a folder /root/test ... the roxadd script should create an icon in the center of the desktop if the screen res is 800x600
Attachments
soap.zip
rox soap demo
(720 Bytes) Downloaded 402 times

User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

#13 Post by dvw86 »

I've got it figured out, but I don't know why it makes such a differance. The last line of the script is

Code: Select all

EOF
If you press the spacebar after the "F" like so:

Code: Select all

EOF[spacebar]
it will not work. Also, you must press enter after the "F" like so:

Code: Select all

EOF[enter]

User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

Trash 2.0

#14 Post by dvw86 »

Well I finished it. It has been tested in Rox 2.4.1 and 1.2, both under Puppy 1.0.8. I made a lot of changes and (IMHO) improvements. Again, be sure to remove any other Trash icon off your desktop before installing this one. Here are a list of them all.

1. First off, Trash now requires Bash so it may not work in older versions of Puppy. I'm not sure about this though. I tested it with a fresh pup001 file so I know that no extra libraries are needed.

2. Desktop (pinboard) icons will be removed when the original item is moved to the Trash. The Trash will first attempt to use SOAP to do this. If SOAP fails, it will manually remove the item from the pinboard file and restart the pinboard. The most likely reason for SOAP to fail is if you are using an older version of Rox such as version 1.2. Puppy 1.0.8 uses Rox 1.2 by default. For this and other reasons I recommend that we use Rox 2.4 for Puppy 1.0.9. When the Trash removes an item from the desktop, it will notify you that the original item is being moved to the Trash AND that the desktop shortcut is being deleted.

3. Items in the Trash now have their own icon.

4. You can now "Restore" items from the Trash. This can be done either by right clicking on the item you wish to restore and selecting "Restore Trashed Item", or by left clicking on the item and selecting "yes" from the prompt. When an item is being restored it will first check to make sure it is not over-writing any other files with the same name. If a file with the same name already exists, it will ask you before over-writing it.

5. All items are checked to see if they are symlinks before being moved to the Trash. If an item is a symlink, it will notify you that only the symlink is being moved to the Trash and that the original file is not being altered.

EDIT 4-2-06
6. I have modified the Trash to remove ALL the desktop shortcuts pointing to the item that is being "Trashed". This should be better since only removing one leaves the rest of them "broken". I think this is more what people expect as well.

7. I also add a little feature that shows you where the trashed item was located before it was sent to the Trash. Just right click on the item in the "Trash" and select "View Original File Location".

Please give it a test. I will send it to Barry for Puppy 2, and to the tracker for Puppy 1.0.9, and make it into a dotpup if no issues are found. Thanks
Attachments
trash2-beta.tar.gz
Trash 2.0 beta
(88.87 KiB) Downloaded 517 times
Last edited by dvw86 on Mon 03 Apr 2006, 02:23, edited 1 time in total.

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

I have a bin. A great bin

#15 Post by Lobster »

I am in a fairly pristine Puppy from CD version of 1.0.7 with 2.6 kernel and I have a bin. A great bin.
This I can use. This makes sense. I drag things to the bin and they are still in the bin and can be uncrunched (or restored) until I decide to delete them

woof woof :)

The only thing that is unexpected (and it may be unrelated and a 1.0.7 issue with JWM) is the bar in the bottom right of JWM
So we need some testers using 1.0.8r1 and alpha Puppy2

This is a nice piece of work and it would be great if we can get it in Puppy 1.0.9 and perhaps even the next Puppy2 Alpha4?

Nice. More testers please!

Have placed it in news for March 28 2006
http://puppylinux.org/wikka/LatestNews
Attachments
red.jpg
(1.98 KiB) Downloaded 2311 times
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#16 Post by GuestToo »

Trash will first attempt to use SOAP
i think the rox docs say that soap will remove the first icon that matches the path ... if a desktop shortcut were dragged to the trash and there were more than one shortcut to the same path, maybe the trash program might sometimes remove an icon that the user did not intend to remove?
I recommend that we use Rox 2.4 for Puppy 1.0.9
rox 2.4 is bigger than 1.2, but it may not be as large as you might think ... a large part of the extra space is taken up by the shared-mime-database files ... the database can be rebuilt from the files in "packages" (i put the shared-mime-database files in /root, in .local ... but they could be put in /usr) ... the packages files are 99k compressed ... update-mime-database is 24k uncompressed

rox 2.4 does have some nice features ... many of the improvements are features that might be used primarily by advanced users

one feature that might be useful (by package managers) is the ability to add and remove desktop icons from the command line, without needing to restart rox

User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

#17 Post by dvw86 »

GuestToo wrote: i think the rox docs say that soap will remove the first icon that matches the path ... if a desktop shortcut were dragged to the trash and there were more than one shortcut to the same path, maybe the trash program might sometimes remove an icon that the user did not intend to remove?
That is correct, but they would have to have two or more icons pointing to the same thing, so it didn't seem like it would be that big of issues since the remaining icons would be "broken" as well. I guess I could just run a loop and as long as I find the entry in the pinboard, just keep removing them. Another thought is to add the <Label> so there is more of a chance that the "correct" shortcut gets removed.

Kal
Posts: 626
Joined: Thu 05 May 2005, 16:59
Location: California, High Desert

trash

#18 Post by Kal »

And your correct above, but I did a dumb, dumb, before Guest Too posted. So, rebuilt streamtuner's link and all is ok. Overall a great improvement. This problem has little chance of happening, but I was testing. Good Luck, Kal
ps: I am using rox 2.4.1

User avatar
dvw86
Posts: 636
Joined: Thu 05 May 2005, 00:55
Location: Washington State

#19 Post by dvw86 »

Well I have modified the Trash to remove ALL the desktop shortcuts pointing to the item that is being "Trashed". This should be better since only removing one leaves the rest of them "broken". I think this is more what people expect as well. I still attempt to remove the first shortcut with SOAP. If SOAP fails I then revert to removing them all manually. If SOAP is successful with the first item it then continues with the rest of them. I also added a little feature that shows you where the trashed item was located before it was sent to the Trash. Just right click on the item in the "Trash" and select "View Original File Location". The "Trash" script got a little cleaning up as well. It was getting a little hard to follow, so I tried to simplify it by using functions. Please forgive my messy code since I have no formal programming training. The new version has been uploaded and can be downloaded here.

Post Reply