about summary refs log tree commit diff stats
path: root/src/preferences.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-11-21 21:24:10 +0000
committerJames Booth <boothj5@gmail.com>2012-11-21 21:24:10 +0000
commite8b2b7196ca3f291cf68592f517a31bff18c8f83 (patch)
treeab4674ecec6a152e0b1b5ddf2091fe94a36df9c1 /src/preferences.c
parent1a909fd6eb2f1ac5fb302c1c164e346fe9050249 (diff)
downloadprofani-tty-e8b2b7196ca3f291cf68592f517a31bff18c8f83.tar.gz
Separated colours from main preferences
Diffstat (limited to 'src/preferences.c')
-rw-r--r--src/preferences.c314
1 files changed, 13 insertions, 301 deletions
diff --git a/src/preferences.c b/src/preferences.c
index 9bfacd88..a44af242 100644
--- a/src/preferences.c
+++ b/src/preferences.c
@@ -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 {
<
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program 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.
#
# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

import os, sys

__all__ = [ x[0:x.index('.')] \
		for x in os.listdir(os.path.dirname(__file__)) \
		if x.startswith('tc_') or x.startswith('bm_')]

def TODO(fnc):
	def result(*arg, **kw):
		try:
			fnc(*arg, **kw)
		except:
			pass # failure expected
	return result

def init():
	sys.path.append(os.path.abspath(os.path.join(sys.path[0], '..')))

class Fake(object):
	def __getattr__(self, attrname):
		val = Fake()
		self.__dict__[attrname] = val
		return val

	def __call__(self, *_, **__):
		return Fake()

	def __clear__(self):
		self.__dict__.clear()

	def __iter__(self):
		return iter(())

class OK(Exception):
	pass

def raise_ok(*_, **__):
	raise OK()
'>-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; -}