mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 23:05:59 +01:00
Add cache directory
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
f4b7bd0ce8
commit
bbe174ac08
3 changed files with 27 additions and 0 deletions
3
main.c
3
main.c
|
@ -41,6 +41,7 @@ main(int argc, char* argv[])
|
||||||
/* parse command line arguments */
|
/* parse command line arguments */
|
||||||
gchar* config_dir = NULL;
|
gchar* config_dir = NULL;
|
||||||
gchar* data_dir = NULL;
|
gchar* data_dir = NULL;
|
||||||
|
gchar* cache_dir = NULL;
|
||||||
gchar* plugin_path = NULL;
|
gchar* plugin_path = NULL;
|
||||||
gchar* loglevel = NULL;
|
gchar* loglevel = NULL;
|
||||||
gchar* password = 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" },
|
{ "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" },
|
{ "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" },
|
{ "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" },
|
{ "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 },
|
{ "fork", '\0', 0, G_OPTION_ARG_NONE, &forkback, _("Fork into the background"), NULL },
|
||||||
{ "password", 'w', 0, G_OPTION_ARG_STRING, &password, _("Document password"), "password" },
|
{ "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_xid(zathura, embed);
|
||||||
zathura_set_config_dir(zathura, config_dir);
|
zathura_set_config_dir(zathura, config_dir);
|
||||||
zathura_set_data_dir(zathura, data_dir);
|
zathura_set_data_dir(zathura, data_dir);
|
||||||
|
zathura_set_cache_dir(zathura, cache_dir);
|
||||||
zathura_set_plugin_dir(zathura, plugin_path);
|
zathura_set_plugin_dir(zathura, plugin_path);
|
||||||
zathura_set_argv(zathura, argv);
|
zathura_set_argv(zathura, argv);
|
||||||
|
|
||||||
|
|
15
zathura.c
15
zathura.c
|
@ -348,6 +348,7 @@ zathura_free(zathura_t* zathura)
|
||||||
/* free config variables */
|
/* free config variables */
|
||||||
g_free(zathura->config.config_dir);
|
g_free(zathura->config.config_dir);
|
||||||
g_free(zathura->config.data_dir);
|
g_free(zathura->config.data_dir);
|
||||||
|
g_free(zathura->config.cache_dir);
|
||||||
|
|
||||||
/* free jumplist */
|
/* free jumplist */
|
||||||
if (zathura->jumplist.list != NULL) {
|
if (zathura->jumplist.list != NULL) {
|
||||||
|
@ -386,6 +387,8 @@ zathura_set_config_dir(zathura_t* zathura, const char* dir)
|
||||||
void
|
void
|
||||||
zathura_set_data_dir(zathura_t* zathura, const char* dir)
|
zathura_set_data_dir(zathura_t* zathura, const char* dir)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail(zathura != NULL);
|
||||||
|
|
||||||
if (dir != NULL) {
|
if (dir != NULL) {
|
||||||
zathura->config.data_dir = g_strdup(dir);
|
zathura->config.data_dir = g_strdup(dir);
|
||||||
} else {
|
} 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);
|
zathura->config.data_dir = g_build_filename(path, "zathura", NULL);
|
||||||
g_free(path);
|
g_free(path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
zathura_set_cache_dir(zathura_t* zathura, const char* dir)
|
||||||
|
{
|
||||||
g_return_if_fail(zathura != NULL);
|
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
|
void
|
||||||
|
|
|
@ -127,6 +127,7 @@ struct zathura_s
|
||||||
{
|
{
|
||||||
gchar* config_dir; /**< Path to the configuration directory */
|
gchar* config_dir; /**< Path to the configuration directory */
|
||||||
gchar* data_dir; /**< Path to the data directory */
|
gchar* data_dir; /**< Path to the data directory */
|
||||||
|
gchar* cache_dir; /**< Path to the cache directory */
|
||||||
} config;
|
} config;
|
||||||
|
|
||||||
struct
|
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);
|
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
|
* Set the path to the plugin directory
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue