From Fedora Project Wiki

(Work on icon cache)
 
(New icon cache guideline proposed by ville)
Line 1: Line 1:
Curent icon cache:
== Icon Cache ==
 
== GTK+ icon cache ==


If an application installs icons into one of the subdirectories in <code>%{_datadir}/icons/</code> (such as <code>hicolor</code> in the following examples), <code>gtk-update-icon-cache</code> should be run after the package is installed/uninstalled on FC4 and later. This is required so that the installed icons show up in GNOME menus right after package installation, and speeds up GTK+ applications' access to the icons. For KDE, just 'touch'ing the top-level icon directory is enough.
If an application installs icons into one of the subdirectories in <code>%{_datadir}/icons/</code> (such as <code>hicolor</code> in the following examples), <code>gtk-update-icon-cache</code> should be run after the package is installed/uninstalled on FC4 and later. This is required so that the installed icons show up in GNOME menus right after package installation, and speeds up GTK+ applications' access to the icons. For KDE, just 'touch'ing the top-level icon directory is enough.
Line 9: Line 7:
<pre>
<pre>
%post
%post
touch --no-create %{_datadir}/icons/hicolor
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
if [ -x %{_bindir}/gtk-update-icon-cache ] ; then
  %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
fi


%postun
%postun
touch --no-create %{_datadir}/icons/hicolor
if [ $1 -eq 0 ] ; then
if [ -x %{_bindir}/gtk-update-icon-cache ] ; then
    touch --no-create %{_datadir}/icons/hicolor &>/dev/null
  %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
    gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi
fi
%posttrans
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
</pre>
</pre>

Revision as of 22:16, 13 February 2009

Icon Cache

If an application installs icons into one of the subdirectories in %{_datadir}/icons/ (such as hicolor in the following examples), gtk-update-icon-cache should be run after the package is installed/uninstalled on FC4 and later. This is required so that the installed icons show up in GNOME menus right after package installation, and speeds up GTK+ applications' access to the icons. For KDE, just 'touch'ing the top-level icon directory is enough.

Note that no dependencies should be added for this. If gtk-update-icon-cache is not available, there's nothing that would be needing the cache update. Not adding the dependency on gtk-update-icon-cache (ie. gtk2 >= 2.6.0) makes it easier to use the package (or the same specfile) on systems where it's not available nor needed, such as older distro versions or (very) trimmed down installations.

%post
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

%postun
if [ $1 -eq 0 ] ; then
    touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi

%posttrans
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :