summaryrefslogtreecommitdiff
path: root/poezio/tabs
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-03-14 16:37:01 +0100
committermathieui <mathieui@mathieui.net>2021-04-02 17:44:36 +0200
commit53633a5c4c8097c1cb356e5240be2a925fb8a631 (patch)
treef8fd79048fd19ce1846e28becafbd3b2aa9955b7 /poezio/tabs
parentb2fbb313ef4b88e62d5d41b5cb5862d643424f73 (diff)
downloadpoezio-53633a5c4c8097c1cb356e5240be2a925fb8a631.tar.gz
poezio-53633a5c4c8097c1cb356e5240be2a925fb8a631.tar.bz2
poezio-53633a5c4c8097c1cb356e5240be2a925fb8a631.tar.xz
poezio-53633a5c4c8097c1cb356e5240be2a925fb8a631.zip
refactor: rewrite config.get() to getbool, getstr, getint…
Diffstat (limited to 'poezio/tabs')
-rw-r--r--poezio/tabs/basetabs.py10
-rw-r--r--poezio/tabs/muctab.py20
-rw-r--r--poezio/tabs/privatetab.py2
-rw-r--r--poezio/tabs/rostertab.py4
4 files changed, 18 insertions, 18 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index 4aa6a370..7e584a92 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -143,7 +143,7 @@ class Tab:
Returns 1 or 0, depending on if we are using the vertical tab list
or not.
"""
- if config.get('enable_vertical_tab_list'):
+ if config.getbool('enable_vertical_tab_list'):
return 0
return 1
@@ -332,7 +332,7 @@ class Tab:
return False
def refresh_tab_win(self) -> None:
- if config.get('enable_vertical_tab_list'):
+ if config.getbool('enable_vertical_tab_list'):
left_tab_win = self.core.left_tab_win
if left_tab_win and not self.size.core_degrade_x:
left_tab_win.refresh()
@@ -621,7 +621,7 @@ class ChatTab(Tab):
for word in txt.split():
if len(word) >= 4 and word not in words:
words.append(word)
- words.extend([word for word in config.get('words').split(':') if word])
+ words.extend([word for word in config.getlist('words') if word])
self.input.auto_completion(words, ' ', quotify=False)
def on_enter(self):
@@ -800,8 +800,8 @@ class ChatTab(Tab):
text_buffer = self._text_buffer
built_lines = []
message_count = 0
- timestamp = config.get('show_timestamps')
- nick_size = config.get('max_nick_length')
+ timestamp = config.getbool('show_timestamps')
+ nick_size = config.getint('max_nick_length')
theme = get_theme()
for message in text_buffer.messages:
# Build lines of a message
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index c7d7d621..188ed156 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -433,7 +433,7 @@ class MucTab(ChatTab):
return False
def get_nick(self) -> str:
- if config.get('show_muc_jid'):
+ if config.getbool('show_muc_jid'):
return cast(str, self.jid.bare)
bookmark = self.core.bookmarks[self.jid.bare]
if bookmark is not None and bookmark.name:
@@ -463,7 +463,7 @@ class MucTab(ChatTab):
def on_gain_focus(self) -> None:
self.state = 'current'
if (self.text_win.built_lines and self.text_win.built_lines[-1] is None
- and not config.get('show_useless_separator')):
+ and not config.getbool('show_useless_separator')):
self.text_win.remove_line_separator()
curses.curs_set(1)
if self.joined and config.get_by_tabname(
@@ -1245,7 +1245,7 @@ class MucTab(ChatTab):
Resize the whole window. i.e. all its sub-windows
"""
self.need_resize = False
- if config.get('hide_user_list') or self.size.tab_degrade_x:
+ if config.getbool('hide_user_list') or self.size.tab_degrade_x:
text_width = self.width
else:
text_width = (self.width // 10) * 9
@@ -1280,7 +1280,7 @@ class MucTab(ChatTab):
if self.need_resize:
self.resize()
log.debug(' TAB Refresh: %s', self.__class__.__name__)
- if config.get('hide_user_list') or self.size.tab_degrade_x:
+ if config.getbool('hide_user_list') or self.size.tab_degrade_x:
display_user_list = False
else:
display_user_list = True
@@ -1302,7 +1302,7 @@ class MucTab(ChatTab):
def on_info_win_size_changed(self) -> None:
if self.core.information_win_size >= self.height - 3:
return
- if config.get("hide_user_list"):
+ if config.getbool("hide_user_list"):
text_width = self.width
else:
text_width = (self.width // 10) * 9
@@ -1356,7 +1356,7 @@ class MucTab(ChatTab):
if highlighted and self.joined and not corrected:
if self.state != 'current':
self.state = 'highlight'
- beep_on = cast(str, config.get('beep_on')).split()
+ beep_on = config.getlist('beep_on')
if 'highlight' in beep_on and 'message' not in beep_on:
if not config.get_by_tabname('disable_beep', self.jid.bare):
curses.beep()
@@ -1506,7 +1506,7 @@ class MucTab(ChatTab):
/close [msg]
"""
self.leave_room(msg)
- if config.get('synchronise_open_rooms'):
+ if config.getbool('synchronise_open_rooms'):
if self.jid in self.core.bookmarks:
self.core.bookmarks[self.jid].autojoin = False
asyncio.ensure_future(
@@ -1806,14 +1806,14 @@ class MucTab(ChatTab):
for user in sorted(self.users, key=COMPARE_USERS_LAST_TALKED, reverse=True):
if user.nick != self.own_nick:
word_list.append(user.nick)
- after = cast(str, config.get('after_completion')) + ' '
+ after = config.getstr('after_completion') + ' '
input_pos = self.input.pos
if ' ' not in self.input.get_text()[:input_pos] or (
self.input.last_completion and self.input.get_text()
[:input_pos] == self.input.last_completion + after):
add_after = after
else:
- if not config.get('add_space_after_completion'):
+ if not config.getbool('add_space_after_completion'):
add_after = ''
else:
add_after = ' '
@@ -1850,7 +1850,7 @@ class MucTab(ChatTab):
"""Completion for /nick"""
nicks_list = [
os.environ.get('USER'),
- cast(str, config.get('default_nick')),
+ config.getstr('default_nick'),
self.core.get_bookmark_nickname(self.jid.bare)
]
nicks = [i for i in nicks_list if i]
diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py
index 94a6ad34..9d782df8 100644
--- a/poezio/tabs/privatetab.py
+++ b/poezio/tabs/privatetab.py
@@ -127,7 +127,7 @@ class PrivateTab(OneToOneTab):
compare_users = lambda x: x.last_talked
word_list = [user.nick for user in sorted(self.parent_muc.users, key=compare_users, reverse=True)\
if user.nick != self.own_nick]
- after = config.get('after_completion') + ' '
+ after = config.getstr('after_completion') + ' '
input_pos = self.input.pos
if ' ' not in self.input.get_text()[:input_pos] or (self.input.last_completion and\
self.input.get_text()[:input_pos] == self.input.last_completion + after):
diff --git a/poezio/tabs/rostertab.py b/poezio/tabs/rostertab.py
index 5d2e148c..78843f92 100644
--- a/poezio/tabs/rostertab.py
+++ b/poezio/tabs/rostertab.py
@@ -517,7 +517,7 @@ class RosterInfoTab(Tab):
args[0]
)
self.core.information('Password updated', 'Account')
- if config.get('password'):
+ if config.getstr('password'):
config.silent_set('password', args[0])
except (IqError, IqTimeout):
self.core.information('Unable to change the password',
@@ -868,7 +868,7 @@ class RosterInfoTab(Tab):
Show or hide offline contacts
"""
option = 'roster_show_offline'
- value = config.get(option)
+ value = config.getbool(option)
success = config.silent_set(option, str(not value))
roster.modified()
if not success: