Example #1
0
    def chat_row_activated_cb(self, treeview, path, view_column):
        if view_column != self.nick_column:
            return
        store, button = self.get_storebutton(self.active_conversation)
        row = store[path]

        msgid = row[self.COL_MSGID]
        msg = self.active_conversation.get_msg(msgid)
        sender_addr = msg.get_sender_addr()
        user = user_from_addr(self.community, sender_addr, safe=False)
        self.community.community_gui.show_user_page(user)
Example #2
0
    def new_message_cb(self, conversation, msg):
        sender_addr = msg.get_sender_addr()
        # safe == False because messages sent by me also go through this path
        sender = user_from_addr(self.community, sender_addr, safe=False)
        if sender:
            sender_nick = sender.get('nick')
            if get_debug_mode() and sender.get('hops') != None:
                sender_nick += ':%d' % sender.get('hops')
        else:
            sender_nick = TP_NICK_DEFAULT

        if not self.has_storebutton(conversation):
            store, button = self.new_storebutton(conversation)
            if conversation.is_community():
                notificationmsg = 'Chat activity on %s community' % conversation.tag()
                self.notification.notify(notificationmsg)
            else:
                self.notification.user_notify(sender, 'has spoken to you')
        else:
            store, button = self.get_storebutton(conversation)

        ctime = int(msg.get_ctime()[0])
        tstr = iso_date_time(t=ctime, dispdate=False, dispsecs=False)

        msgid = msg.get_msgid()

        children = conversation.get_children(msgid, [])

        # NOTE: first column is of type gobject.TYPE_PYOBJECT because
        # glib strings are not binary safe
        icon = None
        if msg.error:
            icon = self.warning_icon
        row_data = [msgid, tstr, '<' + sender_nick + '> ', msg.get_msg(), icon]

        # if message has children it is sorted to the list such
        # that it is inserted before all its children
        if children:
            row = None
            for row in store:
                if row[self.COL_MSGID] in children:
                    break
            store.insert_before(row.iter, row_data)
        else:
            riter = store.append(row_data)
            if self.active_conversation == conversation and self.atbottom:
                self.chat_tw.scroll_to_cell(store.get_path(riter))

        # announce activity on conversation
        return self.activity(conversation)
Example #3
0
    def new_message_cb(self, conversation, msg):
        sender_addr = msg.get_sender_addr()
        # safe == False because messages sent by me also go through this path
        sender = user_from_addr(self.community, sender_addr, safe=False)
        if sender:
            sender_nick = sender.get('nick')
        else:
            sender_nick = TP_NICK_DEFAULT

        if self.active_conversation == conversation:
            self.display.append((msg.get_msgid(), '<%s> %s' % (sender_nick, msg.get_msg())))
            if self.main_ui.get_current_page() == self:
                self.draw()
        return True