1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Moved function to get theme dir to theme.c

This commit is contained in:
James Booth 2013-02-02 22:23:34 +00:00
parent 1247d1c7ee
commit 7398d565d7
3 changed files with 19 additions and 19 deletions

View File

@ -32,10 +32,10 @@
#include <ncurses.h> #include <ncurses.h>
#endif #endif
#include "theme.h" #include "common.h"
#include "files.h" #include "files.h"
#include "log.h" #include "log.h"
#include "theme.h"
static GString *theme_loc; static GString *theme_loc;
static GKeyFile *theme; static GKeyFile *theme;
@ -92,6 +92,7 @@ static NCURSES_COLOR_T _lookup_colour(const char * const colour);
static void _set_colour(gchar *val, NCURSES_COLOR_T *pref, static void _set_colour(gchar *val, NCURSES_COLOR_T *pref,
NCURSES_COLOR_T def); NCURSES_COLOR_T def);
static void _load_colours(void); static void _load_colours(void);
static gchar * _get_themes_dir(void);
void void
theme_init(const char * const theme_name) theme_init(const char * const theme_name)
@ -100,7 +101,7 @@ theme_init(const char * const theme_name)
theme = g_key_file_new(); theme = g_key_file_new();
if (theme_name != NULL) { if (theme_name != NULL) {
gchar *themes_dir = files_get_themes_dir(); gchar *themes_dir = _get_themes_dir();
theme_loc = g_string_new(themes_dir); theme_loc = g_string_new(themes_dir);
g_free(themes_dir); g_free(themes_dir);
g_string_append(theme_loc, "/"); g_string_append(theme_loc, "/");
@ -116,7 +117,7 @@ GSList *
theme_list(void) theme_list(void)
{ {
GSList *result = NULL; GSList *result = NULL;
gchar *themes_dir = files_get_themes_dir(); gchar *themes_dir = _get_themes_dir();
GDir *themes = g_dir_open(themes_dir, 0, NULL); GDir *themes = g_dir_open(themes_dir, 0, NULL);
if (themes != NULL) { if (themes != NULL) {
const gchar *theme = g_dir_read_name(themes); const gchar *theme = g_dir_read_name(themes);
@ -143,7 +144,7 @@ theme_load(const char * const theme_name)
_load_colours(); _load_colours();
return TRUE; return TRUE;
} else { } else {
gchar *themes_dir = files_get_themes_dir(); gchar *themes_dir = _get_themes_dir();
GString *new_theme_file = g_string_new(themes_dir); GString *new_theme_file = g_string_new(themes_dir);
g_free(themes_dir); g_free(themes_dir);
g_string_append(new_theme_file, "/"); g_string_append(new_theme_file, "/");
@ -358,3 +359,16 @@ _load_colours(void)
_set_colour(them_val, &colour_prefs.them, COLOR_GREEN); _set_colour(them_val, &colour_prefs.them, COLOR_GREEN);
g_free(them_val); g_free(them_val);
} }
static gchar *
_get_themes_dir(void)
{
gchar *xdg_config = xdg_get_config_home();
GString *themes_dir = g_string_new(xdg_config);
g_string_append(themes_dir, "/profanity/themes");
gchar *result = strdup(themes_dir->str);
g_free(xdg_config);
g_string_free(themes_dir, TRUE);
return result;
}

View File

@ -45,19 +45,6 @@ files_create_directories(void)
_files_create_themes_directory(); _files_create_themes_directory();
} }
gchar *
files_get_themes_dir(void)
{
gchar *xdg_config = xdg_get_config_home();
GString *themes_dir = g_string_new(xdg_config);
g_string_append(themes_dir, "/profanity/themes");
gchar *result = strdup(themes_dir->str);
g_free(xdg_config);
g_string_free(themes_dir, TRUE);
return result;
}
static void static void
_files_create_config_directory(void) _files_create_config_directory(void)
{ {

View File

@ -24,6 +24,5 @@
#define FILES_H #define FILES_H
void files_create_directories(void); void files_create_directories(void);
gchar* files_get_themes_dir(void);
#endif #endif