Adding DefIcons with script

This forum is for general developer support questions.
Post Reply
User avatar
jaokim
Beta Tester
Beta Tester
Posts: 92
Joined: Sat Jun 18, 2011 1:41 am

Adding DefIcons with script

Post by jaokim »

I want to add new default icon for JAR-files automatically when installing JAmiga.
Adding the default icon is enough by copying def_jar.info to ENV:sys/. But how can I automatically make DefIcons use it? JAR-files are actually ZIP-files, so the icon they'll get by default is a ZIP icon.

I've manually added def_jar.info to DefIcons by applying the same matching as for ZIP files, and also adding the .jar suffix. But that was manually with the DefIcons prefs. Is it possible to do this with a command line tool, so it can be automated during install?
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 1:06 am

Re: Adding DefIcons with script

Post by xenic »

It's probably a bad idea to change a user's system prefs or prefs for another program. In addition, a user may have significantly modified DefIcon prefs that would require significant analysis by a script or program to be sure the user's DefIcons functionality won't be compromised. It's easy to mess up you DefIcons by adding new definitions in the wrong place.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
jaokim
Beta Tester
Beta Tester
Posts: 92
Joined: Sat Jun 18, 2011 1:41 am

Re: Adding DefIcons with script

Post by jaokim »

It's probably a bad idea to change a user's system prefs
I agree it is a bad idea to change with user preferences, but if there was an official way to do it safely, it'd be great.


Meanwhile, I've been looking into the Merge-option of DefIcons, and found it not entirely working.
I'd expect it to work by starting with an empty DefIcons rpeference, creating your own subset of deficon entries (in my case for .jar and .class), saving it to a file, and then merging this with the full DefIcons settings. However, it doesn't work like this.

To reproduce:
Pre-requisities: a drawer with a few files without .info, but correct deficons (for example jpg-files)
1. Open Prefs/DefIcons
2. Choose "Edit/Reset to defaults" from menu (you'll get an empty list with only "project")
3. Press "Add", and change name to "jar".
4. Add... Pattern: "#?.jar"
5. Choose "Project/Save as...", RAM:temp.prefs
6. Choose "Edit/Last saved" from menu, to get back your original settings
7. Choose "Project/Merge...", and choose RAM:temp.prefs
8. In the list, at the bottom you'll now have another "project" entry, with a "jar" entry below it
9. Press "Use"
10. Go to the Workbench drawer with your jpg files and choose "Window/Update"

The files will now get all white icons!

A fix or work-around:
If you select the last "project" entry and press the up arrow, the "project" entry will be moved "up, and in" to the last section. If you then press the down arrow, it will move down to the bottom, and, I think, work ok.

(12. Go to DefIcons and revert to last saved, and press "Use", to get back to normal.)

If after resetting to defaults (step 2) you remove the "project" entry as well, you won't be able to add new entries.

Am I not using DefIcons that way I should, or is there an error somewhere?

Using DefIcons v 53.11 (3.12.2011)
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 1:06 am

Re: Adding DefIcons with script

Post by xenic »

@jaokim
I think you're attempting an impossible task. There is no way of knowing what main catagories or sub-categories the user has set in his DefIcons prefs. For example, here are the main catagories from the default DefIcons prefs in the DefIcons archive on Aminet (almost the same as the ones that came with OS 3.9):
project
+ascii
pdf
+tool
PREF
+iff
+iff
kickstart
+game
empty
object
lib
+archive
+diskarchive
+picture
+video
+sound
+music
kickstart
src
font
outlinefont
WordPerfect
Word6
PicView
key
+filearchive
library
ptch
tcd
java

Here are the main catagories I have in my default DefIcons.prefs for my X1000:
project
tool
+system
+ascii
+document
+video
+sound
+picture
+archive

My personal DefIcons prefs are different from the above examples. There is no way you could merge the above prefs and end up with working DefIcons. I suspect the DefIcons "merge" option was written with the original default prefs in mind. Even if it worked with OS4 defaults, about the best it could do is attach one set of prefs below the other. In addition, if you use the file extension #?.jar for DefICons to identify your files, you would need to check where the user has a "ZIP" file entry because a "jar" file is actually a ZIP archive. If you place your file extension definition for jar files below the ZIP file sub-category, your jar files might be identified as ZIP files. You probably should place your jar file definition in the ZIP sub-category above the rp9 definition with PATTERN #?.jar as identifier.
AmigaOne X1000 with 2GB memory - OS4.1 FE
Post Reply