mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-13 07:43:46 +01:00
Load configuration files
This commit is contained in:
parent
fdeb73436a
commit
3335e71ed8
17
config.c
17
config.c
@ -4,6 +4,7 @@
|
|||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
#include "shortcuts.h"
|
#include "shortcuts.h"
|
||||||
#include "zathura.h"
|
#include "zathura.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
config_load_default(void)
|
config_load_default(void)
|
||||||
@ -11,15 +12,19 @@ config_load_default(void)
|
|||||||
if (!Zathura.UI.session)
|
if (!Zathura.UI.session)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int int_value = 0;
|
int int_value = 0;
|
||||||
|
char* string_value = NULL;
|
||||||
|
|
||||||
/* general settings */
|
/* general settings */
|
||||||
girara_mode_set(Zathura.UI.session, NORMAL);
|
girara_mode_set(Zathura.UI.session, NORMAL);
|
||||||
|
|
||||||
/* zathura settings */
|
/* zathura settings */
|
||||||
|
string_value = CONFIG_DIR;
|
||||||
|
girara_setting_add(Zathura.UI.session, "config-dir", string_value, STRING, true, "Configuration directory", NULL);
|
||||||
int_value = 10;
|
int_value = 10;
|
||||||
girara_setting_add(Zathura.UI.session, "zoom-step", &int_value, INT, false, "Zoom step", NULL);
|
girara_setting_add(Zathura.UI.session, "zoom-step", &int_value, INT, false, "Zoom step", NULL);
|
||||||
|
|
||||||
|
|
||||||
/* define default shortcuts */
|
/* define default shortcuts */
|
||||||
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL);
|
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL);
|
||||||
girara_shortcut_add(Zathura.UI.session, 0, GDK_Escape, NULL, sc_abort, 0, 0, NULL);
|
girara_shortcut_add(Zathura.UI.session, 0, GDK_Escape, NULL, sc_abort, 0, 0, NULL);
|
||||||
@ -91,3 +96,13 @@ config_load_default(void)
|
|||||||
girara_inputbar_command_add(Zathura.UI.session, "print", NULL, cmd_print, cc_print, "Print document");
|
girara_inputbar_command_add(Zathura.UI.session, "print", NULL, cmd_print, cc_print, "Print document");
|
||||||
girara_inputbar_command_add(Zathura.UI.session, "save", NULL, cmd_save, NULL, "Save document");
|
girara_inputbar_command_add(Zathura.UI.session, "save", NULL, cmd_save, NULL, "Save document");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
config_load_file(char* path)
|
||||||
|
{
|
||||||
|
if (Zathura.UI.session == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
girara_config_parse(Zathura.UI.session, path);
|
||||||
|
}
|
||||||
|
11
config.h
11
config.h
@ -3,9 +3,20 @@
|
|||||||
#ifndef CONFIG_H
|
#ifndef CONFIG_H
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
|
#define GLOBAL_RC "/etc/zathurarc"
|
||||||
|
#define ZATHURA_RC "zathurarc"
|
||||||
|
#define CONFIG_DIR "~/.config/zathura"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function loads the default values of the configuration
|
* This function loads the default values of the configuration
|
||||||
*/
|
*/
|
||||||
void config_load_default(void);
|
void config_load_default(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads and evaluates a configuration file
|
||||||
|
*
|
||||||
|
* @param path Path to the configuration file
|
||||||
|
*/
|
||||||
|
void config_load_file(char* path);
|
||||||
|
|
||||||
#endif // CONFIG_H
|
#endif // CONFIG_H
|
||||||
|
10
zathura.c
10
zathura.c
@ -70,6 +70,16 @@ init_zathura()
|
|||||||
/* configuration */
|
/* configuration */
|
||||||
config_load_default();
|
config_load_default();
|
||||||
|
|
||||||
|
/* load global configuration files */
|
||||||
|
config_load_file(GLOBAL_RC);
|
||||||
|
|
||||||
|
/* load local configuration files */
|
||||||
|
char* config_dir = girara_setting_get(Zathura.UI.session, "config-dir");
|
||||||
|
char* configuration_file = g_build_filename(config_dir ? config_dir : CONFIG_DIR, ZATHURA_RC, NULL);
|
||||||
|
config_load_file(configuration_file);
|
||||||
|
free(config_dir);
|
||||||
|
free(configuration_file);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error_free:
|
error_free:
|
||||||
|
Loading…
Reference in New Issue
Block a user