mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Add -t theme option
`profanity -t bios` loads the bios theme now. Fix https://github.com/profanity-im/profanity/issues/1286
This commit is contained in:
parent
4c8e78664c
commit
4f19ea2642
@ -67,8 +67,12 @@ static gboolean _theme_load_file(const char *const theme_name);
|
||||
void
|
||||
theme_init(const char *const theme_name)
|
||||
{
|
||||
if (!_theme_load_file(theme_name) && !_theme_load_file("default")) {
|
||||
log_error("Theme initialisation failed");
|
||||
if (!_theme_load_file(theme_name)) {
|
||||
log_error("Loading theme %s failed.", theme_name);
|
||||
|
||||
if (!_theme_load_file("default")) {
|
||||
log_error("Theme initialisation failed.");
|
||||
}
|
||||
}
|
||||
|
||||
defaults = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
|
||||
|
@ -64,6 +64,7 @@ static char *log = NULL;
|
||||
static char *log_file = NULL;
|
||||
static char *account_name = NULL;
|
||||
static char *config_file = NULL;
|
||||
static char *theme_name = NULL;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
@ -80,6 +81,7 @@ main(int argc, char **argv)
|
||||
{ "log", 'l', 0, G_OPTION_ARG_STRING, &log, "Set logging levels, DEBUG, INFO (default), WARN, ERROR", "LEVEL" },
|
||||
{ "config", 'c', 0, G_OPTION_ARG_STRING, &config_file, "Use an alternative configuration file", NULL },
|
||||
{ "logfile", 'f', 0, G_OPTION_ARG_STRING, &log_file, "Specify log filename", NULL },
|
||||
{ "theme", 't', 0, G_OPTION_ARG_STRING, &theme_name, "Specify theme name", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -175,13 +177,14 @@ main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
prof_run(log ? log : "INFO", account_name, config_file, log_file);
|
||||
prof_run(log ? log : "INFO", account_name, config_file, log_file, theme_name);
|
||||
|
||||
/* Free resources allocated by GOptionContext */
|
||||
g_free(log);
|
||||
g_free(account_name);
|
||||
g_free(config_file);
|
||||
g_free(log_file);
|
||||
g_free(theme_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@
|
||||
#include "omemo/omemo.h"
|
||||
#endif
|
||||
|
||||
static void _init(char *log_level, char *config_file, char *log_file);
|
||||
static void _init(char *log_level, char *config_file, char *log_file, char *theme_name);
|
||||
static void _shutdown(void);
|
||||
static void _connect_default(const char * const account);
|
||||
|
||||
@ -94,9 +94,9 @@ static gboolean cont = TRUE;
|
||||
static gboolean force_quit = FALSE;
|
||||
|
||||
void
|
||||
prof_run(char *log_level, char *account_name, char *config_file, char *log_file)
|
||||
prof_run(char *log_level, char *account_name, char *config_file, char *log_file, char *theme_name)
|
||||
{
|
||||
_init(log_level, config_file, log_file);
|
||||
_init(log_level, config_file, log_file, theme_name);
|
||||
plugins_on_start();
|
||||
_connect_default(account_name);
|
||||
|
||||
@ -157,7 +157,7 @@ _connect_default(const char *const account)
|
||||
}
|
||||
|
||||
static void
|
||||
_init(char *log_level, char *config_file, char *log_file)
|
||||
_init(char *log_level, char *config_file, char *log_file, char *theme_name)
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
// ignore SIGPIPE
|
||||
@ -169,12 +169,14 @@ _init(char *log_level, char *config_file, char *log_file)
|
||||
log_error("Mutex init failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&lock);
|
||||
files_create_directories();
|
||||
log_level_t prof_log_level = log_level_from_string(log_level);
|
||||
prefs_load(config_file);
|
||||
log_init(prof_log_level, log_file);
|
||||
log_stderr_init(PROF_LEVEL_ERROR);
|
||||
|
||||
if (strcmp(PACKAGE_STATUS, "development") == 0) {
|
||||
#ifdef HAVE_GIT_VERSION
|
||||
log_info("Starting Profanity (%sdev.%s.%s)...", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
|
||||
@ -184,12 +186,19 @@ _init(char *log_level, char *config_file, char *log_file)
|
||||
} else {
|
||||
log_info("Starting Profanity (%s)...", PACKAGE_VERSION);
|
||||
}
|
||||
|
||||
chat_log_init();
|
||||
groupchat_log_init();
|
||||
accounts_load();
|
||||
char *theme = prefs_get_string(PREF_THEME);
|
||||
theme_init(theme);
|
||||
prefs_free_string(theme);
|
||||
|
||||
if (theme_name) {
|
||||
theme_init(theme_name);
|
||||
} else {
|
||||
char *theme = prefs_get_string(PREF_THEME);
|
||||
theme_init(theme);
|
||||
prefs_free_string(theme);
|
||||
}
|
||||
|
||||
ui_init();
|
||||
session_init();
|
||||
cmd_init();
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include <pthread.h>
|
||||
#include <glib.h>
|
||||
|
||||
void prof_run(char *log_level, char *account_name, char *config_file, char *log_file);
|
||||
void prof_run(char *log_level, char *account_name, char *config_file, char *log_file, char *theme_name);
|
||||
void prof_set_quit(void);
|
||||
|
||||
pthread_mutex_t lock;
|
||||
|
Loading…
Reference in New Issue
Block a user