/*
* (SLIK) SimpLIstic sKin functions
* (C) 2006 John Ellis
- * Copyright (C) 2008 - 2010 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
*
* Author: John Ellis
*
g_free(text_l);
}
-static void encoding_dialog(const gchar *path);
-
-static gboolean encoding_dialog_idle(gpointer data)
-{
- gchar *path = data;
-
- encoding_dialog(path);
- g_free(path);
-
- return FALSE;
-}
-
-static gint encoding_dialog_delay(gpointer data)
-{
- g_idle_add(encoding_dialog_idle, data);
-
- return 0;
-}
-
static void encoding_dialog(const gchar *path)
{
static gboolean warned_user = FALSE;
const gchar *lc;
const gchar *bf;
- /* check that gtk is initialized (loop is level > 0) */
- if (gtk_main_level() == 0)
- {
- /* gtk not initialized */
- gtk_init_add(encoding_dialog_delay, g_strdup(path));
- return;
- }
-
if (warned_user) return;
warned_user = TRUE;
name = g_convert(path, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
string = g_string_append(string, _("\nPreferred encoding appears to be UTF-8, however the file:\n"));
g_string_append_printf(string, "\"%s\"\n", (name) ? name : _("[name not displayable]"));
-
+
if (g_utf8_validate(path, -1, NULL))
g_string_append_printf(string, _("\"%s\" is encoded in valid UTF-8."), (name) ? name : _("[name not displayable]"));
else
if (!home)
home = path_to_utf8(getenv("HOME"));
-
+
if (!home)
home = path_to_utf8(g_get_home_dir());
{
return g_build_filename(homedir(), fallback, NULL);
}
-
+
return path_to_utf8(dir);
}
static const gchar *xdg_data_home = NULL;
if (xdg_data_home) return xdg_data_home;
-
+
xdg_data_home = xdg_dir_get("XDG_DATA_HOME", ".local/share");
return xdg_data_home;
static const gchar *xdg_config_home = NULL;
if (xdg_config_home) return xdg_config_home;
-
+
xdg_config_home = xdg_dir_get("XDG_CONFIG_HOME", ".config");
return xdg_config_home;
static const gchar *xdg_cache_home = NULL;
if (xdg_cache_home) return xdg_cache_home;
-
+
xdg_cache_home = xdg_dir_get("XDG_CACHE_HOME", ".cache");
return xdg_cache_home;
const gchar *get_rc_dir(void)
{
static gchar *rc_dir = NULL;
-
+
if (rc_dir) return rc_dir;
if (USE_XDG)
static gchar *trash_dir = NULL;
if (trash_dir) return trash_dir;
-
+
if (USE_XDG)
{
trash_dir = g_build_filename(xdg_data_home_get(), GQ_APPNAME_LC, GQ_TRASH_DIR, NULL);
fi = fopen(sl, "rb");
if (!fi) goto end;
-
+
/* First we write to a temporary file, then we rename it on success,
and attributes from original file are copied */
randname = g_strconcat(tl, ".tmp_XXXXXX", NULL);
if (!randname) goto end;
-
+
fd = g_mkstemp(randname);
if (fd == -1) goto end;
-
+
fo = fdopen(fd, "wb");
if (!fo) {
close(fd);
if (rename(randname, tl) < 0) {
unlink(randname);
- goto end;
+ goto end;
}
ret = copy_file_attributes(s, t, TRUE, TRUE);
continue;
}
}
-
+
if (s != t) path[t] = path[s];
t++;
s++;
p[0] = '\0';
end = FALSE;
}
-
+
if (!isdir(npath))
{
DEBUG_1("creating sub dir:%s", npath);
return FALSE;
}
}
-
+
if (!end) p[0] = G_DIR_SEPARATOR;
}
}