From Fedora Project Wiki

(New icon cache guideline proposed by ville)
m (PackagingDrafts/Icon Cache moved to Archive:PackagingDrafts/Icon Cache: Draft accepted nad written into Guidelines)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Icon Cache ==
== 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), icon caches must be updated so that the installed icons show up in menus right after package installation.  This consists of updating the timestamp of the top-level icon directory where the icons were installed, and running <code>gtk-update-icon-cache</code>. 'touch'ing the top-level dir is done so that environments compatible with the [http://standards.freedesktop.org/icon-theme-spec/latest/ar01s08.html Icon theme specification] can refresh their caches, and <code>gtk-update-icon-cache</code> which is additionally required for GNOME also does its work based on the dir timestamp.


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.
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, ditto if "touch" is not available, there's nothing that would benefit from icon cache updates installed yet either. Not adding the dependency on gtk-update-icon-cache (ie. gtk2 >= 2.6.0) or "touch" 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, and generally results in less entries in specfiles, rpmdb, and repo metadatas.


<pre>
<pre>
Line 18: Line 18:
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
</pre>
</pre>
[[Category:Archived_packaging_guideline_drafts]]

Latest revision as of 00:34, 11 March 2009

Icon Cache

If an application installs icons into one of the subdirectories in %{_datadir}/icons/ (such as hicolor in the following examples), icon caches must be updated so that the installed icons show up in menus right after package installation. This consists of updating the timestamp of the top-level icon directory where the icons were installed, and running gtk-update-icon-cache. 'touch'ing the top-level dir is done so that environments compatible with the Icon theme specification can refresh their caches, and gtk-update-icon-cache which is additionally required for GNOME also does its work based on the dir timestamp.

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, ditto if "touch" is not available, there's nothing that would benefit from icon cache updates installed yet either. Not adding the dependency on gtk-update-icon-cache (ie. gtk2 >= 2.6.0) or "touch" 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, and generally results in less entries in specfiles, rpmdb, and repo metadatas.

%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 || :