Пример #1
0
    def draw(self):
        self.main_ui.screen.move(1, 0)
        self.main_ui.screen.clrtobot()

        (h, w) = self.main_ui.screen.getmaxyx()

        y = 1
        for msgid, text in self.display[-(h - 3):]:
            self.main_ui.screen.addstr(y, 0, text)
            y += 1

        self.main_ui.screen.addstr(h - 2, 0, ' ' * w, curses.color_pair(1))
        if self.active_conversation:
            (is_community, key, id) = decode_addr(self.active_conversation.target_addr)

            if is_community:
                coml = self.community.find_communities(id, peer=True)
                com = None
                if len(coml) > 0:
                    com = coml[0]
                name = id
            else:
                user = self.community.get_user(id)
                name = user.get('nick')
            self.main_ui.screen.addstr(h - 2, 1, name, curses.color_pair(1))
        self.main_ui.screen.addstr(h - 1, 0, self.buffer)

        self.main_ui.screen.refresh()
        return True
Пример #2
0
    def add_chat_button(self, conversation):

        (is_community, key, id) = decode_addr(conversation.target_addr)

        if is_community:
            coml = self.community.find_communities(id, peer=True)
            com = None
            if len(coml) > 0:
                com = coml[0]
            name = id
        else:
            user = self.community.get_user(id)
            name = user.get('nick')

        children = self.chatlist.get_children()
        if children:
            button_group = self.chatlist.get_children()[0]
        else:
            button_group = None

        button = gtk.RadioButton(button_group, name)
        button.set_mode(False)
        self.chatlist.pack_start(button, False, True)
        button.show_all()
        button.connect('toggled', self.chat_button_toggled, conversation)

        if is_community:
            image = None
            if com != None:
                image = gtk.image_new_from_pixbuf(get_community_icon(com).scale_simple(48, 48, gtk.gdk.INTERP_BILINEAR))
        else:
            image = gtk.image_new_from_pixbuf(get_user_profile_picture(user, False).scale_simple(48, 48, gtk.gdk.INTERP_BILINEAR))

        if image != None:
            button.set_image(image)

        return button