def __init__(self, parent, subject=None, text=None): gtk.Dialog.__init__(self, 'Message Composer', parent, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) self.add_button('Publish', 1) self.top_hbox = gtk.HBox() self.subject_label = gtk.Label() self.subject_label.set_use_markup(True) self.subject_label.set_markup('Subject:') self.subject_entry = new_entry() if subject != None: self.subject_entry.set_text(subject) self.top_hbox.pack_start(self.subject_label, False, False, 5) self.top_hbox.pack_start(self.subject_entry, True, True, 5) self.messagebuffer = gtk.TextBuffer() if text != None: self.messagebuffer.set_text(text) text_scrollarea = new_scrollarea() self.editor = new_textview() self.editor.set_buffer(self.messagebuffer) self.editor.set_wrap_mode(gtk.WRAP_WORD) self.editor.set_editable(True) self.editor.set_cursor_visible(True) text_scrollarea.add(self.editor) text_scrollarea.set_size_request(-1, 300) self.vbox.pack_start(self.top_hbox, False, False) self.vbox.pack_start(text_scrollarea, True, True) self.vbox.show_all()
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)