From 19135d4a76790c0675529eaa7591b326e631d8e6 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 31 Jul 2013 23:43:19 +0200 Subject: Fix #2306 (none, to, and from subscriptions should be more visible) Added a configuration option and some theme variables. --- doc/source/configuration.rst | 11 +++++++++++ src/theming.py | 20 ++++++++++++++++++++ src/windows.py | 7 +++++++ 3 files changed, 38 insertions(+) diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 587d5fd2..9f568200 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -606,6 +606,17 @@ section of this documentation. Show s2s errors in the roster or not. + show_roster_subscriptions + + **Defalt value:** ``[empty]`` + + Select the level of display of subscriptions with a char the roster + + - ``all`` to display all subscriptions + - ``incomplete`` to display *from*, *to* and *none* + - one of ``from``, ``to``, ``none`` and ``both`` to display only that one + - no value or any other value to disable it + show_tab_names **Default value:** ``false`` diff --git a/src/theming.py b/src/theming.py index c999ef2c..975da92a 100644 --- a/src/theming.py +++ b/src/theming.py @@ -112,6 +112,20 @@ class Theme(object): } return show_mapping.get(show, cls.COLOR_STATUS_NONE) + @classmethod + def char_subscription(cls, sub, keep='incomplete'): + sub_mapping = { + 'from': cls.CHAR_ROSTER_FROM, + 'both': cls.CHAR_ROSTER_BOTH, + 'none': cls.CHAR_ROSTER_NONE, + 'to': cls.CHAR_ROSTER_TO, + } + if keep == 'incomplete' and sub == 'both': + return '' + if keep in ('both', 'none', 'to', 'from'): + return sub_mapping[sub] if sub == keep else '' + return sub_mapping.get(sub, '') + # Message text color COLOR_NORMAL_TEXT = (-1, -1) COLOR_INFORMATION_TEXT = (5, -1) # TODO @@ -243,12 +257,18 @@ class Theme(object): CHAR_ROSTER_ACTIVITY = '☃' CHAR_ROSTER_MOOD = '☺' CHAR_ROSTER_GAMING = '♠' + CHAR_ROSTER_FROM = '←' + CHAR_ROSTER_BOTH = '↔' + CHAR_ROSTER_TO = '→' + CHAR_ROSTER_NONE = '⇹' COLOR_ROSTER_GAMING = (6, -1) COLOR_ROSTER_MOOD = (2, -1) COLOR_ROSTER_ACTIVITY = (3, -1) COLOR_ROSTER_TUNE = (6, -1) COLOR_ROSTER_ERROR = (1, -1) + COLOR_ROSTER_SUBSCRIPTION = (-1, -1) + COLOR_JOIN_CHAR = (4, -1) COLOR_QUIT_CHAR = (1, -1) COLOR_KICK_CHAR = (1, -1) diff --git a/src/windows.py b/src/windows.py index 0a31deed..6ee9fbfb 100644 --- a/src/windows.py +++ b/src/windows.py @@ -1974,6 +1974,8 @@ class RosterWin(Win): self.addstr(y, 0, ' ') self.addstr(theme.CHAR_STATUS, to_curses_attr(color)) + show_roster_sub = config.getl('show_roster_subscriptions', '') + self.addstr(' ') if resource: self.addstr('[+] ' if contact.folded(group) else '[-] ') @@ -1990,6 +1992,8 @@ class RosterWin(Win): added += len(get_theme().CHAR_ROSTER_ACTIVITY) if contact.gaming: added += len(get_theme().CHAR_ROSTER_GAMING) + if show_roster_sub in ('all', 'incomplete', 'to', 'from', 'both', 'none'): + added += len(theme.char_subscription(contact.subscription, keep=show_roster_sub)) if config.getl('show_roster_jids', 'true') == 'false' and contact.name: display_name = '%s' % contact.name @@ -2004,6 +2008,9 @@ class RosterWin(Win): self.addstr(display_name, to_curses_attr(get_theme().COLOR_SELECTED_ROW)) else: self.addstr(display_name) + + if show_roster_sub in ('all', 'incomplete', 'to', 'from', 'both', 'none'): + self.addstr(theme.char_subscription(contact.subscription, keep=show_roster_sub), to_curses_attr(theme.COLOR_ROSTER_SUBSCRIPTION)) if contact.ask: self.addstr(get_theme().CHAR_ROSTER_ASKED, to_curses_attr(get_theme().COLOR_IMPORTANT_TEXT)) if config.get('show_s2s_errors', 'true').lower() == 'true' and contact.error: -- cgit v1.2.3