OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Utilities => Topic started by: Devid on October 12, 2019, 11:47:28 pm

Title: Color labels
Post by: Devid on October 12, 2019, 11:47:28 pm
Hi
there is a way to label (for example with a color) or mark (with an icon/image) a file like Mac does?
Maybe reading/setting a sort of EA?

For example on XFCE (linux) I wrote a little shell script (in the popup menu) that mark the file icon.
Is it possible with AOS?

D.
Title: Re: Color labels
Post by: xynixme on October 13, 2019, 01:56:35 pm
a way to label (for example with a color) or mark (with an icon/image) a file like Mac does?
Maybe reading/setting a sort of EA?

I'm not aware of what a Mac does nor what it looks like, but you can use a file type to set an icon if the file name has no fixed pattern. You may need something in the middle to assign the right marked icon.

I can create a "PDF file" called "C:\I_hate_file_extensions!!!" with a PDF icon because of the file type (EA), but I'll need something extra to change the file type to "Printed PDF file" with a matching marked PDF icon later. Without using CGI to modify and replace an existing icon, that is.
Title: Re: Color labels
Post by: Laurence Pithie on October 14, 2019, 02:52:09 am
You can set a file's icon with the SysSetIcon function in the RexxUtil library. Just feed it the file name and the icon file name. The WPS can be a bit picky about the format of the icon though, if it isn't happy it will display the default icon instead of the new one. The details of the format can be found in the Control Program Guide in the toolkit information.
Title: Re: Color labels
Post by: xynixme on October 14, 2019, 05:03:15 am
You can set a file's icon with the SysSetIcon function in the RexxUtil library.

He should be able to do that with OO.EXE, which may avoid or postpone a REXX.DLL crash. Setup string "ICONFILE=C:\FOO\BAR.ICO". A disadvantage can be that the original icon may be unknown. He wants to "mark" an existing icon, so this will only work if the existing icon is known and BAR.ICO is its marked version.

For example, you can assign the file type ScanMe to all files in a folder, and associate those ScanMe files with a VIR-SCAN.CMD file (and its matching VIR-SCAN.ICO file). Let VIR-SCAN.CMD scan the files and change the file's type from ScanMe to MarkAsScanned (or delete the file type EA, to restore an original icon). Untested and FWIW.
Title: Re: Color labels
Post by: xynixme on October 14, 2019, 06:58:32 am
An untested and modified existing sample of a part of the .type EA route, FWIW, with one added line:

Code: [Select]
/* REXX SetType.cmd */
/* only used during installation */
call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
call SysLoadFuncs
parse arg fn

if left (fn,1)='"' then parse var fn '"' fn '"' .

/* set Sudoku .TYPE EA for the file */
type = 'Sudoku'
typeEA = 'DFFF00000100FDFF'x || d2c( length( type ) ) || '00'x || type
call SysPutEA fn, '.TYPE', typeEA
exit

Associate the type with a single executable-file-with-an-own-icon, e.g. a SUDOKU.EXE.

Next associate the type with data files, like unsolved puzzles.

Finally create a SOLVED.CMD file with a SOLVED.ICO file, which changes the type of a data file from "Sudoku" to "SolvedPuzzle", with an icon which looks like a marked icon of SUDOKU.EXE.
Title: Re: Color labels
Post by: RickCHodgin on November 01, 2019, 01:11:39 pm
You can set a file's icon with the SysSetIcon function in the RexxUtil library. Just feed it the file name and the icon file name. The WPS can be a bit picky about the format of the icon though, if it isn't happy it will display the default icon instead of the new one. The details of the format can be found in the Control Program Guide in the toolkit information.

If you need a little app to take an existing icon and colorize it, or add colors to it or some such, let me know.  I could write it.  You could call it from the command line or a script with the color you want.  I could also add some PM interface to let you choose dynamically.

Some nice features might be:
Scale the icon down (scale=80% for example)
Draw a border around it (border=2px for 2 pixel border, color=rgb(255,0,0) for red, green, blue colors for example)
Put colored blocks here or there (block=4px,0,0 to put a 4 pixel square box @ 0,0 upper left)
Draw a line or rectangle (line=[0,0]-[w,2] to draw 2 pixel a line at the top from 0,0 to width,2)

And other features.
Title: Re: Color labels
Post by: Devid on November 01, 2019, 04:14:41 pm
Welcome back, Rick!!
Thank you all for your answers.
I did some research and found that is possible, if i'am not wrong, to extend the WPAbstract class.
I think it's possible to record in the OS2.INI a .LABEL reference color and setting it in the .EA file attribute.
Or pheraps change the .ICON .EA from a popup menu.
But the ideal would be to overlap the original icon with a "mark" icon (for example a mini printer icon for the printed file, or a warning icon for important file, ecc.).
Unfortunately I don't have anough skill for this type of programming (C / C++ / SOM) and I don't know what is the best dev ambient (VAC, GCC, Watcom??).
Furthermore I think many of us use some desktop enhancer (xworkplace, wps-wizard, ...) then this (I think) very useful extension would be compatible at system level (for example with xview).

If Rick you are able to write this extension there is some open source interesting example in edm2.com site.

Regard
Title: Re: Color labels
Post by: RickCHodgin on November 01, 2019, 04:31:10 pm
Welcome back, Rick!!
Thank you all for your answers.
I did some research and found that is possible, if i'am not wrong, to extend the WPAbstract class.
I think it's possible to record in the OS2.INI a .LABEL reference color and setting it in the .EA file attribute.
Or pheraps change the .ICON .EA from a popup menu.
But the ideal would be to overlap the original icon with a "mark" icon (for example a mini printer icon for the printed file, or a warning icon for important file, ecc.).
Unfortunately I don't have anough skill for this type of programming (C / C++ / SOM) and I don't know what is the best dev ambient (VAC, GCC, Watcom??).
Furthermore I think many of us use some desktop enhancer (xworkplace, wps-wizard, ...) then this (I think) very useful extension would be compatible at system level (for example with xview).

If Rick you are able to write this extension there is some open source interesting example in edm2.com site.

Regard

I would need some assistance to get started.  If anyone's interested in helping me get up and running on this, I'll do it.

UPDATE:  I've looked a little into this.  Does anybody have a working example of something that modifies icons in a some way?  If so, I can see how their code did it and use that as a base.
Title: Re: Color labels
Post by: Devid on November 01, 2019, 05:22:41 pm


I would need some assistance to get started.  If anyone's interested in helping me get up and running on this, I'll do it.

UPDATE:  I've looked a little into this.  Does anybody have a working example of something that modifies icons in a some way?  If so, I can see how their code did it and use that as a base.
[/quote]
About changing icon I don't know if it's already there an OS2 API to do it. Pheraps should at programming level copy the original icon in the %TEMP% directory, superimpose the mark icon/image and subsequently set the new icon in the .ICON EA.
I had imagined doing it with some REXX script (attached to pop-up menu) using imagemagick convert. But I realized I couldn't do it  :-[

P.S.: In the "Workplace Shell programming..." book there is an example of a little program that change EA attributes of a file dropped in.

Regard
Title: Re: Color labels
Post by: RickCHodgin on November 01, 2019, 11:48:02 pm
Quote
I would need some assistance to get started.  If anyone's interested in helping me get up and running on this, I'll do it.

UPDATE:  I've looked a little into this.  Does anybody have a working example of something that modifies icons in a some way?  If so, I can see how their code did it and use that as a base.

About changing icon I don't know if it's already there an OS2 API to do it. Pheraps should at programming level copy the original icon in the %TEMP% directory, superimpose the mark icon/image and subsequently set the new icon in the .ICON EA.
I had imagined doing it with some REXX script (attached to pop-up menu) using imagemagick convert. But I realized I couldn't do it  :-[

P.S.: In the "Workplace Shell programming..." book there is an example of a little program that change EA attributes of a file dropped in.

Regard

I see with WPAbstract, it overrides several WPObject methods, including wpSetIconData(), which is used to persistently set icon info (wpSetIcon() sets only the current instance in memory).

The documentation I have from Borland says it's not typically overridden.  If it could be overridden, then the intercept could be coded to allow for special augments before the icon data is permanently set.

I'll check the documentation you state.  And if any existing OS/2 developers would like to help me also that would be great.
Title: Re: Color labels
Post by: Dave Yeo on November 01, 2019, 11:51:23 pm
Wonder what the precedence of icons is? You can have them in the binary as a resource, in an EA or with the same name as the exe with .ico for a suffix. Possibly if the *.ico takes precedence, just need to change that.
Title: Re: Color labels
Post by: Devid on November 03, 2019, 12:03:59 am
Hi.
I found an interesting WPS class extension that comes close to what I mean.
http://hobbes.nmsu.edu/download/pub/os2/util/wps/wpdsc093.zip (http://hobbes.nmsu.edu/download/pub/os2/util/wps/wpdsc093.zip).
This class extension add a Description field in the detail view. There is also some interesting infos in the zip archive.
An idea could be to use a bit mask to store some color label/tag associated with a description in the EA.
And a column in the WPS details view to view a sort of colored circles associated with the bit mask.
In this way it is possible to mark an object with more than one tag.
Another big/small improvement could be adding the possibility to choose the order of the columns in order to view first the colored dots.
Such functionality can be viewed for example in Mozilla Thunderbird.

Regards.
Title: Re: Color labels
Post by: RickCHodgin on November 03, 2019, 03:06:59 pm
Hi.
I found an interesting WPS class extension that comes close to what I mean.
http://hobbes.nmsu.edu/download/pub/os2/util/wps/wpdsc093.zip (http://hobbes.nmsu.edu/download/pub/os2/util/wps/wpdsc093.zip).
This class extension add a Description field in the detail view. There is also some interesting infos in the zip archive.
An idea could be to use a bit mask to store some color label/tag associated with a description in the EA.
And a column in the WPS details view to view a sort of colored circles associated with the bit mask.
In this way it is possible to mark an object with more than one tag.
Another big/small improvement could be adding the possibility to choose the order of the columns in order to view first the colored dots.
Such functionality can be viewed for example in Mozilla Thunderbird.

It looks like the source code for how this is actually performed is trapped inside rxdscr.dll, dscrlst.dll, and dscrdf.dll.

I did a search here at OS2world and didn't find any Vitaly names.  So I contacted him at the Wiki emails (https://www.os2world.com/wiki/index.php/Vitaly_Gumirov), but they both bounced.  I Googled and tracked him down (https://www.youtube.com/watch?v=3JiMN_JoBSk) to his current website and sent him a message.

It's been many years (uploaded to Hobbes in 1995, and he's now involved in Crypto Currency among other things).  We'll see if he responds.