Sunday, July 13, 2008

Awn Icons

moonbeam has been working on a new feature in Awn called awn-icons, which allows users to drag an icon onto the applet itself and change the icon. The user can choose from the applet instance, the applet, or the type of icon for applying. So, if a user drags a new icon onto File Browser Launcher and chooses icon type, all of the applets that use the 'folder' icon will change. (AFAIK, this would require a restart of Awn/ the applets.)
This enables users to change icons for applets that they couldn't before, such as the media icons and MiMenu. Use Ubuntu but want the translucent GNOME logo on MiMenu? Just drag and drop it on MiMenu. Got some nice back, play, and forward icons? Just drag them on to the media icons applets.

Applets that have been converted (note: I'll try my best to keep this updated):
*Affinity
*aRSS
*AWNLib (not an applet, but still)
*Awn Notification Daemon
*Awn Terminal
*Cairo Menu
*Cairo Menu Classic
*Comic
*Comics
*File Browser Launcher
*Main Menu
*Media Control
*Media Icons
*MiMenu
*Mount Applet
*Mobile Meebo
*Pandora
*Places
*Quit Applet
*RTM
*Run (not in Awn Extras)
*Show Desktop
*Tomboy Applet
*TsClient
*Web Applet
IIRC, every applet that should use Awn Icons does. (!)

Several applets distribute icons that aren't found in a normal theme and use them as their icons. One example is the Quit Applet. You have to modify Makefiles to place the icons in the appropriate directory. I'll show the Quit Applet's [Make]files.

src/quit-applet
Makefile.am
quit-applet.py
quit-applet.desktop.in.in
icons/
Makefile.am
application-exit.svg

src/quit-applet/Makefile.am:

SUBDIRS = icons
APPLET_NAME = quit-applet
APPLET_MAIN_FILE = quit-applet.py
include $(top_srcdir)/Makefile.python-applet
dist_applet_DATA = \
COPYING \
$(NULL)

src/quit-applet/quit-applet.desktop.in.in:

[Desktop Entry]
Version=1.0
Name=Quit-Logoff applet
Type=Application
X-AWN-AppletType=Python
Comment=A applet to exit your session
Exec=quit-applet/quit-applet.py
Icon=quit-applet/icons/scalable/apps/application-exit.svg
Name[en_US]=Quit-Logoff applet
X-AWN-AppletCategory=System

src/quit-applet/icons/Makefile.am:

dist_quitapplet_DATA = \
application-exit.svg \
COPYING \
LGPL

quitappletdir = ${prefix}/share/avant-window-navigator/applets/quit-applet/icons/scalable/apps/

You must place the icon[s] in a separate directory named "icons," otherwise this won't work. Note that you can actually omit the instances of "scalable/apps," which would be better if you have only one icon. Also, if your icon is not an SVG image, either change "scalable" or just omit that part.

Now all the quit applet has to do to get the icon is this:
self.set_awn_icon('quit-applet', 'application-exit')

If an applet needs the icon as a Pixbuf, such as for preferences dialogs, etc., the set_awn_icon method returns the Pixbuf. It's owned by awn-icons, so you would want to use the awn-icons API directly, which currently doesn't have Python bindings.


Note: If you are using this as a tutorial for converting these applets and you need anything clarified, etc., just tell me. :)

No comments: