diff options
author | Matthias Clasen <mclasen@redhat.com> | 2005-08-23 15:18:08 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2005-08-23 15:18:08 +0000 |
commit | 9dbd953842f0fdc194e24894b224dffbe8d60319 (patch) | |
tree | ef5f8f314c91948f5c56e864f7671466e435df55 /gtk/updateiconcache.c | |
parent | d0ef4dec8156e0eae6ef9370ff78ebdc03670d65 (diff) | |
download | gdk-pixbuf-9dbd953842f0fdc194e24894b224dffbe8d60319.tar.gz |
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.
Diffstat (limited to 'gtk/updateiconcache.c')
-rw-r--r-- | gtk/updateiconcache.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/gtk/updateiconcache.c b/gtk/updateiconcache.c index 9f5fd56b8..2da6d0033 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; |