diff options
author | James Booth <boothj5@gmail.com> | 2013-02-02 21:59:29 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-02-02 21:59:29 +0000 |
commit | 9d34c41227cb7567b26872f2a10a8f7a1b01f487 (patch) | |
tree | 5068fecb975441b50b73500ef652cf368c675b6a /src/config | |
parent | 740e5b422832f8d043d96f33a0d33bf1725dbbc0 (diff) | |
download | profani-tty-9d34c41227cb7567b26872f2a10a8f7a1b01f487.tar.gz |
Added config dir to source
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/accounts.c | 532 | ||||
-rw-r--r-- | src/config/accounts.h | 75 | ||||
-rw-r--r-- | src/config/preferences.c | 455 | ||||
-rw-r--r-- | src/config/preferences.h | 101 | ||||
-rw-r--r-- | src/config/theme.c | 360 | ||||
-rw-r--r-- | src/config/theme.h | 65 |
6 files changed, 1588 insertions, 0 deletions
diff --git a/src/config/accounts.c b/src/config/accounts.c new file mode 100644 index 00000000..6549819b --- /dev/null +++ b/src/config/accounts.c @@ -0,0 +1,532 @@ +/* + * accounts.c + * + * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com> + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <stdlib.h> +#include <string.h> + +#include <glib.h> + +#include "accounts.h" + +#include "common.h" +#include "files.h" +#include "jid.h" +#include "log.h" +#include "tools/autocomplete.h" +#include "xmpp/xmpp.h" + +static gchar *accounts_loc; +static GKeyFile *accounts; + +static Autocomplete all_ac; +static Autocomplete enabled_ac; + +static gchar *string_keys[] = {"jid", "server", "resource", "presence.last", "presence.login"}; + +static void _fix_legacy_accounts(const char * const account_name); +static void _save_accounts(void); + +void +accounts_load(void) +{ + log_info("Loading accounts"); + all_ac = autocomplete_new(); + enabled_ac = autocomplete_new(); + accounts_loc = files_get_accounts_file(); + + accounts = g_key_file_new(); + g_key_file_load_from_file(accounts, accounts_loc, G_KEY_FILE_KEEP_COMMENTS, + NULL); + + // create the logins searchable list for autocompletion + gsize naccounts; + gchar **account_names = + g_key_file_get_groups(accounts, &naccounts); + + gsize i; + for (i = 0; i < naccounts; i++) { + autocomplete_add(all_ac, strdup(account_names[i])); + if (g_key_file_get_boolean(accounts, account_names[i], "enabled", NULL)) { + autocomplete_add(enabled_ac, strdup(account_names[i])); + } + + _fix_legacy_accounts(account_names[i]); + } + + for (i = 0; i < naccounts; i++) { + free(account_names[i]); + } + free(account_names); +} + +void +accounts_close(void) +{ + autocomplete_free(all_ac); + autocomplete_free(enabled_ac); + g_key_file_free(accounts); +} + +char * +accounts_find_enabled(char *prefix) +{ + return autocomplete_complete(enabled_ac, prefix); +} + +char * +accounts_find_all(char *prefix) +{ + return autocomplete_complete(all_ac, prefix); +} + +void +accounts_reset_all_search(void) +{ + autocomplete_reset(all_ac); +} + +void +accounts_reset_enabled_search(void) +{ + autocomplete_reset(enabled_ac); +} + +void +accounts_add(const char *account_name, const char *altdomain) +{ + // set account name and resource + const char *barejid = account_name; + const char *resource = "profanity"; + Jid *jid = jid_create(account_name); + if (jid != NULL) { + barejid = jid->barejid; + if (jid->resourcepart != NULL) { + resource = jid->resourcepart; + } + } + + // doesn't yet exist + if (!g_key_file_has_group(accounts, account_name)) { + g_key_file_set_boolean(accounts, account_name, "enabled", TRUE); + g_key_file_set_string(accounts, account_name, "jid", barejid); + g_key_file_set_string(accounts, account_name, "resource", resource); + if (altdomain != NULL) { + g_key_file_set_string(accounts, account_name, "server", altdomain); + } + g_key_file_set_string(accounts, account_name, "presence.last", "online"); + g_key_file_set_string(accounts, account_name, "presence.login", "online"); + g_key_file_set_integer(accounts, account_name, "priority.online", 0); + g_key_file_set_integer(accounts, account_name, "priority.chat", 0); + g_key_file_set_integer(accounts, account_name, "priority.away", 0); + g_key_file_set_integer(accounts, account_name, "priority.xa", 0); + g_key_file_set_integer(accounts, account_name, "priority.dnd", 0); + + _save_accounts(); + autocomplete_add(all_ac, strdup(account_name)); + autocomplete_add(enabled_ac, strdup(account_name)); + } + + jid_destroy(jid); +} + +gchar** +accounts_get_list(void) +{ + return g_key_file_get_groups(accounts, NULL); +} + +ProfAccount* +accounts_get_account(const char * const name) +{ + if (!g_key_file_has_group(accounts, name)) { + return NULL; + } else { + ProfAccount *account = malloc(sizeof(ProfAccount)); + account->name = strdup(name); + + gchar *jid = g_key_file_get_string(accounts, name, "jid", NULL); + if (jid != NULL) { + account->jid = strdup(jid); + } else { + account->jid = strdup(name); + g_key_file_set_string(accounts, name, "jid", name); + _save_accounts(); + } + + account->enabled = g_key_file_get_boolean(accounts, name, "enabled", NULL); + + gchar *server = g_key_file_get_string(accounts, name, "server", NULL); + if (server != NULL) { + account->server = strdup(server); + } else { + account->server = NULL; + } + + gchar *resource = g_key_file_get_string(accounts, name, "resource", NULL); + if (resource != NULL) { + account->resource = strdup(resource); + } else { + account->resource = NULL; + } + + gchar *presence = g_key_file_get_string(accounts, name, "presence.last", NULL); + if (presence == NULL || (!presence_valid_string(presence))) { + account->last_presence = strdup("online"); + } else { + account->last_presence = strdup(presence); + } + + presence = g_key_file_get_string(accounts, name, "presence.login", NULL); + if (presence == NULL) { + account->login_presence = strdup("online"); + } else if (strcmp(presence, "last") == 0) { + account->login_presence = strdup("last"); + } else if (!presence_valid_string(presence)) { + account->login_presence = strdup("online"); + } else { + account->login_presence = strdup(presence); + } + + account->priority_online = g_key_file_get_integer(accounts, name, "priority.online", NULL); + account->priority_chat = g_key_file_get_integer(accounts, name, "priority.chat", NULL); + account->priority_away = g_key_file_get_integer(accounts, name, "priority.away", NULL); + account->priority_xa = g_key_file_get_integer(accounts, name, "priority.xa", NULL); + account->priority_dnd = g_key_file_get_integer(accounts, name, "priority.dnd", NULL); + + return account; + } +} + +void +accounts_free_account(ProfAccount *account) +{ + if (account != NULL) { + FREE_SET_NULL(account->name); + FREE_SET_NULL(account->jid); + FREE_SET_NULL(account->resource); + FREE_SET_NULL(account->server); + FREE_SET_NULL(account->last_presence); + FREE_SET_NULL(account->login_presence); + FREE_SET_NULL(account); + } +} + +gboolean +accounts_enable(const char * const name) +{ + if (g_key_file_has_group(accounts, name)) { + g_key_file_set_boolean(accounts, name, "enabled", TRUE); + _save_accounts(); + autocomplete_add(enabled_ac, strdup(name)); + return TRUE; + } else { + return FALSE; + } +} + +gboolean +accounts_disable(const char * const name) +{ + if (g_key_file_has_group(accounts, name)) { + g_key_file_set_boolean(accounts, name, "enabled", FALSE); + _save_accounts(); + autocomplete_remove(enabled_ac, strdup(name)); + return TRUE; + } else { + return FALSE; + } +} + +gboolean +accounts_rename(const char * const account_name, const char * const new_name) +{ + if (g_key_file_has_group(accounts, new_name)) { + return FALSE; + } + + if (!g_key_file_has_group(accounts, account_name)) { + return FALSE; + } + + g_key_file_set_boolean(accounts, new_name, "enabled", + g_key_file_get_boolean(accounts, account_name, "enabled", NULL)); + + g_key_file_set_integer(accounts, new_name, "priority.online", + g_key_file_get_boolean(accounts, account_name, "priority.online", NULL)); + g_key_file_set_integer(accounts, new_name, "priority.chat", + g_key_file_get_boolean(accounts, account_name, "priority.chat", NULL)); + g_key_file_set_integer(accounts, new_name, "priority.away", + g_key_file_get_boolean(accounts, account_name, "priority.away", NULL)); + g_key_file_set_integer(accounts, new_name, "priority.xa", + g_key_file_get_boolean(accounts, account_name, "priority.xa", NULL)); + g_key_file_set_integer(accounts, new_name, "priority.dnd", + g_key_file_get_boolean(accounts, account_name, "priority.dnd", NULL)); + + int i; + for (i = 0; i < ARRAY_SIZE(string_keys); i++) { + char *value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL); + if (value != NULL) { + g_key_file_set_string(accounts, new_name, string_keys[i], value); + free(value); + } + } + + g_key_file_remove_group(accounts, account_name, NULL); + _save_accounts(); + + autocomplete_remove(all_ac, strdup(account_name)); + autocomplete_add(all_ac, strdup(new_name)); + if (g_key_file_get_boolean(accounts, new_name, "enabled", NULL)) { + autocomplete_remove(enabled_ac, strdup(account_name)); + autocomplete_add(enabled_ac, strdup(new_name)); + } + + return TRUE; +} + +gboolean +accounts_account_exists(const char * const account_name) +{ + return g_key_file_has_group(accounts, account_name); + +} + +void +accounts_set_jid(const char * const account_name, const char * const value) +{ + Jid *jid = jid_create(value); + if (jid != NULL) { + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "jid", jid->barejid); + if (jid->resourcepart != NULL) { + g_key_file_set_string(accounts, account_name, "resource", jid->resourcepart); + } + _save_accounts(); + } + } +} + +void +accounts_set_server(const char * const account_name, const char * const value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "server", value); + _save_accounts(); + } +} + +void +accounts_set_resource(const char * const account_name, const char * const value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "resource", value); + _save_accounts(); + } +} + +void +accounts_set_priority_online(const char * const account_name, const gint value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_integer(accounts, account_name, "priority.online", value); + _save_accounts(); + } +} + +void +accounts_set_priority_chat(const char * const account_name, const gint value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_integer(accounts, account_name, "priority.chat", value); + _save_accounts(); + } +} + +void +accounts_set_priority_away(const char * const account_name, const gint value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_integer(accounts, account_name, "priority.away", value); + _save_accounts(); + } +} + +void +accounts_set_priority_xa(const char * const account_name, const gint value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_integer(accounts, account_name, "priority.xa", value); + _save_accounts(); + } +} + +void +accounts_set_priority_dnd(const char * const account_name, const gint value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_integer(accounts, account_name, "priority.dnd", value); + _save_accounts(); + } +} + +void +accounts_set_priority_all(const char * const account_name, const gint value) +{ + if (accounts_account_exists(account_name)) { + accounts_set_priority_online(account_name, value); + accounts_set_priority_chat(account_name, value); + accounts_set_priority_away(account_name, value); + accounts_set_priority_xa(account_name, value); + accounts_set_priority_dnd(account_name, value); + _save_accounts(); + } +} + +gint +accounts_get_priority_for_presence_type(const char * const account_name, + jabber_presence_t presence_type) +{ + gint result; + + switch (presence_type) + { + case (PRESENCE_ONLINE): + result = g_key_file_get_integer(accounts, account_name, "priority.online", NULL); + break; + case (PRESENCE_CHAT): + result = g_key_file_get_integer(accounts, account_name, "priority.chat", NULL); + break; + case (PRESENCE_AWAY): + result = g_key_file_get_integer(accounts, account_name, "priority.away", NULL); + break; + case (PRESENCE_XA): + result = g_key_file_get_integer(accounts, account_name, "priority.xa", NULL); + break; + case (PRESENCE_DND): + result = g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL); + break; + default: + result = 0; + break; + } + + return result; +} + +void +accounts_set_last_presence(const char * const account_name, const char * const value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "presence.last", value); + _save_accounts(); + } +} + +void +accounts_set_login_presence(const char * const account_name, const char * const value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "presence.login", value); + _save_accounts(); + } +} + +jabber_presence_t +accounts_get_last_presence(const char * const account_name) +{ + gchar *setting = g_key_file_get_string(accounts, account_name, "presence.last", NULL); + if (setting == NULL || (strcmp(setting, "online") == 0)) { + return PRESENCE_ONLINE; + } else if (strcmp(setting, "chat") == 0) { + return PRESENCE_CHAT; + } else if (strcmp(setting, "away") == 0) { + return PRESENCE_AWAY; + } else if (strcmp(setting, "xa") == 0) { + return PRESENCE_XA; + } else if (strcmp(setting, "dnd") == 0) { + return PRESENCE_DND; + } else { + log_warning("Error reading presence.last for account: '%s', value: '%s', defaulting to 'online'", + account_name, setting); + return PRESENCE_ONLINE; + } +} + +jabber_presence_t +accounts_get_login_presence(const char * const account_name) +{ + gchar *setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL); + if (setting == NULL || (strcmp(setting, "online") == 0)) { + return PRESENCE_ONLINE; + } else if (strcmp(setting, "chat") == 0) { + return PRESENCE_CHAT; + } else if (strcmp(setting, "away") == 0) { + return PRESENCE_AWAY; + } else if (strcmp(setting, "xa") == 0) { + return PRESENCE_XA; + } else if (strcmp(setting, "dnd") == 0) { + return PRESENCE_DND; + } else if (strcmp(setting, "last") == 0) { + return accounts_get_last_presence(account_name); + } else { + log_warning("Error reading presence.login for account: '%s', value: '%s', defaulting to 'online'", + account_name, setting); + return PRESENCE_ONLINE; + } +} + +static void +_fix_legacy_accounts(const char * const account_name) +{ + // set barejid and resource + const char *barejid = account_name; + const char *resource = "profanity"; + Jid *jid = jid_create(account_name); + if (jid != NULL) { + barejid = jid->barejid; + if (jid->resourcepart != NULL) { + resource = jid->resourcepart; + } + } + + // accounts with no jid property + if (!g_key_file_has_key(accounts, account_name, "jid", NULL)) { + g_key_file_set_string(accounts, account_name, "jid", barejid); + _save_accounts(); + } + + // accounts with no resource, property + if (!g_key_file_has_key(accounts, account_name, "resource", NULL)) { + g_key_file_set_string(accounts, account_name, "resource", resource); + _save_accounts(); + } + + jid_destroy(jid); +} + +static void +_save_accounts(void) +{ + gsize g_data_size; + char *g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL); + g_file_set_contents(accounts_loc, g_accounts_data, g_data_size, NULL); +} diff --git a/src/config/accounts.h b/src/config/accounts.h new file mode 100644 index 00000000..a9292a02 --- /dev/null +++ b/src/config/accounts.h @@ -0,0 +1,75 @@ +/* + * accounts.h + * + * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com> + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef ACCOUNTS_H +#define ACCOUNTS_H + +#include "common.h" + +typedef struct prof_account_t { + gchar *name; + gchar *jid; + gchar *resource; + gchar *server; + gchar *last_presence; + gchar *login_presence; + gint priority_online; + gint priority_chat; + gint priority_away; + gint priority_xa; + gint priority_dnd; + gboolean enabled; +} ProfAccount; + +void accounts_load(void); +void accounts_close(void); + +char * accounts_find_all(char *prefix); +char * accounts_find_enabled(char *prefix); +void accounts_reset_all_search(void); +void accounts_reset_enabled_search(void); +void accounts_add(const char *jid, const char *altdomain); +gchar** accounts_get_list(void); +ProfAccount* accounts_get_account(const char * const name); +void accounts_free_account(ProfAccount *account); +gboolean accounts_enable(const char * const name); +gboolean accounts_disable(const char * const name); +gboolean accounts_rename(const char * const account_name, + const char * const new_name); +gboolean accounts_account_exists(const char * const account_name); +void accounts_set_jid(const char * const account_name, const char * const value); +void accounts_set_server(const char * const account_name, const char * const value); +void accounts_set_resource(const char * const account_name, const char * const value); +void accounts_set_last_presence(const char * const account_name, const char * const value); +void accounts_set_login_presence(const char * const account_name, const char * const value); +jabber_presence_t accounts_get_login_presence(const char * const account_name); +jabber_presence_t accounts_get_last_presence(const char * const account_name); +void accounts_set_priority_online(const char * const account_name, const gint value); +void accounts_set_priority_chat(const char * const account_name, const gint value); +void accounts_set_priority_away(const char * const account_name, const gint value); +void accounts_set_priority_xa(const char * const account_name, const gint value); +void accounts_set_priority_dnd(const char * const account_name, const gint value); +void accounts_set_priority_all(const char * const account_name, const gint value); +gint accounts_get_priority_for_presence_type(const char * const account_name, + jabber_presence_t presence_type); + +#endif diff --git a/src/config/preferences.c b/src/config/preferences.c new file mode 100644 index 00000000..b2414fca --- /dev/null +++ b/src/config/preferences.c @@ -0,0 +1,455 @@ +/* + * preferences.c + * + * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com> + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "config.h" + +#include <stdlib.h> +#include <string.h> + +#include <glib.h> +#ifdef HAVE_NCURSESW_NCURSES_H +#include <ncursesw/ncurses.h> +#elif HAVE_NCURSES_H +#include <ncurses.h> +#endif + +#include "preferences.h" + +#include "files.h" +#include "log.h" +#include "tools/autocomplete.h" + +static gchar *prefs_loc; +static GKeyFile *prefs; +gint log_maxsize = 0; + +static Autocomplete boolean_choice_ac; + +static void _save_prefs(void); + +void +prefs_load(void) +{ + GError *err; + + log_info("Loading preferences"); + prefs_loc = files_get_preferences_file(); + + prefs = g_key_file_new(); + g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, + NULL); + + err = NULL; + log_maxsize = g_key_file_get_integer(prefs, "logging", "maxsize", &err); + if (err != NULL) { + log_maxsize = 0; + g_error_free(err); + } + + boolean_choice_ac = autocomplete_new(); + autocomplete_add(boolean_choice_ac, strdup("on")); + autocomplete_add(boolean_choice_ac, strdup("off")); +} + +void +prefs_close(void) +{ + autocomplete_free(boolean_choice_ac); + g_key_file_free(prefs); +} + +char * +prefs_autocomplete_boolean_choice(char *prefix) +{ + return autocomplete_complete(boolean_choice_ac, prefix); +} + +void +prefs_reset_boolean_choice(void) +{ + autocomplete_reset(boolean_choice_ac); +} + +gboolean +prefs_get_beep(void) +{ + return g_key_file_get_boolean(prefs, "ui", "beep", NULL); +} + +void +prefs_set_beep(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "beep", value); + _save_prefs(); +} + +gchar * +prefs_get_theme(void) +{ + return g_key_file_get_string(prefs, "ui", "theme", NULL); +} + +void +prefs_set_theme(gchar *value) +{ + g_key_file_set_string(prefs, "ui", "theme", value); + _save_prefs(); +} + +gboolean +prefs_get_states(void) +{ + return g_key_file_get_boolean(prefs, "chatstates", "enabled", NULL); +} + +void +prefs_set_states(gboolean value) +{ + g_key_file_set_boolean(prefs, "chatstates", "enabled", value); + _save_prefs(); +} + +gboolean +prefs_get_outtype(void) +{ + return g_key_file_get_boolean(prefs, "chatstates", "outtype", NULL); +} + +void +prefs_set_outtype(gboolean value) +{ + g_key_file_set_boolean(prefs, "chatstates", "outtype", value); + _save_prefs(); +} + +gint +prefs_get_gone(void) +{ + return g_key_file_get_integer(prefs, "chatstates", "gone", NULL); +} + +void +prefs_set_gone(gint value) +{ + g_key_file_set_integer(prefs, "chatstates", "gone", value); + _save_prefs(); +} + +gboolean +prefs_get_notify_typing(void) +{ + return g_key_file_get_boolean(prefs, "notifications", "typing", NULL); +} + +void +prefs_set_notify_typing(gboolean value) +{ + g_key_file_set_boolean(prefs, "notifications", "typing", value); + _save_prefs(); +} + +gboolean +prefs_get_notify_message(void) +{ + return g_key_file_get_boolean(prefs, "notifications", "message", NULL); +} + +void +prefs_set_notify_message(gboolean value) +{ + g_key_file_set_boolean(prefs, "notifications", "message", value); + _save_prefs(); +} + +gint +prefs_get_notify_remind(void) +{ + return g_key_file_get_integer(prefs, "notifications", "remind", NULL); +} + +void +prefs_set_notify_remind(gint value) +{ + g_key_file_set_integer(prefs, "notifications", "remind", value); + _save_prefs(); +} + +gint +prefs_get_max_log_size(void) +{ + if (log_maxsize < PREFS_MIN_LOG_SIZE) + return PREFS_MAX_LOG_SIZE; + else + return log_maxsize; +} + +void +prefs_set_max_log_size(gint value) +{ + log_maxsize = value; + g_key_file_set_integer(prefs, "logging", "maxsize", value); + _save_prefs(); +} + +gint +prefs_get_priority(void) +{ + return g_key_file_get_integer(prefs, "presence", "priority", NULL); +} + +void +prefs_set_priority(gint value) +{ + g_key_file_set_integer(prefs, "presence", "priority", value); + _save_prefs(); +} + +gint +prefs_get_reconnect(void) +{ + return g_key_file_get_integer(prefs, "connection", "reconnect", NULL); +} + +void +prefs_set_reconnect(gint value) +{ + g_key_file_set_integer(prefs, "connection", "reconnect", value); + _save_prefs(); +} + +gint +prefs_get_autoping(void) +{ + return g_key_file_get_integer(prefs, "connection", "autoping", NULL); +} + +void +prefs_set_autoping(gint value) +{ + g_key_file_set_integer(prefs, "connection", "autoping", value); + _save_prefs(); +} + +gboolean +prefs_get_vercheck(void) +{ + return g_key_file_get_boolean(prefs, "ui", "vercheck", NULL); +} + +void +prefs_set_vercheck(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "vercheck", value); + _save_prefs(); +} + +gboolean +prefs_get_titlebarversion(void) +{ + return g_key_file_get_boolean(prefs, "ui", "titlebar.version", NULL); +} + +void +prefs_set_titlebarversion(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "titlebar.version", value); + _save_prefs(); +} + +gboolean +prefs_get_flash(void) +{ + return g_key_file_get_boolean(prefs, "ui", "flash", NULL); +} + +void +prefs_set_flash(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "flash", value); + _save_prefs(); +} + +gboolean +prefs_get_intype(void) +{ + return g_key_file_get_boolean(prefs, "ui", "intype", NULL); +} + +void +prefs_set_intype(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "intype", value); + _save_prefs(); +} + +gboolean +prefs_get_chlog(void) +{ + return g_key_file_get_boolean(prefs, "logging", "chlog", NULL); +} + +void +prefs_set_chlog(gboolean value) +{ + g_key_file_set_boolean(prefs, "logging", "chlog", value); + _save_prefs(); +} + +gboolean +prefs_get_history(void) +{ + return g_key_file_get_boolean(prefs, "ui", "history", NULL); +} + +void +prefs_set_history(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "history", value); + _save_prefs(); +} + +gchar * +prefs_get_autoaway_mode(void) +{ + gchar *result = g_key_file_get_string(prefs, "presence", "autoaway.mode", NULL); + if (result == NULL) { + return strdup("off"); + } else { + return result; + } +} + +void +prefs_set_autoaway_mode(gchar *value) +{ + g_key_file_set_string(prefs, "presence", "autoaway.mode", value); + _save_prefs(); +} + +gint +prefs_get_autoaway_time(void) +{ + gint result = g_key_file_get_integer(prefs, "presence", "autoaway.time", NULL); + + if (result == 0) { + return 15; + } else { + return result; + } +} + +void +prefs_set_autoaway_time(gint value) +{ + g_key_file_set_integer(prefs, "presence", "autoaway.time", value); + _save_prefs(); +} + +gchar * +prefs_get_autoaway_message(void) +{ + return g_key_file_get_string(prefs, "presence", "autoaway.message", NULL); +} + +void +prefs_set_autoaway_message(gchar *value) +{ + if (value == NULL) { + g_key_file_remove_key(prefs, "presence", "autoaway.message", NULL); + } else { + g_key_file_set_string(prefs, "presence", "autoaway.message", value); + } + _save_prefs(); +} + +gboolean +prefs_get_autoaway_check(void) +{ + if (g_key_file_has_key(prefs, "presence", "autoaway.check", NULL)) { + return g_key_file_get_boolean(prefs, "presence", "autoaway.check", NULL); + } else { + return TRUE; + } +} + +void +prefs_set_autoaway_check(gboolean value) +{ + g_key_file_set_boolean(prefs, "presence", "autoaway.check", value); + _save_prefs(); +} + +gboolean +prefs_get_splash(void) +{ + return g_key_file_get_boolean(prefs, "ui", "splash", NULL); +} + +void +prefs_set_splash(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "splash", value); + _save_prefs(); +} + +gboolean +prefs_get_mouse(void) +{ + // default to true + if (!g_key_file_has_key(prefs, "ui", "mouse", NULL)) { + return TRUE; + } else { + return g_key_file_get_boolean(prefs, "ui", "mouse", NULL); + } +} + +gboolean +prefs_get_statuses(void) +{ + if (g_key_file_has_key(prefs, "ui", "statuses", NULL)) { + return g_key_file_get_boolean(prefs, "ui", "statuses", NULL); + } else { + return TRUE; + } +} + +void +prefs_set_mouse(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "mouse", value); + _save_prefs(); +} + +void +prefs_set_statuses(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "statuses", value); + _save_prefs(); +} + +static void +_save_prefs(void) +{ + gsize g_data_size; + char *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL); + g_file_set_contents(prefs_loc, g_prefs_data, g_data_size, NULL); +} diff --git a/src/config/preferences.h b/src/config/preferences.h new file mode 100644 index 00000000..a68dc16b --- /dev/null +++ b/src/config/preferences.h @@ -0,0 +1,101 @@ +/* + * preferences.h + * + * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com> + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef PREFERENCES_H +#define PREFERENCES_H + +#include "config.h" + +#include <glib.h> +#ifdef HAVE_NCURSESW_NCURSES_H +#include <ncursesw/ncurses.h> +#elif HAVE_NCURSES_H +#include <ncurses.h> +#endif + +#define PREFS_MIN_LOG_SIZE 64 +#define PREFS_MAX_LOG_SIZE 1048580 + +void prefs_load(void); +void prefs_close(void); + +char * prefs_find_login(char *prefix); +void prefs_reset_login_search(void); +char * prefs_autocomplete_boolean_choice(char *prefix); +void prefs_reset_boolean_choice(void); + +gboolean prefs_get_beep(void); +void prefs_set_beep(gboolean value); +gboolean prefs_get_flash(void); +void prefs_set_flash(gboolean value); +gboolean prefs_get_chlog(void); +void prefs_set_chlog(gboolean value); +gboolean prefs_get_history(void); +void prefs_set_history(gboolean value); +gboolean prefs_get_splash(void); +void prefs_set_splash(gboolean value); +gboolean prefs_get_vercheck(void); +void prefs_set_vercheck(gboolean value); +gboolean prefs_get_titlebarversion(void); +void prefs_set_titlebarversion(gboolean value); +gboolean prefs_get_intype(void); +void prefs_set_intype(gboolean value); +gboolean prefs_get_states(void); +void prefs_set_states(gboolean value); +gboolean prefs_get_outtype(void); +void prefs_set_outtype(gboolean value); +gint prefs_get_gone(void); +void prefs_set_gone(gint value); +gchar * prefs_get_theme(void); +void prefs_set_theme(gchar *value); +gboolean prefs_get_mouse(void); +void prefs_set_mouse(gboolean value); +void prefs_set_statuses(gboolean value); +gboolean prefs_get_statuses(void); + +void prefs_set_notify_message(gboolean value); +gboolean prefs_get_notify_message(void); +void prefs_set_notify_typing(gboolean value); +gboolean prefs_get_notify_typing(void); +void prefs_set_notify_remind(gint period); +gint prefs_get_notify_remind(void); +void prefs_set_max_log_size(gint value); +gint prefs_get_max_log_size(void); +void prefs_set_priority(gint value); +gint prefs_get_priority(void); +void prefs_set_reconnect(gint value); +gint prefs_get_reconnect(void); +void prefs_set_autoping(gint value); +gint prefs_get_autoping(void); + +gchar* prefs_get_autoaway_mode(void); +void prefs_set_autoaway_mode(gchar *value); +gint prefs_get_autoaway_time(void); +void prefs_set_autoaway_time(gint value); +gchar* prefs_get_autoaway_message(void); +void prefs_set_autoaway_message(gchar *value); +gboolean prefs_get_autoaway_check(void); +void prefs_set_autoaway_check(gboolean value); + +void prefs_add_login(const char *jid); + +#endif diff --git a/src/config/theme.c b/src/config/theme.c new file mode 100644 index 00000000..ec061ce4 --- /dev/null +++ b/src/config/theme.c @@ -0,0 +1,360 @@ +/* + * theme.c + * + * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com> + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "config.h" + +#include <stdlib.h> +#include <string.h> + +#include <glib.h> +#ifdef HAVE_NCURSESW_NCURSES_H +#include <ncursesw/ncurses.h> +#elif HAVE_NCURSES_H +#include <ncurses.h> +#endif + +#include "theme.h" + +#include "files.h" +#include "log.h" + +static GString *theme_loc; +static GKeyFile *theme; + +struct colour_string_t { + char *str; + NCURSES_COLOR_T colour; +}; + +static int num_colours = 9; +static struct colour_string_t colours[] = { + { "default", -1 }, + { "white", COLOR_WHITE }, + { "green", COLOR_GREEN }, + { "red", COLOR_RED }, + { "yellow", COLOR_YELLOW }, + { "blue", COLOR_BLUE }, + { "cyan", COLOR_CYAN }, + { "black", COLOR_BLACK }, + { "magenta", COLOR_MAGENTA }, +}; + +// colour preferences +static struct colours_t { + NCURSES_COLOR_T bkgnd; + NCURSES_COLOR_T titlebar; + NCURSES_COLOR_T statusbar; + NCURSES_COLOR_T titlebartext; + NCURSES_COLOR_T titlebarbrackets; + NCURSES_COLOR_T statusbartext; + NCURSES_COLOR_T statusbarbrackets; + NCURSES_COLOR_T statusbaractive; + NCURSES_COLOR_T statusbarnew; + NCURSES_COLOR_T maintext; + NCURSES_COLOR_T inputtext; + NCURSES_COLOR_T timetext; + NCURSES_COLOR_T splashtext; + NCURSES_COLOR_T online; + NCURSES_COLOR_T away; + NCURSES_COLOR_T xa; + NCURSES_COLOR_T dnd; + NCURSES_COLOR_T chat; + NCURSES_COLOR_T offline; + NCURSES_COLOR_T typing; + NCURSES_COLOR_T gone; + NCURSES_COLOR_T error; + NCURSES_COLOR_T incoming; + NCURSES_COLOR_T roominfo; + NCURSES_COLOR_T me; + NCURSES_COLOR_T them; +} colour_prefs; + +static NCURSES_COLOR_T _lookup_colour(const char * const colour); +static void _set_colour(gchar *val, NCURSES_COLOR_T *pref, + NCURSES_COLOR_T def); +static void _load_colours(void); + +void +theme_init(const char * const theme_name) +{ + log_info("Loading theme"); + theme = g_key_file_new(); + + if (theme_name != NULL) { + gchar *themes_dir = files_get_themes_dir(); + theme_loc = g_string_new(themes_dir); + g_free(themes_dir); + g_string_append(theme_loc, "/"); + g_string_append(theme_loc, theme_name); + g_key_file_load_from_file(theme, theme_loc->str, G_KEY_FILE_KEEP_COMMENTS, + NULL); + } + + _load_colours(); +} + +GSList * +theme_list(void) +{ + GSList *result = NULL; + gchar *themes_dir = files_get_themes_dir(); + GDir *themes = g_dir_open(themes_dir, 0, NULL); + if (themes != NULL) { + const gchar *theme = g_dir_read_name(themes); + while (theme != NULL) { + result = g_slist_append(result, strdup(theme)); + theme = g_dir_read_name(themes); + } + + g_dir_close(themes); + return result; + + } else { + return NULL; + } +} + +gboolean +theme_load(const char * const theme_name) +{ + // use default theme + if (strcmp(theme_name, "default") == 0) { + g_key_file_free(theme); + theme = g_key_file_new(); + _load_colours(); + return TRUE; + } else { + gchar *themes_dir = files_get_themes_dir(); + GString *new_theme_file = g_string_new(themes_dir); + g_free(themes_dir); + g_string_append(new_theme_file, "/"); + g_string_append(new_theme_file, theme_name); + + // no theme file found + if (!g_file_test(new_theme_file->str, G_FILE_TEST_EXISTS)) { + log_info("Theme does not exist \"%s\"", theme_name); + g_string_free(new_theme_file, TRUE); + return FALSE; + + // load from theme file + } else { + if (theme_loc != NULL) { + g_string_free(theme_loc, TRUE); + } + theme_loc = new_theme_file; + log_info("Changing theme to \"%s\"", theme_name); + g_key_file_free(theme); + theme = g_key_file_new(); + g_key_file_load_from_file(theme, theme_loc->str, G_KEY_FILE_KEEP_COMMENTS, + NULL); + _load_colours(); + return TRUE; + } + } +} + +void +theme_close(void) +{ + g_key_file_free(theme); + if (theme_loc != NULL) { + g_string_free(theme_loc, TRUE); + } +} + +void +theme_init_colours(void) +{ + // main text + init_pair(1, colour_prefs.maintext, colour_prefs.bkgnd); + init_pair(2, colour_prefs.splashtext, colour_prefs.bkgnd); + init_pair(3, colour_prefs.error, colour_prefs.bkgnd); + init_pair(4, colour_prefs.incoming, colour_prefs.bkgnd); + init_pair(5, colour_prefs.inputtext, colour_prefs.bkgnd); + init_pair(6, colour_prefs.timetext, colour_prefs.bkgnd); + + // title bar + init_pair(10, colour_prefs.titlebartext, colour_prefs.titlebar); + init_pair(11, colour_prefs.titlebarbrackets, colour_prefs.titlebar); + + // status bar + init_pair(20, colour_prefs.statusbartext, colour_prefs.statusbar); + init_pair(21, colour_prefs.statusbarbrackets, colour_prefs.statusbar); + init_pair(22, colour_prefs.statusbaractive, colour_prefs.statusbar); + init_pair(23, colour_prefs.statusbarnew, colour_prefs.statusbar); + + // chat + init_pair(30, colour_prefs.me, colour_prefs.bkgnd); + init_pair(31, colour_prefs.them, colour_prefs.bkgnd); + + // room chat + init_pair(40, colour_prefs.roominfo, colour_prefs.bkgnd); + + // statuses + init_pair(50, colour_prefs.online, colour_prefs.bkgnd); + init_pair(51, colour_prefs.offline, colour_prefs.bkgnd); + init_pair(52, colour_prefs.away, colour_prefs.bkgnd); + init_pair(53, colour_prefs.chat, colour_prefs.bkgnd); + init_pair(54, colour_prefs.dnd, colour_prefs.bkgnd); + init_pair(55, colour_prefs.xa, colour_prefs.bkgnd); + + // states + init_pair(60, colour_prefs.typing, colour_prefs.bkgnd); + init_pair(61, colour_prefs.gone, colour_prefs.bkgnd); +} + +static NCURSES_COLOR_T +_lookup_colour(const char * const colour) +{ + int i; + for (i = 0; i < num_colours; i++) { + if (strcmp(colours[i].str, colour) == 0) { + return colours[i].colour; + } + } + + return -99; +} + +static void +_set_colour(gchar *val, NCURSES_COLOR_T *pref, + NCURSES_COLOR_T def) +{ + if(!val) { + *pref = def; + } else { + NCURSES_COLOR_T col = _lookup_colour(val); + if (col == -99) { + *pref = def; + } else { + *pref = col; + } + } +} + +static void +_load_colours(void) +{ + gchar *bkgnd_val = g_key_file_get_string(theme, "colours", "bkgnd", NULL); + _set_colour(bkgnd_val, &colour_prefs.bkgnd, -1); + g_free(bkgnd_val); + + gchar *titlebar_val = g_key_file_get_string(theme, "colours", "titlebar", NULL); + _set_colour(titlebar_val, &colour_prefs.titlebar, COLOR_BLUE); + g_free(titlebar_val); + + gchar *statusbar_val = g_key_file_get_string(theme, "colours", "statusbar", NULL); + _set_colour(statusbar_val, &colour_prefs.statusbar, COLOR_BLUE); + g_free(statusbar_val); + + gchar *titlebartext_val = g_key_file_get_string(theme, "colours", "titlebar.text", NULL); + _set_colour(titlebartext_val, &colour_prefs.titlebartext, COLOR_WHITE); + g_free(titlebartext_val); + + gchar *titlebarbrackets_val = g_key_file_get_string(theme, "colours", "titlebar.brackets", NULL); + _set_colour(titlebarbrackets_val, &colour_prefs.titlebarbrackets, COLOR_CYAN); + g_free(titlebarbrackets_val); + + gchar *statusbartext_val = g_key_file_get_string(theme, "colours", "statusbar.text", NULL); + _set_colour(statusbartext_val, &colour_prefs.statusbartext, COLOR_WHITE); + g_free(statusbartext_val); + + gchar *statusbarbrackets_val = g_key_file_get_string(theme, "colours", "statusbar.brackets", NULL); + _set_colour(statusbarbrackets_val, &colour_prefs.statusbarbrackets, COLOR_CYAN); + g_free(statusbarbrackets_val); + + gchar *statusbaractive_val = g_key_file_get_string(theme, "colours", "statusbar.active", NULL); + _set_colour(statusbaractive_val, &colour_prefs.statusbaractive, COLOR_CYAN); + g_free(statusbaractive_val); + + gchar *statusbarnew_val = g_key_file_get_string(theme, "colours", "statusbar.new", NULL); + _set_colour(statusbarnew_val, &colour_prefs.statusbarnew, COLOR_WHITE); + g_free(statusbarnew_val); + + gchar *maintext_val = g_key_file_get_string(theme, "colours", "main.text", NULL); + _set_colour(maintext_val, &colour_prefs.maintext, COLOR_WHITE); + g_free(maintext_val); + + gchar *splashtext_val = g_key_file_get_string(theme, "colours", "main.splash", NULL); + _set_colour(splashtext_val, &colour_prefs.splashtext, COLOR_CYAN); + g_free(splashtext_val); + + gchar *inputtext_val = g_key_file_get_string(theme, "colours", "input.text", NULL); + _set_colour(inputtext_val, &colour_prefs.inputtext, COLOR_WHITE); + g_free(inputtext_val); + + gchar *timetext_val = g_key_file_get_string(theme, "colours", "main.time", NULL); + _set_colour(timetext_val, &colour_prefs.timetext, COLOR_WHITE); + g_free(timetext_val); + + gchar *online_val = g_key_file_get_string(theme, "colours", "online", NULL); + _set_colour(online_val, &colour_prefs.online, COLOR_GREEN); + g_free(online_val); + + gchar *away_val = g_key_file_get_string(theme, "colours", "away", NULL); + _set_colour(away_val, &colour_prefs.away, COLOR_CYAN); + g_free(away_val); + + gchar *chat_val = g_key_file_get_string(theme, "colours", "chat", NULL); + _set_colour(chat_val, &colour_prefs.chat, COLOR_GREEN); + g_free(chat_val); + + gchar *dnd_val = g_key_file_get_string(theme, "colours", "dnd", NULL); + _set_colour(dnd_val, &colour_prefs.dnd, COLOR_RED); + g_free(dnd_val); + + gchar *xa_val = g_key_file_get_string(theme, "colours", "xa", NULL); + _set_colour(xa_val, &colour_prefs.xa, COLOR_CYAN); + g_free(xa_val); + + gchar *offline_val = g_key_file_get_string(theme, "colours", "offline", NULL); + _set_colour(offline_val, &colour_prefs.offline, COLOR_RED); + g_free(offline_val); + + gchar *typing_val = g_key_file_get_string(theme, "colours", "typing", NULL); + _set_colour(typing_val, &colour_prefs.typing, COLOR_YELLOW); + g_free(typing_val); + + gchar *gone_val = g_key_file_get_string(theme, "colours", "gone", NULL); + _set_colour(gone_val, &colour_prefs.gone, COLOR_RED); + g_free(gone_val); + + gchar *error_val = g_key_file_get_string(theme, "colours", "error", NULL); + _set_colour(error_val, &colour_prefs.error, COLOR_RED); + g_free(error_val); + + gchar *incoming_val = g_key_file_get_string(theme, "colours", "incoming", NULL); + _set_colour(incoming_val, &colour_prefs.incoming, COLOR_YELLOW); + g_free(incoming_val); + + gchar *roominfo_val = g_key_file_get_string(theme, "colours", "roominfo", NULL); + _set_colour(roominfo_val, &colour_prefs.roominfo, COLOR_YELLOW); + g_free(roominfo_val); + + gchar *me_val = g_key_file_get_string(theme, "colours", "me", NULL); + _set_colour(me_val, &colour_prefs.me, COLOR_YELLOW); + g_free(me_val); + + gchar *them_val = g_key_file_get_string(theme, "colours", "them", NULL); + _set_colour(them_val, &colour_prefs.them, COLOR_GREEN); + g_free(them_val); +} diff --git a/src/config/theme.h b/src/config/theme.h new file mode 100644 index 00000000..d87b69f2 --- /dev/null +++ b/src/config/theme.h @@ -0,0 +1,65 @@ +/* + * theme.h + * + * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com> + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef THEME_H +#define THEME_H + +#include "config.h" + +#include <glib.h> +#ifdef HAVE_NCURSESW_NCURSES_H +#include <ncursesw/ncurses.h> +#elif HAVE_NCURSES_H +#include <ncurses.h> +#endif + +#define COLOUR_TEXT COLOR_PAIR(1) +#define COLOUR_SPLASH COLOR_PAIR(2) +#define COLOUR_ERROR COLOR_PAIR(3) +#define COLOUR_INCOMING COLOR_PAIR(4) +#define COLOUR_INPUT_TEXT COLOR_PAIR(5) +#define COLOUR_TIME COLOR_PAIR(6) +#define COLOUR_TITLE_TEXT COLOR_PAIR(10) +#define COLOUR_TITLE_BRACKET COLOR_PAIR(11) +#define COLOUR_STATUS_TEXT COLOR_PAIR(20) +#define COLOUR_STATUS_BRACKET COLOR_PAIR(21) +#define COLOUR_STATUS_ACTIVE COLOR_PAIR(22) +#define COLOUR_STATUS_NEW COLOR_PAIR(23) +#define COLOUR_ME COLOR_PAIR(30) +#define COLOUR_THEM COLOR_PAIR(31) +#define COLOUR_ROOMINFO COLOR_PAIR(40) +#define COLOUR_ONLINE COLOR_PAIR(50) +#define COLOUR_OFFLINE COLOR_PAIR(51) +#define COLOUR_AWAY COLOR_PAIR(52) +#define COLOUR_CHAT COLOR_PAIR(53) +#define COLOUR_DND COLOR_PAIR(54) +#define COLOUR_XA COLOR_PAIR(55) +#define COLOUR_TYPING COLOR_PAIR(60) +#define COLOUR_GONE COLOR_PAIR(61) + +void theme_init(const char * const theme_name); +void theme_init_colours(void); +gboolean theme_load(const char * const theme_name); +GSList* theme_list(void); +void theme_close(void); + +#endif |