diff --git a/Makefile b/Makefile index a739002ec..7468b4118 100644 --- a/Makefile +++ b/Makefile @@ -155,5 +155,11 @@ tags: -rm tags exuberant-ctags -R +sloccount: + if test -n "`which sloccount`"; then\ + sloccount ./src;\ + sloccount --cached --details ./src;\ + fi + .PHONY: all translation trayicon gtkspell idle clean dist install help\ - uninstall tags + uninstall tags sloccount diff --git a/src/chat_control.py b/src/chat_control.py index 0fdeb4949..4b8500bd4 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -744,9 +744,8 @@ class ChatControl(ChatControlBase): ChatControlBase.draw_widgets(self) def _update_banner_state_image(self): - # FIXME: The cyling of contact_list ... is this necessary if I have the contact - # This will need to be triumphant when sending directly to a resource - contact = self.contact + contact = gajim.contacts.get_contact_with_highest_priority(self.account, + self.contact.jid) show = contact.show jid = contact.jid @@ -1030,7 +1029,9 @@ class ChatControl(ChatControlBase): if num_unread and gajim.config.get('show_unread_tab_icon'): tab_img = img_16['message'] else: - tab_img = img_16[self.contact.show] + contact = gajim.contacts.get_contact_with_highest_priority(self.account, + self.contact.jid) + tab_img = img_16[contact.show] return tab_img @@ -1407,7 +1408,6 @@ class ChatControl(ChatControlBase): gajim.interface.roster.on_info(widget, self.contact, self.account) def on_toggle_gpg_menuitem_activate(self, widget): - print "toggling" jid = self.get_active_jid() tb = self.xml.get_widget('gpg_togglebutton') tb.set_active(not tb.get_active()) diff --git a/src/common/contacts.py b/src/common/contacts.py index 29c2869ff..03fa0d6a5 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -99,6 +99,7 @@ class Contacts: def create_contact(self, jid='', name='', groups=[], show='', status='', sub='', ask='', resource='', priority=5, keyID='', our_chatstate=None, chatstate=None): + print "Creating contact:", jid return Contact(jid, name, groups, show, status, sub, ask, resource, priority, keyID, our_chatstate, chatstate) @@ -110,6 +111,7 @@ class Contacts: our_chatstate = contact.our_chatstate, chatstate = contact.chatstate) def add_contact(self, account, contact): + print "Adding contact:", contact.jid # No such account before ? if not self._contacts.has_key(account): self._contacts[account] = {contact.jid : [contact]} @@ -130,6 +132,7 @@ class Contacts: contacts.append(contact) def remove_contact(self, account, contact): + print "Removing contact:", contact.jid if not self._contacts.has_key(account): return if not self._contacts[account].has_key(contact.jid): @@ -138,6 +141,7 @@ class Contacts: self._contacts[account][contact.jid].remove(contact) def remove_jid(self, account, jid): + print "Adding jid:", jid '''Removes all contacts for a given jid''' if not self._contacts.has_key(account): return @@ -165,7 +169,7 @@ class Contacts: def get_contacts_from_jid(self, account, jid): ''' we may have two or more resources on that jid ''' - if jid in self._contacts[account]: + if jid in self._contacts[account].keys(): contacts_instances = self._contacts[account][jid] return contacts_instances return [] @@ -175,12 +179,14 @@ class Contacts: return None prim_contact = contacts[0] for contact in contacts[1:]: + print "checking priority of", contact.jid if int(contact.priority) > int(prim_contact.priority): prim_contact = contact return prim_contact def get_contact_with_highest_priority(self, account, jid): contacts = self.get_contacts_from_jid(account, jid) + print "contacts:", contacts return self.get_highest_prio_contact_from_contacts(contacts) def get_first_contact_from_jid(self, account, jid): @@ -235,10 +241,12 @@ class Contacts: def create_gc_contact(self, room_jid='', name='', show='', status='', role='', affiliation='', jid='', resource=''): + print "Creating GC contact:", room_jid, jid return GC_Contact(room_jid, name, show, status, role, affiliation, jid, resource) def add_gc_contact(self, account, gc_contact): + print "Adding GC contact:", gc_contact.room_jid # No such account before ? if not self._gc_contacts.has_key(account): self._contacts[account] = {gc_contact.room_jid : {gc_contact.name: \ @@ -253,6 +261,7 @@ class Contacts: gc_contact def remove_gc_contact(self, account, gc_contact): + print "Adding GC contact:", gc_contact.room_jid if not self._gc_contacts.has_key(account): return if not self._gc_contacts[account].has_key(gc_contact.room_jid): @@ -266,6 +275,7 @@ class Contacts: del self._gc_contacts[account][gc_contact.room_jid] def remove_room(self, account, room_jid): + print "Removing room:", room_jid if not self._gc_contacts.has_key(account): return if not self._gc_contacts[account].has_key(room_jid): diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 43d62d8b7..d361152f4 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -560,7 +560,6 @@ class GroupchatControl(ChatControlBase): def draw_roster(self): model = self.list_treeview.get_model() model.clear() - print "draw_roster" for nick in gajim.contacts.get_nick_list(self.account, self.room_jid): gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) self.add_contact_to_roster(nick, gc_contact.show, gc_contact.role, diff --git a/src/message_window.py b/src/message_window.py index 3a4b2df82..ea39d3561 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -381,9 +381,9 @@ class MessageWindow: def popup_menu(self, event): menu = self.get_active_control().prepare_context_menu() # common menuitems (tab switches) - if len(self.controls) > 1: # if there is more than one tab + if len(self._controls) > 1: # if there is more than one tab menu.append(gtk.SeparatorMenuItem()) # seperator - for ctl in self.controls.values(): + for ctl in self._controls.values(): jid = ctl.contact.jid if jid != self.get_active_jid(): item = gtk.ImageMenuItem(_('Switch to %s') %\ diff --git a/src/roster_window.py b/src/roster_window.py index b0c5c7bc2..450b550c5 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -169,9 +169,9 @@ class RosterWindow: if hide: return if contact.show in ('offline', 'error') and \ - not showOffline and (not _('Transports') in contact.groups or \ - gajim.connections[account].connected < 2) and \ - not gajim.awaiting_events[account].has_key(jid): + not showOffline and (not _('Transports') in contact.groups or \ + gajim.connections[account].connected < 2) and \ + not gajim.awaiting_events[account].has_key(jid): return model = self.tree.get_model() @@ -431,8 +431,8 @@ class RosterWindow: '''create the main window's menus''' new_message_menuitem = self.xml.get_widget('new_message_menuitem') join_gc_menuitem = self.xml.get_widget('join_gc_menuitem') - add_new_contact_menuitem = self.xml.get_widget('add_new_contact_menuitem') - service_disco_menuitem = self.xml.get_widget('service_disco_menuitem') + add_new_contact_menuitem = self.xml.get_widget('add_new_contact_menuitem') + service_disco_menuitem = self.xml.get_widget('service_disco_menuitem') advanced_menuitem = self.xml.get_widget('advanced_menuitem') show_offline_contacts_menuitem = self.xml.get_widget( 'show_offline_contacts_menuitem') @@ -634,7 +634,7 @@ class RosterWindow: for win in gajim.interface.msg_win_mgr.windows(): win.repaint_themed_widgets() # update gc's roster - for ctl in gajim.interface.msg_win_mgr.controls(): + for ctl in gajim.interface.msg_win_mgr.controls(): if ctl.type_id == message_control.TYPE_GC: ctl.draw_widgets() @@ -709,7 +709,7 @@ class RosterWindow: contact.show = show contact.status = status if show in ('offline', 'error') and \ - not gajim.awaiting_events[account].has_key(contact.jid): + not gajim.awaiting_events[account].has_key(contact.jid): if len(contact_instances) > 1: # if multiple resources gajim.contacts.remove_contact(account, contact) @@ -755,7 +755,7 @@ class RosterWindow: if props and self.tooltip.id == props[0]: # check if the current pointer is at the same path # as it was before setting the timeout - rect = self.tree.get_cell_area(props[0], props[1]) + rect = self.tree.get_cell_area(props[0], props[1]) position = self.tree.window.get_origin() pointer = self.window.get_pointer() self.tooltip.show_tooltip(contact, (pointer[0], rect.height), @@ -1905,7 +1905,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) if self._last_selected_contact is not None: jid, account = self._last_selected_contact self.draw_contact(jid, account, selected = True, - focus = True) + focus = True) def on_roster_window_focus_out_event(self, widget, event): # if a contact row is selected, update colors (eg. for status msg) @@ -1914,7 +1914,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) if self._last_selected_contact is not None: jid, account = self._last_selected_contact self.draw_contact(jid, account, selected = True, - focus = False) + focus = False) def on_roster_window_key_press_event(self, widget, event): if event.keyval == gtk.keysyms.Escape: @@ -2102,7 +2102,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) self.collapsed_rows.append(account) def on_editing_started(self, cell, event, row): - ''' start editing a cell in the tree ''' + ''' start editing a cell in the tree''' path = self.tree.get_cursor()[0] self.editing_path = path