Пример #1
0
    def append_messages_to_store(self, store, metas):
        # Display hot messages first
        hot = []
        normal = []
        for meta in metas:
            if msgboard.is_hot(meta):
                hot.append((True, meta))
            else:
                normal.append((False, meta))

        for l in hot, normal:
            for (ishot, meta) in l:
                user = None
                uid = meta.get('src')
                if uid != None:
                    user = community.get_user(uid)
                if user == community.get_myself():
                    sender = 'Myself'
                elif user != None:
                    sender = pango_escape(user.tag())
                else:
                    sender = pango_escape(meta.get('from'))
                timestamp = msgtime(meta)
                subject = pango_escape(meta.get('subject'))
                if ishot:
                    line = '%s <span foreground="gray"><small>%s</small></span>\n<span foreground="red">[HOT] </span><b>%s</b>' % (sender, timestamp, subject)
                else:
                    line = '%s <span foreground="gray"><small>%s</small></span>\n<b>%s</b>' % (sender, timestamp, subject)
                icon = self.message_icon
                if user != None:
                    icon = get_user_profile_picture(user).scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR)
                store.append([icon, line, meta])
Пример #2
0
 def notification_show(self, msg, highpri, delay, user):
     if delay == None:
         delay = 3000
     if user == None:
         self.append_log(msg, highpri, None, None)
     else:
         icon = get_user_profile_picture(user).scale_simple(32, 32, gtk.gdk.INTERP_BILINEAR)
         self.append_log(msg, highpri, icon, self.user_clicked, user)
     if highpri:
         self.queue_highpri.insert(0, msg)
         self.update_dialog()
         timeout_add(delay, self.next_highpri)
     else:
         self.queue.append(msg)
         self.update_progress_bar()
         timeout_add(delay, self.next)
Пример #3
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
Пример #4
0
 def scale_user_face(self, user, factor):
     # returns saved face picture if user is in dictionary,
     # else creates a new picture, and saves and returns it
     return scale_image(get_user_profile_picture(
         user, status_icons=False, center=False), MAX_FACE_DIMENSION / factor)
Пример #5
0
    def __init__(self, gui, msg):

        self.gui = gui
        self.main_gui = gui.main_gui
        self.msg = msg

        self.user = None
        uid = msg.get('src')
        if uid != None:
            self.user = community.get_user(uid)

        if self.user == community.get_myself():
            sender = 'Myself'
        elif self.user != None:
            sender = self.user.tag()
        else:
            sender = msg.get('from')

        subject = msg.get('subject')
        title = 'Message from %s: %s' % (sender, subject)
        GUI_Page.__init__(self, title)

        self.vbox = gtk.VBox()

        self.top_hbox = gtk.HBox(False, 10)

        if self.user != None:
            self.profile_image = gtk.Image()
            self.profile_image.set_size_request(64+5, 64+5)
            icon = get_user_profile_picture(self.user).scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR)
            self.profile_image.set_from_pixbuf(icon)
            eventbox = gtk.EventBox()
            eventbox.connect("button-press-event", self.image_clicked)
            eventbox.add(self.profile_image)
            self.top_hbox.pack_start(eventbox, False, True)

        self.info_widgets = {}

        info_vbox = gtk.VBox()

        label = gtk.Label()
        label.set_markup('<b>From:</b>')
        label.set_size_request(100, -1)
        label.set_alignment(1, 0)
        widget = gtk.Label()
        widget.set_markup('<span color="#ff0000"><u>%s</u></span>' % pango_escape(sender))
        widget.set_alignment(0, 0)
        eventbox = gtk.EventBox()
        eventbox.connect("button-press-event", self.image_clicked)
        eventbox.add(widget)

        hbox = gtk.HBox(False, 5)
        hbox.pack_start(label, False, False)
        hbox.pack_start(eventbox, True, True)
        info_vbox.pack_start(hbox, False, True)

        for name in ('subject', 'date'):
            label = gtk.Label()
            label.set_markup('<b>%s:</b>' % name.title())
            label.set_size_request(100, -1)
            label.set_alignment(1, 0)
            if name == 'date':
                value = msgtime(msg)
            else:
                value = msg.get(name)
            widget = gtk.Label(value)
            widget.set_alignment(0, 0)

            hbox = gtk.HBox(False, 5)
            hbox.pack_start(label, False, False)
            hbox.pack_start(widget, True, True)
            info_vbox.pack_start(hbox, False, False)

            self.info_widgets[name] = widget

        self.edit_button = gtk.Button(label='Edit', stock=gtk.STOCK_EDIT)
        self.edit_button.connect('clicked', self.edit_cb)

        self.delete_button = gtk.Button(label='Delete', stock=gtk.STOCK_DELETE)
        self.delete_button.connect('clicked', self.delete_cb)

        self.top_hbox.pack_start(info_vbox, True, True)
        self.top_hbox.pack_start(self.edit_button, False, False)
        self.top_hbox.pack_start(self.delete_button, False, False)

        # Message textview
        message_scrollarea = new_scrollarea()
        self.messagebuffer = gtk.TextBuffer()
        self.messageview = new_textview()
        self.messageview.set_buffer(self.messagebuffer)
        self.messageview.set_wrap_mode(gtk.WRAP_WORD)
        self.messageview.set_editable(False)
        self.messageview.set_cursor_visible(False)
        message_scrollarea.add(self.messageview)

        self.vbox.pack_start(self.top_hbox, expand=False, fill=True)
        self.vbox.pack_start(message_scrollarea, expand=True, fill=True)
        self.pack_start(self.vbox)

        self.urltag = self.messagebuffer.create_tag()
        self.urltag.set_property('foreground', '#0000ff')
        self.urltag.set_property('underline', pango.UNDERLINE_SINGLE)
        self.urltag.connect('event', self.urltag_event_cb)

        self.load_message()

        self.show_all()
        self.main_gui.add_page(self)
Пример #6
0
 def get_user_icon(self, user):
     icon = get_user_profile_picture(user)
     if self.list_view:
         return icon.scale_simple(48, 48, gtk.gdk.INTERP_BILINEAR)
     return icon