From f40f5cb6c21e69abe6693d7cd22ec934d9177610 Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 15 Nov 2011 23:26:24 +0100 Subject: [PATCH 1/4] Add a wrapper for RawConfigParser.options() in PluginConfig --- src/plugin.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugin.py b/src/plugin.py index 7d1aeb4b..f35bdab1 100644 --- a/src/plugin.py +++ b/src/plugin.py @@ -27,6 +27,13 @@ class PluginConfig(config.Config): if not self.has_section(self.module_name): self.add_section(self.module_name) + def options(self, section=None): + if not section: + section = self.module_name + if not self.has_section(section): + self.add_section(section) + return config.Config.options(self, section) + def write(self): """Write the config to the disk""" try: From 75f7d710801388b2f62deb98968ff8d4d1f0d350 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 16 Nov 2011 09:46:09 +0100 Subject: [PATCH 2/4] Use os.path.expanduser to interpret '~' for _dir config options --- src/core.py | 1 + src/logger.py | 1 + src/plugin_manager.py | 1 + src/theming.py | 1 + 4 files changed, 4 insertions(+) diff --git a/src/core.py b/src/core.py index 311c187d..6bfb4c63 100644 --- a/src/core.py +++ b/src/core.py @@ -1340,6 +1340,7 @@ class Core(object): os.path.join(os.environ.get('XDG_DATA_HOME') or\ os.path.join(os.environ.get('HOME'), '.local', 'share'), 'poezio', 'themes') + themes_dir = os.path.expanduser(themes_dir) try: names = os.listdir(themes_dir) except OSError as e: diff --git a/src/logger.py b/src/logger.py index bd24eb3b..4f6768cf 100644 --- a/src/logger.py +++ b/src/logger.py @@ -16,6 +16,7 @@ import logging log = logging.getLogger(__name__) DATA_HOME = config.get('log_dir', '') or os.path.join(environ.get('XDG_DATA_HOME') or os.path.join(environ.get('HOME'), '.local', 'share'), 'poezio') +DATA_HOME = os.path.expanduser(DATA_HOME) class Logger(object): """ diff --git a/src/plugin_manager.py b/src/plugin_manager.py index e3b786cb..6d3fb05a 100644 --- a/src/plugin_manager.py +++ b/src/plugin_manager.py @@ -10,6 +10,7 @@ plugins_dir = plugins_dir or\ os.path.join(os.environ.get('XDG_DATA_HOME') or\ os.path.join(os.environ.get('HOME'), '.local', 'share'), 'poezio', 'plugins') +plugins_dir = os.path.expanduser(plugins_dir) config_home = os.environ.get("XDG_CONFIG_HOME") if not config_home: diff --git a/src/theming.py b/src/theming.py index 0fe45d59..71aa8b72 100644 --- a/src/theming.py +++ b/src/theming.py @@ -246,6 +246,7 @@ def reload_theme(): os.path.join(os.environ.get('XDG_DATA_HOME') or\ os.path.join(os.environ.get('HOME'), '.local', 'share'), 'poezio', 'themes') + themes_dir = os.path.expanduser(themes_dir) try: os.makedirs(themes_dir) except OSError: From 24ba3b6ed9f2c6aac07056d5a8a481a7286772b8 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 16 Nov 2011 11:25:20 +0100 Subject: [PATCH 3/4] Add CHAR_CHATSTATE_* to the available theme options --- src/theming.py | 6 ++++++ src/windows.py | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/theming.py b/src/theming.py index 71aa8b72..7b653d66 100644 --- a/src/theming.py +++ b/src/theming.py @@ -94,6 +94,12 @@ class Theme(object): # in the user list CHAR_STATUS = '|' + # The characters used for the chatstates in the user list + # in a MUC + CHAR_CHATSTATE_ACTIVE = 'A' + CHAR_CHATSTATE_COMPOSING = 'X' + CHAR_CHATSTATE_PAUSED = 'p' + # Separators COLOR_VERTICAL_SEPARATOR = (4, -1) COLOR_NEW_TEXT_SEPARATOR = (2, -1) diff --git a/src/windows.py b/src/windows.py index 2e2c0fd5..7601208c 100644 --- a/src/windows.py +++ b/src/windows.py @@ -233,11 +233,11 @@ class UserList(Win): else: show_col = self.color_show[user.show]() if user.chatstate == 'composing': - char = 'X' + char = get_theme().CHAR_CHATSTATE_COMPOSING elif user.chatstate == 'active': - char = 'A' + char = get_theme().CHAR_CHATSTATE_ACTIVE elif user.chatstate == 'paused': - char = 'p' + char = get_theme().CHAR_CHATSTATE_PAUSED else: char = get_theme().CHAR_STATUS self.addstr(y, 0, char, to_curses_attr(show_col)) From cae620e3efea2ed3428a8c3076cc8696431723e8 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 16 Nov 2011 13:26:07 +0100 Subject: [PATCH 4/4] Fix plugin status --- plugins/status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/status.py b/plugins/status.py index 7eb27cb5..71b2315d 100644 --- a/plugins/status.py +++ b/plugins/status.py @@ -17,5 +17,5 @@ class Plugin(BasePlugin): '/afk [status message]\nAfk: Set your status as afk (away from keyboard).') self.add_command('away', lambda line: self.core.command_status('away '+line), '/away [status message]\nAway: Set your status as away.') - self.add_command('away', lambda line: self.core.command_status('away '+line), + self.add_command('available', lambda line: self.core.command_status('available '+line), '/available [status message]\nAvailable: Set your status as available.')