[libvirt] [PATCH] Add a Windows icon resource to virsh.exe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a Windows resource icon to virsh.exe (on Windows only,
obviously).

I've generated 16x16, 32x32, 48x48 and 64x64 MS .ico files, starting
from Diana Fong / Tim Allen's libvirtLogo.png in the docs directory,
scaling it down to the required size, and adding an alpha mask.

The *.ico files have to go into the src directory, because of
limitations of the Microsoft resource editor file format itself.  I
propose to add the 64x64 PNG file into the docs directory, or perhaps
not bother adding it at all -- it's not actually used and can be quite
trivially recreated.

My graphical attempts are fairly lame.  This is partly because these
icons really need to be tweaked by hand for legibility at small sizes,
and partly because Windows itself does some quantization on the .ico
files after loading them.  This quantization I don't understand and
isn't documented anywhere.  Nevertheless the icon looks not totally
unreasonable, as you can see from the final screenshot attached.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
Read my OCaml programming blog: http://camltastic.blogspot.com/
Fedora now supports 68 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
? docs/libvirt_win_icon_64x64.png
? src/libvirt_win_icon_16x16.ico
? src/libvirt_win_icon_32x32.ico
? src/libvirt_win_icon_48x48.ico
? src/libvirt_win_icon_64x64.ico
Index: configure.in
===================================================================
RCS file: /data/cvs/libvirt/configure.in,v
retrieving revision 1.171
diff -u -r1.171 configure.in
--- configure.in	10 Oct 2008 13:57:13 -0000	1.171
+++ configure.in	15 Oct 2008 16:29:24 -0000
@@ -34,6 +34,8 @@
 AC_PROG_INSTALL
 AC_PROG_CPP
 
+AC_OBJEXT
+
 dnl gl_INIT uses m4_foreach_w, yet that is not defined in autoconf-2.59.
 dnl In order to accommodate developers with such old tools, here's a
 dnl replacement definition.
@@ -1040,6 +1042,10 @@
 AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
 AC_SUBST([MINGW_EXTRA_LDFLAGS])
 
+dnl Look for windres to build a Windows icon resource.
+AC_CHECK_TOOL([WINDRES], [windres], [no])
+AM_CONDITIONAL([WITH_WIN_ICON], [test "$WINDRES" != "no"])
+
 # Set LV_LIBTOOL_OBJDIR to "." or $lt_cv_objdir, depending on whether
 # we're building shared libraries.  This is the name of the directory
 # in which .o files will be created.
Index: src/Makefile.am
===================================================================
RCS file: /data/cvs/libvirt/src/Makefile.am,v
retrieving revision 1.95
diff -u -r1.95 Makefile.am
--- src/Makefile.am	10 Oct 2008 13:57:13 -0000	1.95
+++ src/Makefile.am	15 Oct 2008 16:29:24 -0000
@@ -283,6 +283,33 @@
 	rm -f $@
 	mv $@-tmp $@
 
+if WITH_WIN_ICON
+virsh_LDADD += virsh_win_icon.$(OBJEXT)
+virsh_DEPENDENCIES += virsh_win_icon.$(OBJEXT)
+
+# Before you edit virsh_win_icon.rc, please note the following
+# limitations of the resource file format:
+#
+# (1) '..' is not permitted in the icon filename field.
+# (2) '-' is not permitted in the icon filename field.
+# (3) Comments are not permitted in the file.
+#
+# Windows appears to choose the first <= 32x32 icon it finds
+# in the resource file.  Therefore you should list the available
+# icons from largest to smallest, and make sure that the 32x32
+# icon is the most legible.
+#
+# Windows .ICO is a special MS-only format.  GIMP and other
+# tools can write it.  However there are several variations,
+# and Windows seems to do its own colour quantization.  More
+# information is needed in this area.
+
+virsh_win_icon.$(OBJEXT): virsh_win_icon.rc
+	$(WINDRES) \
+	  --input-format rc --input $< \
+	  --output-format coff --output $@
+endif
+
 libexec_PROGRAMS =
 
 if WITH_STORAGE_DISK
Index: src/virsh_win_icon.rc
===================================================================
RCS file: src/virsh_win_icon.rc
diff -N src/virsh_win_icon.rc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/virsh_win_icon.rc	15 Oct 2008 16:29:24 -0000
@@ -0,0 +1,4 @@
+xlarge  ICON    libvirt_win_icon_64x64.ico
+large   ICON    libvirt_win_icon_48x48.ico
+medium  ICON    libvirt_win_icon_32x32.ico
+small   ICON    libvirt_win_icon_16x16.ico

Attachment: libvirt_win_icon_64x64.png
Description: PNG image

Attachment: libvirt_win_icon_64x64.ico
Description: image/vnd.microsoft.icon

Attachment: libvirt_win_icon_48x48.ico
Description: image/vnd.microsoft.icon

Attachment: libvirt_win_icon_32x32.ico
Description: image/vnd.microsoft.icon

Attachment: libvirt_win_icon_16x16.ico
Description: image/vnd.microsoft.icon

Attachment: screenshot.png
Description: PNG image

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]