diff --git a/ChangeLog b/ChangeLog index f932582284..929e92f4ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2005-08-23 Matthias Clasen + * 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 C99ism. (#314262, Robert Jeff Mitchell) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f932582284..929e92f4ba 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,9 @@ 2005-08-23 Matthias Clasen + * 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 C99ism. (#314262, Robert Jeff Mitchell) diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f932582284..929e92f4ba 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,9 @@ 2005-08-23 Matthias Clasen + * 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 C99ism. (#314262, Robert Jeff Mitchell) diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 5b47fccb39..68916bb88d 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,8 @@ +2005-08-23 Matthias Clasen + + * gtk/gtk-update-icon-cache.xml: + * gtk/gtk-update-icon-cache.1: Updates. + 2005-08-16 Matthias Clasen * gtk/tmpl/gtktreemodel.sgml: Fix an diff --git a/docs/reference/gtk/gtk-update-icon-cache.1 b/docs/reference/gtk/gtk-update-icon-cache.1 index c9c2ca03b8..8f8707eab0 100644 --- a/docs/reference/gtk/gtk-update-icon-cache.1 +++ b/docs/reference/gtk/gtk-update-icon-cache.1 @@ -1,56 +1,41 @@ -.\"Generated by db2man.xsl. Don't modify this, modify the source. -.de Sh \" Subsection -.br -.if t .Sp -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.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" +.\" ** You probably do not want to edit this file directly ** +.\" It was generated using the DocBook XSL Stylesheets (version 1.69.1). +.\" Instead of manually editing it, you probably should edit the DocBook XML +.\" source for it and then use the DocBook XSL Stylesheets to regenerate it. +.TH "GTK\-UPDATE\-ICON\-CACH" "1" "08/23/2005" "" "" +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) .ad l -.hy 0 +.SH "NAME" +gtk\-update\-icon\-cache \- Icon theme caching utility +.SH "SYNOPSIS" .HP 22 -\fBgtk\-update\-icon\-cache\fR [\-\-force] [\-\-quiet] {iconpath} -.ad -.hy - +\fBgtk\-update\-icon\-cache\fR [\-\-force] [\-\-index\-only] [\-\-quiet] {iconpath} .SH "DESCRIPTION" - .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 -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 -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" - .TP \-\-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 \-\-quiet, \-q -Turn off verbose output\&. - +Turn off verbose output. .SH "BUGS" - .PP -None known yet\&. - +None known yet. diff --git a/docs/reference/gtk/gtk-update-icon-cache.xml b/docs/reference/gtk/gtk-update-icon-cache.xml index 40a847f4c7..4c2afa4e01 100644 --- a/docs/reference/gtk/gtk-update-icon-cache.xml +++ b/docs/reference/gtk/gtk-update-icon-cache.xml @@ -14,20 +14,20 @@ gtk-update-icon-cache --force +--index-only --quiet iconpath Description - -gtk-update-icon-cache creates mmap()able cache files for +gtk-update-icon-cache creates mmap()able cache files for icon themes. -If expects to be given the path to a icon theme directory, e.g. -/usr/share/icons/hicolor, and writes a -icon-theme.cache containing cached information +If expects to be given the path to a icon theme directory containing an +index.theme, e.g. /usr/share/icons/hicolor, +and writes a icon-theme.cache containing cached information about the icons in the directory tree below the given directory. @@ -46,6 +46,14 @@ multiple applications, the overall memory consumption is reduced as well. Overwrite an existing cache file even if it appears to be uptodate. + + + --index-only + -i + Don't include image data in the cache. + + + --quiet -q diff --git a/gtk/updateiconcache.c b/gtk/updateiconcache.c index 9f5fd56b86..2da6d00330 100644 --- a/gtk/updateiconcache.c +++ b/gtk/updateiconcache.c @@ -40,6 +40,7 @@ static gboolean force_update = FALSE; static gboolean quiet = FALSE; +static gboolean index_only = FALSE; #define CACHE_NAME "icon-theme.cache" @@ -48,7 +49,7 @@ static gboolean quiet = FALSE; #define HAS_SUFFIX_PNG (1 << 2) #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 MINOR_VERSION 0 @@ -87,6 +88,22 @@ is_cache_up_to_date (const gchar *path) 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 { gboolean has_pixdata; @@ -1191,6 +1208,7 @@ build_cache (const gchar *path) static GOptionEntry args[] = { { "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 }, { NULL } }; @@ -1214,6 +1232,13 @@ main (int argc, char **argv) path = g_locale_to_utf8 (path, -1, NULL, NULL, NULL); #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)) return 0;