A few issues, xLabel and xPopup Thread last updated on 2007-07-03 02:51:44

Posted by member 256241 on 2007-06-27 19:26:23

Hi, I'm having a few niggling problems which I thought I'd post here.

1, I am trying to make an xLabel's image change to the icon of an EXE. Currently it works perfectly for PNGs etc. According to the docs:

(label-name)Image "$windir$explorer.exe,3"

However, whenever the path I give it is not an image file, but an EXE, it simply doesn't load anything. Here's my code:

where qIcon12 = "C:\Program Files\7-Zip\7z.exe, 0"
*script exec !parseEvars !setevar quicklaunch12overlayimage "%{qIcon12}"

Can somebody tell me where I'm going wrong? Theres .icon drawing mode, but the docs insinuate that the .image mode can do just that, and it'll save me have to switch between drawing modes at runtime.

2, I have a pinned popup, in which a label is hooked. In that label, multiple labels are hooked, right clicking on one brings up another xPopup. When the second popup is unpinned or closes through autohide, both popups are cleared. Does anyone have any ideas about this one?
[edit] I have worked around this by calling the following bang command OnClose of the second popup:
*script bang !lrecreatepopup
*script exec !startPopup %#%{popx}%# %#%{popy}%# centercenter
*script ~bang
It seems a bit inefficient, but it works. Anyone know the PROPER way to do this?

3, if qTarget1 = "c:\folder\application.exe", is there any way to extract just the application file name, and lose the full path and extension, for the sake of displaying the name in a tooltip?

4, A bit more of a general icon question. Most EXEs have different icons, and different sizes. Do standard exes have icons in 24*24? I know they have 16,32,64... Have I shot myself in the foot by using 24*24 as the size for my launchers?

5. Is there a way to have a selected colour be transparent when using an image for an xLabel? By this I mean, that if an icon image you used has white as the background colour, that it could treat that as transparent? If so, I imagine there would be issues with antialiasing?

6. Is there an easy way to input some text, like comdlgls, into which I could enter plain text, so define bang commands as well as shortcuts to apps? I gather this would be possible in xLabel's textedit mode, but is there a module that would be simpler for my intended use?

Thanks for reading, and for hopefully helping me solve at least one of them!

Posted by member 248213 on 2007-06-27 23:03:44 link

1 You need to use the ".icon" paintingmode and the "Icon" setting instead of the "Image" setting.

2 No idea. Make sure it is actually pinned?

3 Parse the path and extension with regexp (scripting)

4 I dont think 24x24 is too popular

5 No I think only magic pink can be magic (with the correct settings ofcourse)

6 Simpler module? Not that I am aware of. Texteditboxes are pretty simple though ;)

Posted by member 256241 on 2007-06-28 20:59:46 link

Thanks fractal.

1, Damn. (Once I get it to work) Is there any way of telling whether the intended image/icon path is to an exe,ico,dll instead of an image file, so that I can set the imagemodes to the correct type?

2. Yeah, it's pinned. Hmm, I think I'm going to live with my workaround for now, doesn't seem to much of a resource loss and it works.

3. Ill have a look into that.

4. Damn, well, it doesn't seem to look so bad when I stretch them to size. Are there like, different algorithms for stretching or something with a super-quality mode....? Heheh

5. That's a shame, but I suppose it just pays to find/make decent icons in the first place.

6. Okay.

Back to work I go, thanks.

Posted by member 248213 on 2007-06-29 00:57:05 link

1. exe, ico and dll all use PaintingMode .icon (because they are icon resources) So unless you are switching between images (png, bmp, jpg or gif) you should just leave it on ".icon"

4. Just extract the icons the correct size... "IconExtractionSize 16"
I thought you let the user pick which apps they want, so its not like you have static 24x24 icons that dont change, right?

5 Yes, yes it does. I suggest png2ico.exe (I think its free) I'll mail it if you can't find it on google ;)

Posted by member 256241 on 2007-06-29 08:23:55 link

1. That's exactly it though. I want the icon to change to the default icon of the target exe that's selected as a target for that launch label. Then after that, you can change the icon by browsing for an image, and use a png or something. Then maybe set it back to the exe for it's default icon.

Maybe I could have two overlays for the icon, one in .icon and one on .image, then whenever it's invalid it wont show, and it cant be both of them.

4. The size of these launchers are 16*16 and 24*24. Their sizes cant be changed at runtime, and even otherwise its a pain. (remember, I hacked this together with labels).

5. Hmm, I'll look it up. I've got a feeling I might have used it before.

Cheers.

Posted by member 248213 on 2007-06-29 12:52:00 link

1 Hey thats not a bad idea actually. But maybe the on top overlay will "block" the one behind it anyway.

4 Well, just change them all to the standard 16x16

;)

Posted by member 1 on 2007-06-29 14:53:56 link

1. If you used a MagicPink default image and put the icon below it might work. Im pretty sure that Labels ignore MagicPink being clicked.

Posted by member 256241 on 2007-07-01 20:08:57 link

Ok, I've got the two overlays on top of each other, and in essence it's all there and working. However, as I think you anticipated DevilBoi, the icons default image (at least I think it's the default image) is shown even when the icon I tell it to display is a png.

I couldn't see a setting anywhere in the docs for changing the default icon, is it possible? Thanks

Posted by member 1 on 2007-07-01 20:19:37 link

You would have to run a script on recycle that says if the image isn't default.png to display the default icon. And I can't take credit for that one...

Posted by member 256241 on 2007-07-01 20:23:45 link

Thanks, but I'm sorry, I don't quite understand.

On recycle both overlay's images/icons are set to the same value. How do I know if it should be displaying the icon or the image (whether to set the icon to a "default" one...

Thanks.

Posted by member 248213 on 2007-07-01 20:39:44 link

And if your going to script that, you may aswell script a single label changing paintingmode...

And you are using mz, so why not?

Really you should switch to lua and check out my deskicons config in laserdock :D because all this stuff I have been through allready.

Also, there are no "default" images/icons used by xPC. Just the "window" or the label will still be created, just transparent as no "image" is configured.
Because paintingmode .none (the default) does not paint the window the same way (and is thus click through'able)
But that does not solve your problem.

In laserdock I have functions that figure out if the resource is image or icon and set the paintingmode evar for that label accordingly.

And remember the latest beta of xPC can handle jpeg's and gif's too ;)

Posted by member 256241 on 2007-07-01 20:57:50 link

Here's a screenshot:
http://img106.imageshack.us/img106/1589/untitledky9.jpg

The top left of the bottom square of labels has two overlays, the image path the same as the icons path. What you see in the screenshot, is the circle of the firefox logo (png), and what has to be a default image for the .icon overlay... If only it would be blank when it cant draw the icon you give it...

I want to avoid scripting a solution around this, as I don't know how I will tell if the user selected an exe or a png in the comdlgls for the icon... If I could then I suppose a scriptaround is possible.

Thanks

Posted by member 248213 on 2007-07-02 07:52:11 link

"the image path the same as the icons path"
So the .icon overlay has "Icon firefox.png"?
Well, then it will display the icon for png files.

Because they are independant (1 for images, 1 for the rest) you need a way to figure out what the resource is being changed to.

So, what is different about the resource? How can we tell them apart?
File extensions are how the OS differs files, so that would be a safe bet.

The extension can be defined by "Anything after the last point/fullstop" eg; "blah.extension"

Ok, so how can we detect a file extension?
"Regular expressions" (or "patterns" in lua) can parse any string according to a set of rules.
So you can form a regexp (or pattern) that means "Return Anything after the last point/fullstop"

I use this code for lua:
local ext = string.match(filepath,".*[/\\/.](.*)")
if ext == nil then
return "unknown"
else
return string.lower (ext)
end

The first line defines a local variable "ext" whos value will be set to a match in the string "filepath".
The rules of the match (the pattern), in english are something like: "After any amount of characters(.*) and after a backslash[/\\ and a fullstop/.] find any number of characters and return them as the result(.*)"
Whew! :D

The second checks if anything was grabbed (maybe trying to find the extension for "C:\folder\filename" which has no extension)

The fifth line just makes it lower case for easy checking (eg; PNG != png)


You should go with lua. Its not too rough, and lots of themers here (and @ ls-themes.org) use it

Posted by member 1 on 2007-07-02 17:00:30 link

Why not just trim off the filepath to the last 3 characters and see what they are?

Posted by member 256241 on 2007-07-02 19:15:52 link

I'd be interested in being able to do this, however I really don't know how to go about it. I'm at the end of developing this theme and don't really want to switch to lua. Is there any way in litestep to trim a string to it's last 3 characters except lua?

At the moment, I'm working it in so that before you select the image/icon you tell it if it's an icon or not. I guess this way around will work, but it adds a pointless menu item.

Back to work...

Thanks.

Posted by member 212670 on 2007-07-02 19:34:23 link

You can with xlabel: [afterLast(x, delim)]

Example to run in a command:

!ParseEvars !alert %[afterLast('c:\some\path\file.ext', '.')]%

Posted by member 248213 on 2007-07-03 02:51:44 link

Hey thats neat xcal :)

And it will work for all extensions too (.jpeg is 4 chars long)