#include <glib.h>
#include <glib/gstdio.h>
#include <gdk-pixbuf/gdk-pixdata.h>
+#include <glib/gi18n.h>
static gboolean force_update = FALSE;
static gboolean ignore_theme_index = FALSE;
#define ALIGN_VALUE(this, boundary) \
(( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
-gboolean
+static gboolean
is_cache_up_to_date (const gchar *path)
{
struct stat path_stat, cache_stat;
return cache_stat.st_mtime >= path_stat.st_mtime;
}
-gboolean
+static gboolean
has_theme_index (const gchar *path)
{
gboolean result;
idata2 = g_hash_table_lookup (image_data_hash, path2);
if (idata && idata2 && idata != idata2)
- g_error ("different idatas found for symlinked '%s' and '%s'\n",
+ g_error (_("different idatas found for symlinked '%s' and '%s'\n"),
path, path2);
if (idata && !idata2)
}
}
-GList *
+static GList *
scan_directory (const gchar *base_path,
const gchar *subdir,
GHashTable *files,
return TRUE;
}
-gboolean
+static gboolean
write_string (FILE *cache, const gchar *n)
{
gchar *s;
}
-gboolean
+static gboolean
write_card16 (FILE *cache, guint16 n)
{
int i;
return i == 1;
}
-gboolean
+static gboolean
write_card32 (FILE *cache, guint32 n)
{
int i;
}
-gboolean
+static gboolean
write_pixdata (FILE *cache, GdkPixdata *pixdata)
{
guint8 *s;
write_card32 (cache, dir_list_offset));
}
-guint
+static guint
get_image_meta_data_size (Image *image)
{
gint i;
return len;
}
-guint
+static guint
get_image_pixel_data_size (Image *image)
{
if (image->pixel_data_size == 0)
return image->pixel_data_size;
}
-guint
+static guint
get_image_data_size (Image *image)
{
guint len;
return len;
}
-guint
+static guint
get_single_node_size (HashNode *node, gboolean include_image_data)
{
int len = 0;
return len;
}
-guint
+static guint
get_bucket_size (HashNode *node)
{
int len = 0;
return len;
}
-gboolean
+static gboolean
write_bucket (FILE *cache, HashNode *node, int *offset)
{
while (node != NULL)
return TRUE;
}
-gboolean
+static gboolean
write_hash_table (FILE *cache, HashContext *context, int *new_offset)
{
int offset = HASH_OFFSET;
return TRUE;
}
-gboolean
+static gboolean
write_dir_index (FILE *cache, int offset, GList *directories)
{
int n_dirs;
return TRUE;
}
-gboolean
+static gboolean
write_file (FILE *cache, GHashTable *files, GList *directories)
{
HashContext context;
* back and change it later */
if (!write_header (cache, 0))
{
- g_printerr ("Failed to write header\n");
+ g_printerr (_("Failed to write header\n"));
return FALSE;
}
if (!write_hash_table (cache, &context, &new_offset))
{
- g_printerr ("Failed to write hash table\n");
+ g_printerr (_("Failed to write hash table\n"));
return FALSE;
}
if (!write_dir_index (cache, new_offset, directories))
{
- g_printerr ("Failed to write directory index\n");
+ g_printerr (_("Failed to write directory index\n"));
return FALSE;
}
if (!write_header (cache, new_offset))
{
- g_printerr ("Failed to rewrite header\n");
+ g_printerr (_("Failed to rewrite header\n"));
return FALSE;
}
return TRUE;
}
-void
+static void
build_cache (const gchar *path)
{
gchar *cache_path, *tmp_cache_path;
if (!cache)
{
- g_printerr ("Failed to write cache file: %s\n", g_strerror (errno));
+ g_printerr (_("Failed to write cache file: %s\n"), g_strerror (errno));
exit (1);
}
g_unlink (bak_cache_path);
if (g_rename (cache_path, bak_cache_path) == -1)
{
- g_printerr ("Could not rename %s to %s: %s, removing %s then.\n",
+ g_printerr (_("Could not rename %s to %s: %s, removing %s then.\n"),
cache_path, bak_cache_path,
g_strerror (errno),
cache_path);
if (g_rename (tmp_cache_path, cache_path) == -1)
{
- g_printerr ("Could not rename %s to %s: %s\n",
+ g_printerr (_("Could not rename %s to %s: %s\n"),
tmp_cache_path, cache_path,
g_strerror (errno));
g_unlink (tmp_cache_path);
#ifdef G_OS_WIN32
if (bak_cache_path != NULL)
if (g_rename (bak_cache_path, cache_path) == -1)
- g_printerr ("Could not rename %s back to %s: %s.\n",
+ g_printerr (_("Could not rename %s back to %s: %s.\n"),
bak_cache_path, cache_path,
g_strerror (errno));
#endif
utime (path, &utime_buf);
if (!quiet)
- g_printerr ("Cache file created successfully.\n");
+ g_printerr (_("Cache file created successfully.\n"));
}
-void
+static void
write_csource (const gchar *path)
{
gchar *cache_path;
gchar *data;
- guint8 d;
gsize len;
- gint pos;
gint i;
cache_path = g_build_filename (path, CACHE_NAME, NULL);
g_printf ("#else\n");
g_printf ("static const guint8 %s[] = \n", var_name);
g_printf ("#endif\n");
- g_printf ("{ ""\n \"");
-
- pos = 3;
- for (i = 0; i < len; i++)
+
+ g_printf ("{\n");
+ for (i = 0; i < len - 1; i++)
{
- d = data[i];
- if (pos > 70)
- {
- g_printf ("\"\n \"");
- pos = 3;
- }
- if (d < 33 || d > 126 || d == '?')
- {
- g_printf ("\\%.3o", d);
- pos += 4;
- continue;
- }
- if (d == '\\')
- {
- g_printf ("\\\\");
- pos += 2;
- }
- else if (d == '"')
- {
- g_printf ("\\\"");
- pos += 2;
- }
- else
- {
- g_printf ("%c", d);
- pos += 1;
- }
+ if (i %12 == 0)
+ g_printf (" ");
+ g_printf ("0x%02x, ", (guint8)data[i]);
+ if (i % 12 == 11)
+ g_printf ("\n");
}
- g_printf ("\"};\n");
+
+ g_printf ("0x%02x\n};\n", (guint8)data[i]);
}
static GOptionEntry args[] = {
- { "force", 'f', 0, G_OPTION_ARG_NONE, &force_update, "Overwrite an existing cache, even if uptodate", NULL },
- { "ignore-theme-index", 't', 0, G_OPTION_ARG_NONE, &ignore_theme_index, "Don't check for the existence of index.theme", NULL },
- { "index-only", 'i', 0, G_OPTION_ARG_NONE, &index_only, "Don't include image data in the cache", NULL },
- { "source", 'c', 0, G_OPTION_ARG_STRING, &var_name, "Output a C header file", "NAME" },
- { "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Turn off verbose output", NULL },
+ { "force", 'f', 0, G_OPTION_ARG_NONE, &force_update, N_("Overwrite an existing cache, even if up to date"), NULL },
+ { "ignore-theme-index", 't', 0, G_OPTION_ARG_NONE, &ignore_theme_index, N_("Don't check for the existence of index.theme"), NULL },
+ { "index-only", 'i', 0, G_OPTION_ARG_NONE, &index_only, N_("Don't include image data in the cache"), NULL },
+ { "source", 'c', 0, G_OPTION_ARG_STRING, &var_name, N_("Output a C header file"), "NAME" },
+ { "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, N_("Turn off verbose output"), NULL },
{ NULL }
};
if (argc < 2)
return 0;
+
+ bindtextdomain (GETTEXT_PACKAGE, GTK_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
context = g_option_context_new ("ICONPATH");
- g_option_context_add_main_entries (context, args, NULL);
+ g_option_context_add_main_entries (context, args, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, NULL);
if (!ignore_theme_index && !has_theme_index (path))
{
- g_printerr ("No theme index file in '%s'.\n"
- "If you really want to create an icon cache here, use --ignore-theme-index.\n", path);
+ g_printerr (_("No theme index file in '%s'.\n"
+ "If you really want to create an icon cache here, use --ignore-theme-index.\n"), path);
return 1;
}