Move xgd functions

This commit is contained in:
James Booth
2016-07-24 17:12:09 +01:00
parent 6cc4abedc5
commit 29452f8f1b
17 changed files with 56 additions and 52 deletions

View File

@@ -858,7 +858,7 @@ _save_accounts(void)
{
gsize g_data_size;
gchar *g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL);
gchar *xdg_data = xdg_get_data_home();
gchar *xdg_data = files_get_xdg_data_home();
GString *base_str = g_string_new(xdg_data);
g_string_append(base_str, "/profanity/");
gchar *true_loc = get_file_or_linked(accounts_loc, base_str->str);
@@ -873,7 +873,7 @@ _save_accounts(void)
static gchar*
_get_accounts_file(void)
{
gchar *xdg_data = xdg_get_data_home();
gchar *xdg_data = files_get_xdg_data_home();
GString *logfile = g_string_new(xdg_data);
g_string_append(logfile, "/profanity/accounts");
gchar *result = strdup(logfile->str);

View File

@@ -45,8 +45,8 @@
void
files_create_directories(void)
{
gchar *xdg_config = xdg_get_config_home();
gchar *xdg_data = xdg_get_data_home();
gchar *xdg_config = files_get_xdg_config_home();
gchar *xdg_data = files_get_xdg_data_home();
GString *themes_dir = g_string_new(xdg_config);
g_string_append(themes_dir, "/profanity/themes");
@@ -86,7 +86,28 @@ files_create_directories(void)
}
gchar*
xdg_get_config_home(void)
files_get_inputrc_path(void)
{
gchar *xdg_config = files_get_xdg_config_home();
GString *inputrc_file = g_string_new(xdg_config);
g_free(xdg_config);
g_string_append(inputrc_file, "/profanity/inputrc");
if (g_file_test(inputrc_file->str, G_FILE_TEST_IS_REGULAR)) {
gchar *result = strdup(inputrc_file->str);
g_string_free(inputrc_file, TRUE);
return result;
}
g_string_free(inputrc_file, TRUE);
return NULL;
}
gchar*
files_get_xdg_config_home(void)
{
gchar *xdg_config_home = getenv("XDG_CONFIG_HOME");
if (xdg_config_home)
@@ -105,7 +126,7 @@ xdg_get_config_home(void)
}
gchar*
xdg_get_data_home(void)
files_get_xdg_data_home(void)
{
gchar *xdg_data_home = getenv("XDG_DATA_HOME");
if (xdg_data_home)

View File

@@ -37,8 +37,11 @@
#include <glib.h>
gchar* xdg_get_config_home(void);
gchar* xdg_get_data_home(void);
void files_create_directories(void);
gchar* files_get_inputrc_path(void);
gchar* files_get_xdg_config_home(void);
gchar* files_get_xdg_data_home(void);
#endif

View File

@@ -1121,27 +1121,6 @@ prefs_get_aliases(void)
}
}
gchar*
prefs_get_inputrc(void)
{
gchar *xdg_config = xdg_get_config_home();
GString *inputrc_file = g_string_new(xdg_config);
g_free(xdg_config);
g_string_append(inputrc_file, "/profanity/inputrc");
if (g_file_test(inputrc_file->str, G_FILE_TEST_IS_REGULAR)) {
gchar *result = strdup(inputrc_file->str);
g_string_free(inputrc_file, TRUE);
return result;
}
g_string_free(inputrc_file, TRUE);
return NULL;
}
void
_free_alias(ProfAlias *alias)
{
@@ -1161,7 +1140,7 @@ _save_prefs(void)
{
gsize g_data_size;
gchar *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
gchar *xdg_config = xdg_get_config_home();
gchar *xdg_config = files_get_xdg_config_home();
GString *base_str = g_string_new(xdg_config);
g_string_append(base_str, "/profanity/");
gchar *true_loc = get_file_or_linked(prefs_loc, base_str->str);
@@ -1176,7 +1155,7 @@ _save_prefs(void)
static gchar*
_get_preferences_file(void)
{
gchar *xdg_config = xdg_get_config_home();
gchar *xdg_config = files_get_xdg_config_home();
GString *prefs_file = g_string_new(xdg_config);
g_string_append(prefs_file, "/profanity/profrc");
gchar *result = strdup(prefs_file->str);

View File

@@ -51,7 +51,7 @@
void
scripts_init(void)
{
gchar *data_home = xdg_get_data_home();
gchar *data_home = files_get_xdg_data_home();
GString *scriptsdir = g_string_new(data_home);
free(data_home);
@@ -75,7 +75,7 @@ scripts_init(void)
GSList*
scripts_list(void)
{
gchar *data_home = xdg_get_data_home();
gchar *data_home = files_get_xdg_data_home();
GString *scriptsdir = g_string_new(data_home);
free(data_home);
g_string_append(scriptsdir, "/profanity/scripts");
@@ -99,7 +99,7 @@ scripts_list(void)
GSList*
scripts_read(const char *const script)
{
gchar *data_home = xdg_get_data_home();
gchar *data_home = files_get_xdg_data_home();
GString *scriptpath = g_string_new(data_home);
free(data_home);
@@ -137,7 +137,7 @@ scripts_read(const char *const script)
gboolean
scripts_exec(const char *const script)
{
gchar *data_home = xdg_get_data_home();
gchar *data_home = files_get_xdg_data_home();
GString *scriptpath = g_string_new(data_home);
free(data_home);

View File

@@ -535,7 +535,7 @@ _load_preferences(void)
static gchar*
_get_themes_dir(void)
{
gchar *xdg_config = xdg_get_config_home();
gchar *xdg_config = files_get_xdg_config_home();
GString *themes_dir = g_string_new(xdg_config);
g_free(xdg_config);
g_string_append(themes_dir, "/profanity/themes");

View File

@@ -432,7 +432,7 @@ tlscerts_close(void)
static gchar*
_get_tlscerts_file(void)
{
gchar *xdg_data = xdg_get_data_home();
gchar *xdg_data = files_get_xdg_data_home();
GString *tlscerts_file = g_string_new(xdg_data);
g_string_append(tlscerts_file, "/profanity/tlscerts");
gchar *result = strdup(tlscerts_file->str);