Commit 9dbd9538 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Complain when there is no index.theme file in the specified directory,

2005-08-23  Matthias Clasen  <mclasen@redhat.com>

	* gtk/updateiconcache.c: Complain when there is no index.theme file
	in the specified directory, unless --force is used. Also add an
	--index-only option to create caches without image data.
parent d0ef4dec
2005-08-23 Matthias Clasen <mclasen@redhat.com> 2005-08-23 Matthias Clasen <mclasen@redhat.com>
* gtk/updateiconcache.c: Complain when there is no index.theme file
in the specified directory, unless --force is used. Also add an
--index-only option to create caches without image data.
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Fix a * gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Fix a
C99ism. (#314262, Robert Jeff Mitchell) C99ism. (#314262, Robert Jeff Mitchell)
......
2005-08-23 Matthias Clasen <mclasen@redhat.com> 2005-08-23 Matthias Clasen <mclasen@redhat.com>
* gtk/updateiconcache.c: Complain when there is no index.theme file
in the specified directory, unless --force is used. Also add an
--index-only option to create caches without image data.
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Fix a * gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Fix a
C99ism. (#314262, Robert Jeff Mitchell) C99ism. (#314262, Robert Jeff Mitchell)
......
2005-08-23 Matthias Clasen <mclasen@redhat.com> 2005-08-23 Matthias Clasen <mclasen@redhat.com>
* gtk/updateiconcache.c: Complain when there is no index.theme file
in the specified directory, unless --force is used. Also add an
--index-only option to create caches without image data.
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Fix a * gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Fix a
C99ism. (#314262, Robert Jeff Mitchell) C99ism. (#314262, Robert Jeff Mitchell)
......
2005-08-23 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk-update-icon-cache.xml:
* gtk/gtk-update-icon-cache.1: Updates.
2005-08-16 Matthias Clasen <mclasen@redhat.com> 2005-08-16 Matthias Clasen <mclasen@redhat.com>
* gtk/tmpl/gtktreemodel.sgml: Fix an * gtk/tmpl/gtktreemodel.sgml: Fix an
......
.\"Generated by db2man.xsl. Don't modify this, modify the source. .\" ** You probably do not want to edit this file directly **
.de Sh \" Subsection .\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
.br .\" Instead of manually editing it, you probably should edit the DocBook XML
.if t .Sp .\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
.ne 5 .TH "GTK\-UPDATE\-ICON\-CACH" "1" "08/23/2005" "" ""
.PP .\" disable hyphenation
\fB\\$1\fR .nh
.PP .\" disable justification (adjust text to left margin only)
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Ip \" List item
.br
.ie \\n(.$>=3 .ne \\$3
.el .ne 3
.IP "\\$1" \\$2
..
.TH "GTK-UPDATE-ICON-CA" 1 "" "" ""
.SH NAME
gtk-update-icon-cache \- Icon theme caching utility
.SH "SYNOPSIS"
.ad l .ad l
.hy 0 .SH "NAME"
gtk\-update\-icon\-cache \- Icon theme caching utility
.SH "SYNOPSIS"
.HP 22 .HP 22
\fBgtk\-update\-icon\-cache\fR [\-\-force] [\-\-quiet] {iconpath} \fBgtk\-update\-icon\-cache\fR [\-\-force] [\-\-index\-only] [\-\-quiet] {iconpath}
.ad
.hy
.SH "DESCRIPTION" .SH "DESCRIPTION"
.PP .PP
\fBgtk\-update\-icon\-cache\fR creates mmap()able cache files for icon themes\&. \fBgtk\-update\-icon\-cache\fR
creates mmap()able cache files for icon themes.
.PP .PP
If expects to be given the path to a icon theme directory, e\&.g\&. \fI/usr/share/icons/hicolor\fR, and writes a \fIicon\-theme\&.cache\fR containing cached information about the icons in the directory tree below the given directory\&. If expects to be given the path to a icon theme directory containing an
\fIindex.theme\fR, e.g.
\fI/usr/share/icons/hicolor\fR, and writes a
\fIicon\-theme.cache\fR
containing cached information about the icons in the directory tree below the given directory.
.PP .PP
GTK+ can use the cache files created by \fBgtk\-update\-icon\-cache\fR to avoid a lot of system call and disk seek overhead when the application starts\&. Since the format of the cache files allows them to be mmap()ed shared between multiple applications, the overall memory consumption is reduced as well\&. GTK+ can use the cache files created by
\fBgtk\-update\-icon\-cache\fR
to avoid a lot of system call and disk seek overhead when the application starts. Since the format of the cache files allows them to be mmap()ed shared between multiple applications, the overall memory consumption is reduced as well.
.SH "OPTIONS" .SH "OPTIONS"
.TP .TP
\-\-force, \-f \-\-force, \-f
Overwrite an existing cache file even if it appears to be uptodate\&. Overwrite an existing cache file even if it appears to be uptodate.
.TP
\-\-index\-only, \-i
Don't include image data in the cache.
.TP .TP
\-\-quiet, \-q \-\-quiet, \-q
Turn off verbose output\&. Turn off verbose output.
.SH "BUGS" .SH "BUGS"
.PP .PP
None known yet\&. None known yet.
...@@ -14,20 +14,20 @@ ...@@ -14,20 +14,20 @@
<cmdsynopsis> <cmdsynopsis>
<command>gtk-update-icon-cache</command> <command>gtk-update-icon-cache</command>
<arg choice="opt">--force</arg> <arg choice="opt">--force</arg>
<arg choice="opt">--index-only</arg>
<arg choice="opt">--quiet</arg> <arg choice="opt">--quiet</arg>
<arg choice="req">iconpath</arg> <arg choice="req">iconpath</arg>
</cmdsynopsis> </cmdsynopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1><title>Description</title> <refsect1><title>Description</title>
<para> <para><command>gtk-update-icon-cache</command> creates mmap()able cache files for
<command>gtk-update-icon-cache</command> creates mmap()able cache files for
icon themes. icon themes.
</para> </para>
<para> <para>
If expects to be given the path to a icon theme directory, e.g. If expects to be given the path to a icon theme directory containing an
<filename>/usr/share/icons/hicolor</filename>, and writes a <filename>index.theme</filename>, e.g. <filename>/usr/share/icons/hicolor</filename>,
<filename>icon-theme.cache</filename> containing cached information and writes a <filename>icon-theme.cache</filename> containing cached information
about the icons in the directory tree below the given directory. about the icons in the directory tree below the given directory.
</para> </para>
<para> <para>
...@@ -46,6 +46,14 @@ multiple applications, the overall memory consumption is reduced as well. ...@@ -46,6 +46,14 @@ multiple applications, the overall memory consumption is reduced as well.
<listitem><para>Overwrite an existing cache file even if it appears to be uptodate. <listitem><para>Overwrite an existing cache file even if it appears to be uptodate.
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>--index-only</term>
<term>-i</term>
<listitem><para>Don't include image data in the cache.
</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>--quiet</term> <term>--quiet</term>
<term>-q</term> <term>-q</term>
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
static gboolean force_update = FALSE; static gboolean force_update = FALSE;
static gboolean quiet = FALSE; static gboolean quiet = FALSE;
static gboolean index_only = FALSE;
#define CACHE_NAME "icon-theme.cache" #define CACHE_NAME "icon-theme.cache"
...@@ -48,7 +49,7 @@ static gboolean quiet = FALSE; ...@@ -48,7 +49,7 @@ static gboolean quiet = FALSE;
#define HAS_SUFFIX_PNG (1 << 2) #define HAS_SUFFIX_PNG (1 << 2)
#define HAS_ICON_FILE (1 << 3) #define HAS_ICON_FILE (1 << 3)
#define CAN_CACHE_IMAGE_DATA(flags) (((flags) & HAS_SUFFIX_PNG) || ((flags) & HAS_SUFFIX_XPM)) #define CAN_CACHE_IMAGE_DATA(flags) (!index_only && (((flags) & HAS_SUFFIX_PNG) || ((flags) & HAS_SUFFIX_XPM)))
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
...@@ -87,6 +88,22 @@ is_cache_up_to_date (const gchar *path) ...@@ -87,6 +88,22 @@ is_cache_up_to_date (const gchar *path)
return cache_stat.st_mtime >= path_stat.st_mtime; return cache_stat.st_mtime >= path_stat.st_mtime;
} }
gboolean
has_theme_index (const gchar *path)
{
gboolean result;
gchar *index_path;
index_path = g_build_filename (path, "index.theme", NULL);
result = g_file_test (index_path, G_FILE_TEST_IS_REGULAR);
g_free (index_path);
return result;
}
typedef struct typedef struct
{ {
gboolean has_pixdata; gboolean has_pixdata;
...@@ -1191,6 +1208,7 @@ build_cache (const gchar *path) ...@@ -1191,6 +1208,7 @@ build_cache (const gchar *path)
static GOptionEntry args[] = { static GOptionEntry args[] = {
{ "force", 'f', 0, G_OPTION_ARG_NONE, &force_update, "Overwrite an existing cache, even if uptodate", NULL }, { "force", 'f', 0, G_OPTION_ARG_NONE, &force_update, "Overwrite an existing cache, even if uptodate", NULL },
{ "index-only", 'i', 0, G_OPTION_ARG_NONE, &index_only, "Don't include image data in the cache", NULL },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Turn off verbose output", NULL }, { "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Turn off verbose output", NULL },
{ NULL } { NULL }
}; };
...@@ -1214,6 +1232,13 @@ main (int argc, char **argv) ...@@ -1214,6 +1232,13 @@ main (int argc, char **argv)
path = g_locale_to_utf8 (path, -1, NULL, NULL, NULL); path = g_locale_to_utf8 (path, -1, NULL, NULL, NULL);
#endif #endif
if (!force_update && !has_theme_index (path))
{
g_printerr ("No theme index file in '%s'.\n"
"If you really want to create an icon cache here, use --force.\n", path);
return 1;
}
if (!force_update && is_cache_up_to_date (path)) if (!force_update && is_cache_up_to_date (path))
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment