Commit bbe174ac authored by Sebastian Ramacher's avatar Sebastian Ramacher
Browse files

Add cache directory


Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent f4b7bd0c
......@@ -41,6 +41,7 @@ main(int argc, char* argv[])
/* parse command line arguments */
gchar* config_dir = NULL;
gchar* data_dir = NULL;
gchar* cache_dir = NULL;
gchar* plugin_path = NULL;
gchar* loglevel = NULL;
gchar* password = NULL;
......@@ -57,6 +58,7 @@ main(int argc, char* argv[])
{ "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, _("Reparents to window specified by xid"), "xid" },
{ "config-dir", 'c', 0, G_OPTION_ARG_FILENAME, &config_dir, _("Path to the config directory"), "path" },
{ "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, _("Path to the data directory"), "path" },
{ "cache-dir", '\0', 0, G_OPTION_ARG_FILENAME, &cache_dir, _("Path to the cache directory"), "path"},
{ "plugins-dir", 'p', 0, G_OPTION_ARG_STRING, &plugin_path, _("Path to the directories containing plugins"), "path" },
{ "fork", '\0', 0, G_OPTION_ARG_NONE, &forkback, _("Fork into the background"), NULL },
{ "password", 'w', 0, G_OPTION_ARG_STRING, &password, _("Document password"), "password" },
......@@ -156,6 +158,7 @@ main(int argc, char* argv[])
zathura_set_xid(zathura, embed);
zathura_set_config_dir(zathura, config_dir);
zathura_set_data_dir(zathura, data_dir);
zathura_set_cache_dir(zathura, cache_dir);
zathura_set_plugin_dir(zathura, plugin_path);
zathura_set_argv(zathura, argv);
......
......@@ -348,6 +348,7 @@ zathura_free(zathura_t* zathura)
/* free config variables */
g_free(zathura->config.config_dir);
g_free(zathura->config.data_dir);
g_free(zathura->config.cache_dir);
/* free jumplist */
if (zathura->jumplist.list != NULL) {
......@@ -386,6 +387,8 @@ zathura_set_config_dir(zathura_t* zathura, const char* dir)
void
zathura_set_data_dir(zathura_t* zathura, const char* dir)
{
g_return_if_fail(zathura != NULL);
if (dir != NULL) {
zathura->config.data_dir = g_strdup(dir);
} else {
......@@ -393,8 +396,20 @@ zathura_set_data_dir(zathura_t* zathura, const char* dir)
zathura->config.data_dir = g_build_filename(path, "zathura", NULL);
g_free(path);
}
}
void
zathura_set_cache_dir(zathura_t* zathura, const char* dir)
{
g_return_if_fail(zathura != NULL);
if (dir != NULL) {
zathura->config.cache_dir = g_strdup(dir);
} else {
gchar* path = girara_get_xdg_path(XDG_CACHE);
zathura->config.cache_dir = g_build_filename(path, "zathura", NULL);
g_free(path);
}
}
void
......
......@@ -127,6 +127,7 @@ struct zathura_s
{
gchar* config_dir; /**< Path to the configuration directory */
gchar* data_dir; /**< Path to the data directory */
gchar* cache_dir; /**< Path to the cache directory */
} config;
struct
......@@ -249,6 +250,14 @@ void zathura_set_config_dir(zathura_t* zathura, const char* dir);
*/
void zathura_set_data_dir(zathura_t* zathura, const char* dir);
/**
* Set the path to the cache directory.
*
* @param zathura The Zathura session
* @param dir Directory path
*/
void zathura_set_cache_dir(zathura_t* zathura, const char* dir);
/**
* Set the path to the plugin directory
*
......
Supports Markdown
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