diff options
Diffstat (limited to 'src/core.py')
-rw-r--r-- | src/core.py | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/core.py b/src/core.py index 3cdc7592..5e2566ff 100644 --- a/src/core.py +++ b/src/core.py @@ -18,7 +18,7 @@ import traceback from datetime import datetime import common -import theme +import theming import logging import singleton import collections @@ -45,6 +45,7 @@ from roster import Roster, RosterGroup, roster from contact import Contact, Resource from text_buffer import TextBuffer from keyboard import read_char +from theming import get_theme # http://xmpp.org/extensions/xep-0045.html#errorstatus ERROR_AND_STATUS_CODES = { @@ -359,13 +360,13 @@ class Core(object): return # If a resource got offline, display the message in the conversation with this # precise resource. - self.add_information_message_to_conversation_tab(jid.full, '\x195%s is \x191offline' % (resource.get_jid().full)) + self.add_information_message_to_conversation_tab(jid.full, '\x195}%s is \x191}offline' % (resource.get_jid().full)) contact.remove_resource(resource) # Display the message in the conversation with the bare JID only if that was # the only resource online (i.e. now the contact is completely disconnected) if not contact.get_highest_priority_resource(): # No resource left: that was the last one - self.add_information_message_to_conversation_tab(jid.bare, '\x195%s is \x191offline' % (jid.bare)) - self.information('\x193%s \x195is \x191offline' % (resource.get_jid().bare), "Roster") + self.add_information_message_to_conversation_tab(jid.bare, '\x195}%s is \x191}offline' % (jid.bare)) + self.information('\x193}%s \x195}is \x191}offline' % (resource.get_jid().bare), "Roster") def on_got_online(self, presence): jid = presence['from'] @@ -383,13 +384,13 @@ class Core(object): resource.set_status(status_message) resource.set_presence(status) resource.set_priority(priority) - self.add_information_message_to_conversation_tab(jid.full, '\x195%s is \x194online' % (jid.full)) + self.add_information_message_to_conversation_tab(jid.full, '\x195}%s is \x194}online' % (jid.full)) if not contact.get_highest_priority_resource(): # No connected resource yet: the user's just connecting if time.time() - self.connection_time > 12: # We do not display messages if we recently logged in - self.information("\x193%s \x195is \x194online\x195 (\x190%s\x195)" % (resource.get_jid().bare, status), "Roster") - self.add_information_message_to_conversation_tab(jid.bare, '\x195%s is \x194online' % (jid.bare)) + self.information("\x193}%s \x195}is \x194}online\x195} (\x190}%s\x195})" % (resource.get_jid().bare, status), "Roster") + self.add_information_message_to_conversation_tab(jid.bare, '\x195%s is \x194}online' % (jid.bare)) contact.add_resource(resource) def add_information_message_to_conversation_tab(self, jid, msg): @@ -603,7 +604,7 @@ class Core(object): remote_nick = roster.get_contact_by_jid(jid.bare).get_name() or jid.user else: remote_nick = jid.user - conversation.get_room().add_message(body, nickname=remote_nick, nick_color=theme.COLOR_REMOTE_USER) + conversation.get_room().add_message(body, nickname=remote_nick, nick_color=get_theme().COLOR_REMOTE_USER) if conversation.remote_wants_chatstates is None: if message['chat_state']: conversation.remote_wants_chatstates = True @@ -613,7 +614,7 @@ class Core(object): if 'private' in config.get('beep_on', 'highlight private').split(): curses.beep() if self.current_tab() is not conversation: - conversation.set_color_state(theme.COLOR_TAB_PRIVATE) + conversation.set_color_state(get_theme().COLOR_TAB_PRIVATE) self.refresh_tab_win() else: self.refresh_window() @@ -675,7 +676,7 @@ class Core(object): roster.add_contact(contact, jid) roster.edit_groups_of_contact(contact, []) contact.set_ask('asked') - self.get_tab_by_number(0).set_color_state(theme.COLOR_TAB_HIGHLIGHT) + self.get_tab_by_number(0).set_color_state(get_theme().COLOR_TAB_HIGHLIGHT) self.information('%s wants to subscribe to your presence'%jid, 'Roster') if isinstance(self.current_tab(), tabs.RosterInfoTab): self.refresh_window() @@ -804,9 +805,10 @@ class Core(object): curses.noecho() curses.nonl() curses.raw() - theme.init_colors() stdscr.idlok(True) stdscr.keypad(True) + curses.start_color() + curses.use_default_colors() curses.ungetch(" ") # H4X: without this, the screen is stdscr.getkey() # erased on the first "getkey()" @@ -824,7 +826,7 @@ class Core(object): """ Refresh everything """ - self.current_tab().set_color_state(theme.COLOR_TAB_CURRENT) + self.current_tab().set_color_state(get_theme().COLOR_TAB_CURRENT) self.current_tab().refresh() self.doupdate() @@ -872,15 +874,15 @@ class Core(object): - A Muc with any new message """ for tab in self.tabs: - if tab.get_color_state() == theme.COLOR_TAB_PRIVATE: + if tab.get_color_state() == get_theme().COLOR_TAB_PRIVATE: self.command_win('%s' % tab.nb) return for tab in self.tabs: - if tab.get_color_state() == theme.COLOR_TAB_HIGHLIGHT: + if tab.get_color_state() == get_theme().COLOR_TAB_HIGHLIGHT: self.command_win('%s' % tab.nb) return for tab in self.tabs: - if tab.get_color_state() == theme.COLOR_TAB_NEW_MESSAGE: + if tab.get_color_state() == get_theme().COLOR_TAB_NEW_MESSAGE: self.command_win('%s' % tab.nb) return for tab in self.tabs: @@ -1179,7 +1181,7 @@ class Core(object): def command_theme(self, arg): """ """ - theme.reload_theme() + # get_theme().reload_theme() self.refresh_window() def command_win(self, arg): |