summaryrefslogtreecommitdiff
path: root/poezio/windows/roster_win.py
diff options
context:
space:
mode:
Diffstat (limited to 'poezio/windows/roster_win.py')
-rw-r--r--poezio/windows/roster_win.py71
1 files changed, 12 insertions, 59 deletions
diff --git a/poezio/windows/roster_win.py b/poezio/windows/roster_win.py
index 2efdd324..dfdc9b9b 100644
--- a/poezio/windows/roster_win.py
+++ b/poezio/windows/roster_win.py
@@ -6,11 +6,10 @@ import logging
log = logging.getLogger(__name__)
from datetime import datetime
-from typing import Optional, List, Union, Dict
+from typing import Optional, List, Union
from poezio.windows.base_wins import Win
-from poezio import common
from poezio.config import config
from poezio.contact import Contact, Resource
from poezio.roster import Roster, RosterGroup
@@ -26,8 +25,8 @@ class RosterWin(Win):
Win.__init__(self)
self.pos = 0 # cursor position in the contact list
self.start_pos = 1 # position of the start of the display
- self.selected_row = None # type: Optional[Row]
- self.roster_cache = [] # type: List[Row]
+ self.selected_row: Optional[Row] = None
+ self.roster_cache: List[Row] = []
@property
def roster_len(self) -> int:
@@ -99,13 +98,13 @@ class RosterWin(Win):
# This is a search
if roster.contact_filter is not roster.DEFAULT_FILTER:
self.roster_cache = []
- sort = config.get('roster_sort', 'jid:show') or 'jid:show'
+ sort = config.getstr('roster_sort') or 'jid:show'
for contact in roster.get_contacts_sorted_filtered(sort):
self.roster_cache.append(contact)
else:
- show_offline = config.get('roster_show_offline')
- sort = config.get('roster_sort') or 'jid:show'
- group_sort = config.get('roster_group_sort') or 'name'
+ show_offline = config.getbool('roster_show_offline')
+ sort = config.getstr('roster_sort') or 'jid:show'
+ group_sort = config.getstr('roster_group_sort') or 'name'
self.roster_cache = []
# build the cache
for group in roster.get_groups(group_sort):
@@ -155,9 +154,9 @@ class RosterWin(Win):
self.height]
options = {
- 'show_roster_sub': config.get('show_roster_subscriptions'),
- 'show_s2s_errors': config.get('show_s2s_errors'),
- 'show_roster_jids': config.get('show_roster_jids')
+ 'show_roster_sub': config.getbool('show_roster_subscriptions'),
+ 'show_s2s_errors': config.getbool('show_s2s_errors'),
+ 'show_roster_jids': config.getbool('show_roster_jids')
}
for item in roster_view:
@@ -171,7 +170,7 @@ class RosterWin(Win):
group = item.name
elif isinstance(item, Contact):
self.draw_contact_line(y, item, draw_selected, group,
- **options)
+ **options) # type: ignore
elif isinstance(item, Resource):
self.draw_resource_line(y, item, draw_selected)
@@ -268,14 +267,6 @@ class RosterWin(Win):
added += len(theme.CHAR_ROSTER_ASKED)
if show_s2s_errors and contact.error:
added += len(theme.CHAR_ROSTER_ERROR)
- if contact.tune:
- added += len(theme.CHAR_ROSTER_TUNE)
- if contact.mood:
- added += len(theme.CHAR_ROSTER_MOOD)
- if contact.activity:
- added += len(theme.CHAR_ROSTER_ACTIVITY)
- if contact.gaming:
- added += len(theme.CHAR_ROSTER_GAMING)
if show_roster_sub in ('all', 'incomplete', 'to', 'from', 'both',
'none'):
added += len(
@@ -287,7 +278,7 @@ class RosterWin(Win):
elif contact.name and contact.name != contact.bare_jid:
display_name = '%s (%s)' % (contact.name, contact.bare_jid)
else:
- display_name = contact.bare_jid
+ display_name = str(contact.bare_jid)
display_name = self.truncate_name(display_name, added) + nb
@@ -309,18 +300,6 @@ class RosterWin(Win):
if show_s2s_errors and contact.error:
self.addstr(theme.CHAR_ROSTER_ERROR,
to_curses_attr(theme.COLOR_ROSTER_ERROR))
- if contact.tune:
- self.addstr(theme.CHAR_ROSTER_TUNE,
- to_curses_attr(theme.COLOR_ROSTER_TUNE))
- if contact.activity:
- self.addstr(theme.CHAR_ROSTER_ACTIVITY,
- to_curses_attr(theme.COLOR_ROSTER_ACTIVITY))
- if contact.mood:
- self.addstr(theme.CHAR_ROSTER_MOOD,
- to_curses_attr(theme.COLOR_ROSTER_MOOD))
- if contact.gaming:
- self.addstr(theme.CHAR_ROSTER_GAMING,
- to_curses_attr(theme.COLOR_ROSTER_GAMING))
self.finish_line()
def draw_resource_line(self, y: int, resource: Resource, colored: bool) -> None:
@@ -394,32 +373,6 @@ class ContactInfoWin(Win):
self.finish_line()
i += 1
- if contact.tune:
- self.addstr(i, 0,
- 'Tune: %s' % common.format_tune_string(contact.tune),
- to_curses_attr(theme.COLOR_NORMAL_TEXT))
- self.finish_line()
- i += 1
-
- if contact.mood:
- self.addstr(i, 0, 'Mood: %s' % contact.mood,
- to_curses_attr(theme.COLOR_NORMAL_TEXT))
- self.finish_line()
- i += 1
-
- if contact.activity:
- self.addstr(i, 0, 'Activity: %s' % contact.activity,
- to_curses_attr(theme.COLOR_NORMAL_TEXT))
- self.finish_line()
- i += 1
-
- if contact.gaming:
- self.addstr(
- i, 0, 'Game: %s' % common.format_gaming_string(contact.gaming),
- to_curses_attr(theme.COLOR_NORMAL_TEXT))
- self.finish_line()
- i += 1
-
def draw_group_info(self, group: RosterGroup) -> None:
"""
draw the group information