Commit 68b665a4 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Move config file loading to config.c

parent 43500539
......@@ -15,8 +15,12 @@
#include <girara/shortcuts.h>
#include <girara/config.h>
#include <girara/commands.h>
#include <girara/utils.h>
#include <glib/gi18n.h>
#define GLOBAL_RC "/etc/zathurarc"
#define ZATHURA_RC "zathurarc"
static void
cb_jumplist_change(girara_session_t* session, const char* name,
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
......@@ -454,11 +458,25 @@ config_load_default(zathura_t* zathura)
}
void
config_load_file(zathura_t* zathura, const char* path)
config_load_files(zathura_t* zathura)
{
if (zathura == NULL || path == NULL) {
return;
/* load global configuration files */
char* config_path = girara_get_xdg_path(XDG_CONFIG_DIRS);
girara_list_t* config_dirs = girara_split_path_array(config_path);
ssize_t size = girara_list_size(config_dirs) - 1;
for (; size >= 0; --size) {
const char* dir = girara_list_nth(config_dirs, size);
char* file = g_build_filename(dir, ZATHURA_RC, NULL);
girara_config_parse(zathura->ui.session, file);
g_free(file);
}
girara_list_free(config_dirs);
g_free(config_path);
girara_config_parse(zathura->ui.session, GLOBAL_RC);
girara_config_parse(zathura->ui.session, path);
/* load local configuration files */
char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL);
girara_config_parse(zathura->ui.session, configuration_file);
g_free(configuration_file);
}
......@@ -3,9 +3,6 @@
#ifndef CONFIG_H
#define CONFIG_H
#define GLOBAL_RC "/etc/zathurarc"
#define ZATHURA_RC "zathurarc"
#include "zathura.h"
/**
......@@ -21,6 +18,6 @@ void config_load_default(zathura_t* zathura);
* @param zathura The zathura session
* @param path Path to the configuration file
*/
void config_load_file(zathura_t* zathura, const char* path);
void config_load_files(zathura_t* zathura);
#endif // CONFIG_H
......@@ -168,8 +168,8 @@ cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext*
static void
cb_print_request_page_setup(GtkPrintOperation* UNUSED(print_operation),
GtkPrintContext* UNUSED(context), gint page_number, GtkPageSetup* setup,
zathura_t* zathura)
GtkPrintContext* UNUSED(context), gint page_number,
GtkPageSetup* setup, zathura_t* zathura)
{
if (zathura == NULL || zathura->document == NULL) {
return;
......
......@@ -101,26 +101,7 @@ zathura_init(zathura_t* zathura)
/* configuration */
config_load_default(zathura);
/* load global configuration files */
char* config_path = girara_get_xdg_path(XDG_CONFIG_DIRS);
girara_list_t* config_dirs = girara_split_path_array(config_path);
ssize_t size = girara_list_size(config_dirs) - 1;
for (; size >= 0; --size) {
const char* dir = girara_list_nth(config_dirs, size);
char* file = g_build_filename(dir, ZATHURA_RC, NULL);
config_load_file(zathura, file);
g_free(file);
}
girara_list_free(config_dirs);
g_free(config_path);
config_load_file(zathura, GLOBAL_RC);
/* load local configuration files */
char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL);
config_load_file(zathura, configuration_file);
g_free(configuration_file);
config_load_files(zathura);
/* UI */
if (girara_session_init(zathura->ui.session, "zathura") == false) {
......
Markdown is supported
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