예제 #1
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)
예제 #2
0
    def append_log(self, msg, highpri, icon, cb, ctx=None):
        if icon == None:
            if highpri:
                icon = self.important_icon
            else:
                icon = self.information_icon
        else:
            icon = icon.scale_simple(32, 32, gtk.gdk.INTERP_BILINEAR)

        msg = '%s: %s' %(iso_date_time(), msg)
        msg = self.main_gui.pretty_line(msg)
        riter = self.event_list.append((icon, msg, cb, ctx))
        if self.atbottom:
            self.event_view.scroll_to_cell(self.event_list.get_path(riter))
예제 #3
0
def msgtime(meta):
    return iso_date_time(meta.get('timestart'))