diff options
Diffstat (limited to 'src/core.py')
-rw-r--r-- | src/core.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/core.py b/src/core.py index 0b8442ff..88c926a9 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 @@ -47,6 +47,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 = { @@ -370,13 +371,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'] @@ -394,13 +395,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): @@ -614,7 +615,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 @@ -624,7 +625,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() @@ -686,7 +687,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() @@ -815,9 +816,11 @@ 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() + theming.reload_theme() curses.ungetch(" ") # H4X: without this, the screen is stdscr.getkey() # erased on the first "getkey()" @@ -835,7 +838,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() @@ -883,19 +886,19 @@ 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: - if tab.get_color_state() == theme.COLOR_TAB_DISCONNECTED: + if tab.get_color_state() == get_theme().COLOR_TAB_DISCONNECTED: self.command_win('%s' % tab.nb) return for tab in self.tabs: @@ -1210,9 +1213,7 @@ class Core(object): self.xmpp.plugin['xep_0030'].get_items(jid=server, block=False, callback=list_tab.on_muc_list_item_received) def command_theme(self, arg): - """ - """ - theme.reload_theme() + theming.reload_theme() self.refresh_window() def command_win(self, arg): |