1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-10-13 20:13:38 -04:00

Separated colours from main preferences

This commit is contained in:
James Booth 2012-11-21 21:24:10 +00:00
parent 1a909fd6eb
commit e8b2b7196c
7 changed files with 478 additions and 348 deletions

View File

@ -8,7 +8,8 @@ profanity_SOURCES = src/command.c src/contact.c src/history.c src/jabber.h \
src/main.c src/profanity.h src/prof_history.h src/chat_log.c \
src/chat_log.h src/tinyurl.c src/tinyurl.h src/chat_session.c \
src/chat_session.h src/release.c src/release.h src/room_chat.c \
src/room_chat.h src/stanza.c src/stanza.h src/parser.c src/parser.h
src/room_chat.h src/stanza.c src/stanza.h src/parser.c src/parser.h \
src/theme.c src/theme.h
TESTS = tests/testsuite
check_PROGRAMS = tests/testsuite

View File

@ -44,56 +44,6 @@ gint log_maxsize = 0;
static PAutocomplete login_ac;
static PAutocomplete boolean_choice_ac;
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 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);
static void _save_prefs(void);
void
@ -125,8 +75,6 @@ prefs_load(void)
}
free(jids);
_load_colours();
err = NULL;
log_maxsize = g_key_file_get_integer(prefs, "log", "maxsize", &err);
if (err != NULL) {
@ -147,111 +95,6 @@ prefs_close(void)
g_key_file_free(prefs);
}
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(prefs, "colours", "bkgnd", NULL);
_set_colour(bkgnd_val, &colour_prefs.bkgnd, -1);
gchar *titlebar_val = g_key_file_get_string(prefs, "colours", "titlebar", NULL);
_set_colour(titlebar_val, &colour_prefs.titlebar, COLOR_BLUE);
gchar *statusbar_val = g_key_file_get_string(prefs, "colours", "statusbar", NULL);
_set_colour(statusbar_val, &colour_prefs.statusbar, COLOR_BLUE);
gchar *titlebartext_val = g_key_file_get_string(prefs, "colours", "titlebartext", NULL);
_set_colour(titlebartext_val, &colour_prefs.titlebartext, COLOR_WHITE);
gchar *titlebarbrackets_val = g_key_file_get_string(prefs, "colours", "titlebarbrackets", NULL);
_set_colour(titlebarbrackets_val, &colour_prefs.titlebarbrackets, COLOR_CYAN);
gchar *statusbartext_val = g_key_file_get_string(prefs, "colours", "statusbartext", NULL);
_set_colour(statusbartext_val, &colour_prefs.statusbartext, COLOR_WHITE);
gchar *statusbarbrackets_val = g_key_file_get_string(prefs, "colours", "statusbarbrackets", NULL);
_set_colour(statusbarbrackets_val, &colour_prefs.statusbarbrackets, COLOR_CYAN);
gchar *statusbaractive_val = g_key_file_get_string(prefs, "colours", "statusbaractive", NULL);
_set_colour(statusbaractive_val, &colour_prefs.statusbaractive, COLOR_CYAN);
gchar *statusbarnew_val = g_key_file_get_string(prefs, "colours", "statusbarnew", NULL);
_set_colour(statusbarnew_val, &colour_prefs.statusbarnew, COLOR_WHITE);
gchar *maintext_val = g_key_file_get_string(prefs, "colours", "maintext", NULL);
_set_colour(maintext_val, &colour_prefs.maintext, COLOR_WHITE);
gchar *splashtext_val = g_key_file_get_string(prefs, "colours", "splashtext", NULL);
_set_colour(splashtext_val, &colour_prefs.splashtext, COLOR_CYAN);
gchar *online_val = g_key_file_get_string(prefs, "colours", "online", NULL);
_set_colour(online_val, &colour_prefs.online, COLOR_GREEN);
gchar *away_val = g_key_file_get_string(prefs, "colours", "away", NULL);
_set_colour(away_val, &colour_prefs.away, COLOR_CYAN);
gchar *chat_val = g_key_file_get_string(prefs, "colours", "chat", NULL);
_set_colour(chat_val, &colour_prefs.chat, COLOR_GREEN);
gchar *dnd_val = g_key_file_get_string(prefs, "colours", "dnd", NULL);
_set_colour(dnd_val, &colour_prefs.dnd, COLOR_RED);
gchar *xa_val = g_key_file_get_string(prefs, "colours", "xa", NULL);
_set_colour(xa_val, &colour_prefs.xa, COLOR_CYAN);
gchar *offline_val = g_key_file_get_string(prefs, "colours", "offline", NULL);
_set_colour(offline_val, &colour_prefs.offline, COLOR_RED);
gchar *typing_val = g_key_file_get_string(prefs, "colours", "typing", NULL);
_set_colour(typing_val, &colour_prefs.typing, COLOR_YELLOW);
gchar *gone_val = g_key_file_get_string(prefs, "colours", "gone", NULL);
_set_colour(gone_val, &colour_prefs.gone, COLOR_RED);
gchar *error_val = g_key_file_get_string(prefs, "colours", "error", NULL);
_set_colour(error_val, &colour_prefs.error, COLOR_RED);
gchar *incoming_val = g_key_file_get_string(prefs, "colours", "incoming", NULL);
_set_colour(incoming_val, &colour_prefs.incoming, COLOR_YELLOW);
gchar *roominfo_val = g_key_file_get_string(prefs, "colours", "roominfo", NULL);
_set_colour(roominfo_val, &colour_prefs.roominfo, COLOR_YELLOW);
gchar *me_val = g_key_file_get_string(prefs, "colours", "me", NULL);
_set_colour(me_val, &colour_prefs.me, COLOR_YELLOW);
gchar *them_val = g_key_file_get_string(prefs, "colours", "them", NULL);
_set_colour(them_val, &colour_prefs.them, COLOR_GREEN);
}
char *
prefs_find_login(char *prefix)
{
@ -289,6 +132,19 @@ prefs_set_beep(gboolean 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)
{
@ -511,147 +367,3 @@ _save_prefs(void)
char *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
g_file_set_contents(prefs_loc->str, g_prefs_data, g_data_size, NULL);
}
NCURSES_COLOR_T
prefs_get_bkgnd()
{
return colour_prefs.bkgnd;
}
NCURSES_COLOR_T
prefs_get_titlebar()
{
return colour_prefs.titlebar;
}
NCURSES_COLOR_T
prefs_get_statusbar()
{
return colour_prefs.statusbar;
}
NCURSES_COLOR_T
prefs_get_titlebartext()
{
return colour_prefs.titlebartext;
}
NCURSES_COLOR_T
prefs_get_titlebarbrackets()
{
return colour_prefs.titlebarbrackets;
}
NCURSES_COLOR_T
prefs_get_statusbartext()
{
return colour_prefs.statusbartext;
}
NCURSES_COLOR_T
prefs_get_statusbarbrackets()
{
return colour_prefs.statusbarbrackets;
}
NCURSES_COLOR_T
prefs_get_statusbaractive()
{
return colour_prefs.statusbaractive;
}
NCURSES_COLOR_T
prefs_get_statusbarnew()
{
return colour_prefs.statusbarnew;
}
NCURSES_COLOR_T
prefs_get_maintext()
{
return colour_prefs.maintext;
}
NCURSES_COLOR_T
prefs_get_splashtext()
{
return colour_prefs.splashtext;
}
NCURSES_COLOR_T
prefs_get_online()
{
return colour_prefs.online;
}
NCURSES_COLOR_T
prefs_get_away()
{
return colour_prefs.away;
}
NCURSES_COLOR_T
prefs_get_chat()
{
return colour_prefs.chat;
}
NCURSES_COLOR_T
prefs_get_dnd()
{
return colour_prefs.dnd;
}
NCURSES_COLOR_T
prefs_get_xa()
{
return colour_prefs.xa;
}
NCURSES_COLOR_T
prefs_get_offline()
{
return colour_prefs.offline;
}
NCURSES_COLOR_T
prefs_get_typing()
{
return colour_prefs.typing;
}
NCURSES_COLOR_T
prefs_get_gone()
{
return colour_prefs.gone;
}
NCURSES_COLOR_T
prefs_get_error()
{
return colour_prefs.error;
}
NCURSES_COLOR_T
prefs_get_incoming()
{
return colour_prefs.incoming;
}
NCURSES_COLOR_T
prefs_get_roominfo()
{
return colour_prefs.roominfo;
}
NCURSES_COLOR_T
prefs_get_me()
{
return colour_prefs.me;
}
NCURSES_COLOR_T
prefs_get_them()
{
return colour_prefs.them;
}

View File

@ -63,6 +63,8 @@ gboolean prefs_get_states(void);
void prefs_set_states(gboolean value);
gboolean prefs_get_outtype(void);
void prefs_set_outtype(gboolean value);
gchar * prefs_get_theme(void);
void prefs_set_theme(gchar *value);
void prefs_set_notify_message(gboolean value);
gboolean prefs_get_notify_message(void);
@ -77,29 +79,4 @@ gint prefs_get_priority(void);
void prefs_add_login(const char *jid);
NCURSES_COLOR_T prefs_get_bkgnd();
NCURSES_COLOR_T prefs_get_titlebar();
NCURSES_COLOR_T prefs_get_statusbar();
NCURSES_COLOR_T prefs_get_titlebartext();
NCURSES_COLOR_T prefs_get_titlebarbrackets();
NCURSES_COLOR_T prefs_get_statusbartext();
NCURSES_COLOR_T prefs_get_statusbarbrackets();
NCURSES_COLOR_T prefs_get_statusbaractive();
NCURSES_COLOR_T prefs_get_statusbarnew();
NCURSES_COLOR_T prefs_get_maintext();
NCURSES_COLOR_T prefs_get_splashtext();
NCURSES_COLOR_T prefs_get_online();
NCURSES_COLOR_T prefs_get_away();
NCURSES_COLOR_T prefs_get_chat();
NCURSES_COLOR_T prefs_get_dnd();
NCURSES_COLOR_T prefs_get_xa();
NCURSES_COLOR_T prefs_get_offline();
NCURSES_COLOR_T prefs_get_typing();
NCURSES_COLOR_T prefs_get_gone();
NCURSES_COLOR_T prefs_get_error();
NCURSES_COLOR_T prefs_get_incoming();
NCURSES_COLOR_T prefs_get_roominfo();
NCURSES_COLOR_T prefs_get_me();
NCURSES_COLOR_T prefs_get_them();
#endif

View File

@ -39,6 +39,7 @@
#include "preferences.h"
#include "profanity.h"
#include "room_chat.h"
#include "theme.h"
#include "jabber.h"
#include "ui.h"
@ -446,6 +447,7 @@ _init(const int disable_tls, char *log_level)
log_info("Starting Profanity (%s)...", PACKAGE_VERSION);
chat_log_init();
prefs_load();
theme_load(prefs_get_theme());
gui_init();
jabber_init(disable_tls);
cmd_init();
@ -462,6 +464,7 @@ _shutdown(void)
gui_close();
chat_log_close();
prefs_close();
theme_close();
cmd_close();
log_close();
}

