mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 18:13:46 +01:00
Move config file loading to config.c
This commit is contained in:
parent
4350053956
commit
68b665a49d
26
config.c
26
config.c
@ -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, path);
|
||||
girara_config_parse(zathura->ui.session, GLOBAL_RC);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
5
config.h
5
config.h
@ -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
|
||||
|
4
print.c
4
print.c
@ -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;
|
||||
|
21
zathura.c
21
zathura.c
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user