This is the mail archive of the
cygwin-xfree@cygwin.com
mailing list for the Cygwin XFree86 project.
RE: Custom icons per window class/name patch
- From: "Ralf Habacker" <Ralf dot Habacker at freenet dot de>
- To: <cygwin-xfree at cygwin dot com>
- Date: Mon, 19 May 2003 21:19:42 +0200
- Subject: RE: Custom icons per window class/name patch
- Reply-to: cygwin-xfree at cygwin dot com
> Hi Ralf,
>
> I did some checking in between packing today and it was relatively simple
> to get the res_class and res_name of a window in the winCreateWin function,
> but the thing is you can't use any XLib calls: you're the server itself at
> that point, and not a client!
Good that there is someone, who have got this. ;-)
> I've done a quick-n-easy icon specifier, namely a file called
> c:\windows\xwin.ini . It's a standard old format text INI file with the
> [sections] being the class and identifiers=c:\file.ico being the keys.
> If a res_name isn't matched, it uses the _default key for the icon. If
> the res_class isn't matched, the default X icon is used...
> Ex:
> [XLoad]
> _default=z:\tmp\xload.ico
>
> [Fig]
> _default=z:\tmp\xfig.ico
> file_popup=z:\tmp\file.ico
>
> Note you need Windoze paths since I call the API LoadImage() to get the ICO
> into a handle. Use "xprop" to get the res_name and res_class of a window.
>
> Feel free to use this as a base to add a nicer UI and maybe use XPMs and other
image formats instead of plain Windoze .icos...
At first I've added my patch for accessing icons files directly by filename.
$ diff -ubB winmultiwindowwindow.c.orig winmultiwindowwindow.c
--- winmultiwindowwindow.c.orig 2003-05-19 21:10:18.000000000 +0200
+++ winmultiwindowwindow.c 2003-05-19 21:12:12.000000000 +0200
@@ -1399,6 +1399,10 @@
GetPrivateProfileString( res_class, res_name, "", fname, MAX_PATH,
"XWin.ini");
if (!fname[0]) /* Try the default icon instead */
GetPrivateProfileString( res_class, "_default", "", fname, MAX_PATH,
"XWin.ini");
+ if (!fname[0]) { /* at last try for an icon file located into a PATH var
located directory */
+ strcpy(fname,res_name);
+ strcat(fname,".ico");
+ }
if (fname[0]) {
HANDLE hIconFile;
/* Have a .ico filename, let's try and load it */
Ralf