371
src/theme.c Normal file
View File

@ -0,0 +1,371 @@
/*
* theme.c
*
* Copyright (C) 2012 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_NCURSES_H
#include <ncurses.h>
#endif
#ifdef HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#endif
#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 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_load(const char * const theme_name)
{
log_info("Loading theme");
theme = g_key_file_new();
if (theme_name != NULL) {
theme_loc = g_string_new(getenv("HOME"));
g_string_append(theme_loc, "/.profanity/themes/");
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();
}
void
theme_close(void)
{
g_key_file_free(theme);
}
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);
gchar *titlebar_val = g_key_file_get_string(theme, "colours", "titlebar", NULL);
_set_colour(titlebar_val, &colour_prefs.titlebar, COLOR_BLUE);
gchar *statusbar_val = g_key_file_get_string(theme, "colours", "statusbar", NULL);
_set_colour(statusbar_val, &colour_prefs.statusbar, COLOR_BLUE);
gchar *titlebartext_val = g_key_file_get_string(theme, "colours", "titlebartext", NULL);
_set_colour(titlebartext_val, &colour_prefs.titlebartext, COLOR_WHITE);
gchar *titlebarbrackets_val = g_key_file_get_string(theme, "colours", "titlebarbrackets", NULL);
_set_colour(titlebarbrackets_val, &colour_prefs.titlebarbrackets, COLOR_CYAN);
gchar *statusbartext_val = g_key_file_get_string(theme, "colours", "statusbartext", NULL);
_set_colour(statusbartext_val, &colour_prefs.statusbartext, COLOR_WHITE);
gchar *statusbarbrackets_val = g_key_file_get_string(theme, "colours", "statusbarbrackets", NULL);
_set_colour(statusbarbrackets_val, &colour_prefs.statusbarbrackets, COLOR_CYAN);
gchar *statusbaractive_val = g_key_file_get_string(theme, "colours", "statusbaractive", NULL);
_set_colour(statusbaractive_val, &colour_prefs.statusbaractive, COLOR_CYAN);
gchar *statusbarnew_val = g_key_file_get_string(theme, "colours", "statusbarnew", NULL);
_set_colour(statusbarnew_val, &colour_prefs.statusbarnew, COLOR_WHITE);
gchar *maintext_val = g_key_file_get_string(theme, "colours", "maintext", NULL);
_set_colour(maintext_val, &colour_prefs.maintext, COLOR_WHITE);
gchar *splashtext_val = g_key_file_get_string(theme, "colours", "splashtext", NULL);
_set_colour(splashtext_val, &colour_prefs.splashtext, COLOR_CYAN);
gchar *online_val = g_key_file_get_string(theme, "colours", "online", NULL);
_set_colour(online_val, &colour_prefs.online, COLOR_GREEN);
gchar *away_val = g_key_file_get_string(theme, "colours", "away", NULL);
_set_colour(away_val, &colour_prefs.away, COLOR_CYAN);
gchar *chat_val = g_key_file_get_string(theme, "colours", "chat", NULL);
_set_colour(chat_val, &colour_prefs.chat, COLOR_GREEN);
gchar *dnd_val = g_key_file_get_string(theme, "colours", "dnd", NULL);
_set_colour(dnd_val, &colour_prefs.dnd, COLOR_RED);
gchar *xa_val = g_key_file_get_string(theme, "colours", "xa", NULL);
_set_colour(xa_val, &colour_prefs.xa, COLOR_CYAN);
gchar *offline_val = g_key_file_get_string(theme, "colours", "offline", NULL);
_set_colour(offline_val, &colour_prefs.offline, COLOR_RED);
gchar *typing_val = g_key_file_get_string(theme, "colours", "typing", NULL);
_set_colour(typing_val, &colour_prefs.typing, COLOR_YELLOW);
gchar *gone_val = g_key_file_get_string(theme, "colours", "gone", NULL);
_set_colour(gone_val, &colour_prefs.gone, COLOR_RED);
gchar *error_val = g_key_file_get_string(theme, "colours", "error", NULL);
_set_colour(error_val, &colour_prefs.error, COLOR_RED);
gchar *incoming_val = g_key_file_get_string(theme, "colours", "incoming", NULL);
_set_colour(incoming_val, &colour_prefs.incoming, COLOR_YELLOW);
gchar *roominfo_val = g_key_file_get_string(theme, "colours", "roominfo", NULL);
_set_colour(roominfo_val, &colour_prefs.roominfo, COLOR_YELLOW);
gchar *me_val = g_key_file_get_string(theme, "colours", "me", NULL);
_set_colour(me_val, &colour_prefs.me, COLOR_YELLOW);
gchar *them_val = g_key_file_get_string(theme, "colours", "them", NULL);
_set_colour(them_val, &colour_prefs.them, COLOR_GREEN);
}
/*
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->str, g_prefs_data, g_data_size, NULL);
}
*/
NCURSES_COLOR_T
theme_get_bkgnd()
{
return colour_prefs.bkgnd;
}
NCURSES_COLOR_T
theme_get_titlebar()
{
return colour_prefs.titlebar;
}
NCURSES_COLOR_T
theme_get_statusbar()
{
return colour_prefs.statusbar;
}
NCURSES_COLOR_T
theme_get_titlebartext()
{
return colour_prefs.titlebartext;
}
NCURSES_COLOR_T
theme_get_titlebarbrackets()
{
return colour_prefs.titlebarbrackets;
}
NCURSES_COLOR_T
theme_get_statusbartext()
{
return colour_prefs.statusbartext;
}
NCURSES_COLOR_T
theme_get_statusbarbrackets()
{
return colour_prefs.statusbarbrackets;
}
NCURSES_COLOR_T
theme_get_statusbaractive()
{
return colour_prefs.statusbaractive;
}
NCURSES_COLOR_T
theme_get_statusbarnew()
{
return colour_prefs.statusbarnew;
}
NCURSES_COLOR_T
theme_get_maintext()
{
return colour_prefs.maintext;
}
NCURSES_COLOR_T
theme_get_splashtext()
{
return colour_prefs.splashtext;
}
NCURSES_COLOR_T
theme_get_online()
{
return colour_prefs.online;
}
NCURSES_COLOR_T
theme_get_away()
{
return colour_prefs.away;
}
NCURSES_COLOR_T
theme_get_chat()
{
return colour_prefs.chat;
}
NCURSES_COLOR_T
theme_get_dnd()
{
return colour_prefs.dnd;
}
NCURSES_COLOR_T
theme_get_xa()
{
return colour_prefs.xa;
}
NCURSES_COLOR_T
theme_get_offline()
{
return colour_prefs.offline;
}
NCURSES_COLOR_T
theme_get_typing()
{
return colour_prefs.typing;
}
NCURSES_COLOR_T
theme_get_gone()
{
return colour_prefs.gone;
}
NCURSES_COLOR_T
theme_get_error()
{
return colour_prefs.error;
}
NCURSES_COLOR_T
theme_get_incoming()
{
return colour_prefs.incoming;
}
NCURSES_COLOR_T
theme_get_roominfo()
{
return colour_prefs.roominfo;
}
NCURSES_COLOR_T
theme_get_me()
{
return colour_prefs.me;
}
NCURSES_COLOR_T
theme_get_them()
{
return colour_prefs.them;
}

65
src/theme.h Normal file
View File

@ -0,0 +1,65 @@
/*
* theme.h
*
* Copyright (C) 2012 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_NCURSES_H
#include <ncurses.h>
#endif
#ifdef HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#endif
void theme_load(const char * const theme_name);
void theme_close(void);
NCURSES_COLOR_T theme_get_bkgnd();
NCURSES_COLOR_T theme_get_titlebar();
NCURSES_COLOR_T theme_get_statusbar();
NCURSES_COLOR_T theme_get_titlebartext();
NCURSES_COLOR_T theme_get_titlebarbrackets();
NCURSES_COLOR_T theme_get_statusbartext();
NCURSES_COLOR_T theme_get_statusbarbrackets();
NCURSES_COLOR_T theme_get_statusbaractive();
NCURSES_COLOR_T theme_get_statusbarnew();
NCURSES_COLOR_T theme_get_maintext();
NCURSES_COLOR_T theme_get_splashtext();
NCURSES_COLOR_T theme_get_online();
NCURSES_COLOR_T theme_get_away();
NCURSES_COLOR_T theme_get_chat();
NCURSES_COLOR_T theme_get_dnd();
NCURSES_COLOR_T theme_get_xa();
NCURSES_COLOR_T theme_get_offline();
NCURSES_COLOR_T theme_get_typing();
NCURSES_COLOR_T theme_get_gone();
NCURSES_COLOR_T theme_get_error();
NCURSES_COLOR_T theme_get_incoming();
NCURSES_COLOR_T theme_get_roominfo();
NCURSES_COLOR_T theme_get_me();
NCURSES_COLOR_T theme_get_them();
#endif

View File

@ -45,6 +45,7 @@
#include "preferences.h"
#include "release.h"
#include "room_chat.h"
#include "theme.h"
#include "ui.h"
#define CONS_WIN_TITLE "_cons"
@ -113,39 +114,39 @@ gui_init(void)
start_color();
// main text
init_pair(1, prefs_get_maintext(), prefs_get_bkgnd());
init_pair(2, prefs_get_splashtext(), prefs_get_bkgnd());
init_pair(3, prefs_get_error(), prefs_get_bkgnd());
init_pair(4, prefs_get_incoming(), prefs_get_bkgnd());
init_pair(1, theme_get_maintext(), theme_get_bkgnd());
init_pair(2, theme_get_splashtext(), theme_get_bkgnd());
init_pair(3, theme_get_error(), theme_get_bkgnd());
init_pair(4, theme_get_incoming(), theme_get_bkgnd());
// title bar
init_pair(10, prefs_get_titlebartext(), prefs_get_titlebar());
init_pair(11, prefs_get_titlebarbrackets(), prefs_get_titlebar());
init_pair(10, theme_get_titlebartext(), theme_get_titlebar());
init_pair(11, theme_get_titlebarbrackets(), theme_get_titlebar());
// status bar
init_pair(20, prefs_get_statusbartext(), prefs_get_statusbar());
init_pair(21, prefs_get_statusbarbrackets(), prefs_get_statusbar());
init_pair(22, prefs_get_statusbaractive(), prefs_get_statusbar());
init_pair(23, prefs_get_statusbarnew(), prefs_get_statusbar());
init_pair(20, theme_get_statusbartext(), theme_get_statusbar());
init_pair(21, theme_get_statusbarbrackets(), theme_get_statusbar());
init_pair(22, theme_get_statusbaractive(), theme_get_statusbar());
init_pair(23, theme_get_statusbarnew(), theme_get_statusbar());
// chat
init_pair(30, prefs_get_me(), prefs_get_bkgnd());
init_pair(31, prefs_get_them(), prefs_get_bkgnd());
init_pair(30, theme_get_me(), theme_get_bkgnd());
init_pair(31, theme_get_them(), theme_get_bkgnd());
// room chat
init_pair(40, prefs_get_roominfo(), prefs_get_bkgnd());
init_pair(40, theme_get_roominfo(), theme_get_bkgnd());
// statuses
init_pair(50, prefs_get_online(), prefs_get_bkgnd());
init_pair(51, prefs_get_offline(), prefs_get_bkgnd());
init_pair(52, prefs_get_away(), prefs_get_bkgnd());
init_pair(53, prefs_get_chat(), prefs_get_bkgnd());
init_pair(54, prefs_get_dnd(), prefs_get_bkgnd());
init_pair(55, prefs_get_xa(), prefs_get_bkgnd());
init_pair(50, theme_get_online(), theme_get_bkgnd());
init_pair(51, theme_get_offline(), theme_get_bkgnd());
init_pair(52, theme_get_away(), theme_get_bkgnd());
init_pair(53, theme_get_chat(), theme_get_bkgnd());
init_pair(54, theme_get_dnd(), theme_get_bkgnd());
init_pair(55, theme_get_xa(), theme_get_bkgnd());
// states
init_pair(60, prefs_get_typing(), prefs_get_bkgnd());
init_pair(61, prefs_get_gone(), prefs_get_bkgnd());
init_pair(60, theme_get_typing(), theme_get_bkgnd());
init_pair(61, theme_get_gone(), theme_get_bkgnd());
}
refresh();