def initialize_profile_page(self): profile_hbox = gtk.HBox() vbox = gtk.VBox() picture_hbox = gtk.HBox() self.profile_image = gtk.Image() self.profile_image.set_size_request(MAX_FACE_DIMENSION+10, MAX_FACE_DIMENSION+10) picture_hbox.pack_start(self.profile_image, False, True) self.status_label = gtk.Label() self.status_label.set_line_wrap(True) picture_hbox.pack_start(self.status_label) vbox.pack_start(picture_hbox) self.profile_info_label = gtk.Label() self.profile_info_label.set_alignment(0.1, 0.01) # 0.01 on purpose self.profile_info_label.set_line_wrap(True) vbox.pack_start(self.profile_info_label) profile_hbox.pack_start(vbox) self.user_action_list = User_Action_List(self.community_gui, self.get_user) profile_hbox.pack_start(self.user_action_list.action_view) swindow = new_scrollarea() swindow.set_border_width(0) swindow.add_with_viewport(profile_hbox) self.update_profile_widgets() self.notebook.append_page(swindow, gtk.Label('Profile'))
def __init__(self, fs_gui): GUI_Page.__init__(self, 'Publish content') self.fs_gui = fs_gui self.icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), \ "64px-publish_content_icon.png")) self.vbox = gtk.VBox() self.pack_start(self.vbox) self.folders = {} self.sharelist = gtk.TreeStore(gobject.TYPE_PYOBJECT, str, bool, gtk.gdk.Pixbuf, str, str) self.initialize_share_list() self.initialize_action_list() self.title = gtk.Label("Content Publishing") self.vbox.pack_start(self.title, False, False) scrollwin = new_scrollarea() scrollwin.add_with_viewport(self.sharelist_view) self.vbox.pack_start(scrollwin, True, True) self.show_all() main_gui.add_page(self)
def __init__(self, fs_gui, title): GUI_Page.__init__(self, title) self.fs_gui = fs_gui self.target = None self.is_community = False self.items = 0 self.vbox = gtk.VBox() self.pack_start(self.vbox) self.folders = {} self.content_list = gtk.TreeStore(gobject.TYPE_PYOBJECT, str, gobject.TYPE_PYOBJECT, bool, gtk.gdk.Pixbuf, str, str, str, str, int) self.content_list.set_sort_column_id(self.COL_HOPS, gtk.SORT_ASCENDING) self.initialize_browse_list() self.initialize_action_list() self.title = gtk.Label("Content Browsing") self.vbox.pack_start(self.title, False, False) scrollwin = new_scrollarea() scrollwin.add_with_viewport(self.browse_list_view) self.vbox.pack_start(scrollwin, True, True) self.show_all() main_gui.add_page(self)
def initialize_profile_page(self): profile_hbox = gtk.HBox() vbox = gtk.VBox() myself = self.community.get_myself() is_member = (self.com in self.community.get_user_communities(myself)) picture_vbox = gtk.VBox() self.profile_image = gtk.Image() self.profile_image.set_size_request(MAX_FACE_DIMENSION+10, MAX_FACE_DIMENSION+10) if is_member: eventbox = gtk.EventBox() eventbox.connect("button-press-event", self.image_clicked) eventbox.add(self.profile_image) picture_vbox.pack_start(gtk.Label('Click picture to change')) picture_vbox.pack_start(eventbox, True, True) else: picture_vbox.pack_start(self.profile_image, True, True) picture_hbox = gtk.HBox() picture_hbox.pack_start(picture_vbox, False, True) self.status_label = gtk.Label() self.status_label.set_line_wrap(True) picture_hbox.pack_start(self.status_label) vbox.pack_start(picture_hbox) self.profile_info_label = gtk.Label() self.profile_info_label.set_alignment(0.1, 0.01) # 0.01 on purpose self.profile_info_label.set_line_wrap(True) vbox.pack_start(self.profile_info_label) profile_hbox.pack_start(vbox) self.com_action_list = Community_Action_List(self.community_gui, self.get_community) profile_hbox.pack_start(self.com_action_list.action_view) swindow = new_scrollarea() swindow.set_border_width(0) swindow.add_with_viewport(profile_hbox) self.update_profile_widgets() self.notebook.append_page(swindow, gtk.Label('Profile'))
def initialize_members_page(self): hbox = gtk.HBox() if self.list_view: # Display as a list self.itemview = gtk.TreeView(self.itemlist) self.itemview.connect('row-activated', self.handle_item_clicked) self.itemview.set_headers_visible(False) cr_icon = gtk.CellRendererPixbuf() cr_name = gtk.CellRendererText() cr_status = gtk.CellRendererText() column = gtk.TreeViewColumn('') column.pack_start(cr_icon, False) column.pack_start(cr_name) column.add_attribute(cr_icon, 'pixbuf', self.COL_ICON) column.add_attribute(cr_name, 'markup', self.COL_TITLE) self.itemview.append_column(column) column = gtk.TreeViewColumn('Status') column.pack_start(cr_status) column.add_attribute(cr_status, 'text', self.COL_STATUS) column.set_expand(True) self.itemview.append_column(column) else: # Icon display self.itemview = gtk.IconView(self.itemlist) self.itemview.set_spacing(6) self.itemview.set_row_spacing(9) self.itemview.connect('item-activated', self.handle_item_clicked) self.itemview.connect('button-press-event', self.view_clicked, None) self.itemview.set_pixbuf_column(self.COL_ICON) self.itemview.set_markup_column(self.COL_TITLE) swindow = new_scrollarea() swindow.add_with_viewport(self.itemview) hbox.pack_start(swindow) self.action_list = User_Action_List(self.community_gui, self.get_selected) hbox.pack_start(self.action_list.get_widget(), False, True) self.notebook.append_page(hbox, gtk.Label('Members'))
def initialize_item_list(self): vbox = gtk.VBox() self.itemview = gtk.IconView(self.itemlist) self.itemview.set_spacing(6) self.itemview.set_row_spacing(9) self.itemview.connect('item-activated', self.handle_item_clicked) self.itemview.connect('button-press-event', self.view_clicked, None) self.itemview.set_pixbuf_column(self.COL_ICON) self.itemview.set_text_column(self.COL_NAME) swindow = new_scrollarea() swindow.add_with_viewport(self.itemview) vbox.pack_start(swindow) self.pack_start(vbox, True, True)
def __init__(self, activate_cb=None): self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY) self.store = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, object) self.scrollarea = new_scrollarea() self.scrollarea.set_size_request(-1, 340) self.view = gtk.TreeView() self.view.set_headers_visible(True) cr1 = gtk.CellRendererPixbuf() cr2 = gtk.CellRendererText() cr3 = gtk.CellRendererText() cr4 = gtk.CellRendererText() cr3.set_property('xalign', 0.1) col = gtk.TreeViewColumn('Community') col.pack_start(cr1, False) col.pack_start(cr2) col.add_attribute(cr1, 'pixbuf', self.COL_ICON) col.add_attribute(cr2, 'text', self.COL_NAME) col2 = gtk.TreeViewColumn('Members') col2.pack_start(cr3) col2.add_attribute(cr3, 'text', self.COL_MEMBERS) self.column_desc = gtk.TreeViewColumn('Description') self.column_desc.pack_start(cr4) self.column_desc.add_attribute(cr4, 'text', self.COL_DESC) self.view.append_column(col) self.view.append_column(col2) self.view.append_column(self.column_desc) self.view.set_model(self.store) self.view.connect('row-activated', self.row_activated_cb) self.view.connect_after('size-allocate', self.resized) self.activated = activate_cb self.scrollarea.add_with_viewport(self.view)
def create_message_list(self): message_list = new_scrollarea() message_view = gtk.TreeView() message_view.set_headers_visible(False) cr1 = gtk.CellRendererPixbuf() cr2 = gtk.CellRendererText() col1 = gtk.TreeViewColumn('Message') col1.pack_start(cr1, False) col1.pack_start(cr2, True) message_view.append_column(col1) col1.add_attribute(cr1, 'pixbuf', 0) col1.add_attribute(cr2, 'markup', 1) message_view.connect('row-activated', self.row_activated_cb) message_list.add(message_view) return message_list, message_view
def __init__(self, main_gui): self.main_gui = main_gui self.main_window = main_gui.get_main_window() gtk.Dialog.__init__(self, 'Watch editor', self.main_window, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) action_area = self.action_area content_area = self.vbox watch_area = new_scrollarea() self.watch_view = gtk.TreeView() cr1 = gtk.CellRendererText() col1 = gtk.TreeViewColumn('Watch') col1.pack_start(cr1, True) self.watch_view.append_column(col1) col1.add_attribute(cr1, 'text', 0) watch_area.add(self.watch_view) content_area.pack_start(watch_area) add_button = gtk.Button(stock=gtk.STOCK_ADD) delete_button = gtk.Button(stock=gtk.STOCK_DELETE) edit_button = gtk.Button(stock=gtk.STOCK_EDIT) add_button.connect('clicked', self.add_clicked_cb) delete_button.connect('clicked', self.delete_clicked_cb) edit_button.connect('clicked', self.edit_clicked_cb) action_area.pack_start(add_button) action_area.pack_start(delete_button) action_area.pack_start(edit_button) self.show_all()
def initialize_search_window(self): self.search_fwindow = new_scrollarea() self.search_vbox = gtk.VBox() self.search_fwindow.add_with_viewport(self.search_vbox) entrylist = [('keywords', 'Keywords:'), \ ('fname', 'Filename:'), \ ('title', 'Title:'), \ ('author', 'Author:'), \ ('description', 'Description:')] for (key, header) in entrylist: hbox = gtk.HBox() label = gtk.Label(header) label.set_size_request(130, -1) label.set_alignment(0, 0) hbox.pack_start(label, False, False) entry = gtk.Entry() self.entries[key] = entry entry.connect("activate", self.search_cb) hbox.pack_start(entry, True, True) self.search_vbox.pack_start(hbox, False, False)
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): GUI_Page.__init__(self, 'Notifications') self.main_gui = gui self.queue = [] self.queue_highpri = [] self.atbottom = True self.notification_plugin = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION) self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY) self.dialog = gtk.Dialog('Proximate', gui.get_main_window(), gtk.DIALOG_DESTROY_WITH_PARENT) self.dialog.add_events(gtk.gdk.BUTTON_PRESS_MASK) self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.dialog.set_default_size(200, 150) self.dialog.set_has_separator(False) self.text = gtk.Label() self.text.set_line_wrap(True) self.dialog.vbox.pack_start(self.text) self.dialog.connect('button-press-event', self.dialog_clicked) self.dialog.connect('delete-event', self.dialog_deleted) self.dialog.connect('response', self.response_handler) self.notebook = gtk.Notebook() self.events_label = gtk.Label('Events') self.notifications_label = gtk.Label('Notifications') # The other notification log display # store = (icon, message, callback, ctx, apply_icon, cancel_icon) self.notification_list = gtk.ListStore(gtk.gdk.Pixbuf, str, object, object, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf) self.notification_view = gtk.TreeView(self.notification_list) self.notification_view.set_headers_visible(False) self.notification_view.connect('row-activated', self.notification_row_activated_cb) cr_icon = gtk.CellRendererPixbuf() cr_msg = gtk.CellRendererText() cr_apply_icon = gtk.CellRendererPixbuf() cr_cancel_icon = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn('') column.pack_start(cr_icon, False) column.pack_start(cr_msg) column.add_attribute(cr_icon, 'pixbuf', self.COL_ICON) column.add_attribute(cr_msg, 'text', self.COL_MSG) column.set_expand(True) self.notification_view.append_column(column) self.apply_column = gtk.TreeViewColumn('') self.apply_column.pack_start(cr_apply_icon, False) self.apply_column.add_attribute(cr_apply_icon, 'pixbuf', self.COL_APPLY) self.notification_view.append_column(self.apply_column) self.cancel_column = gtk.TreeViewColumn('') self.cancel_column.pack_start(cr_cancel_icon, False) self.cancel_column.add_attribute(cr_cancel_icon, 'pixbuf', self.COL_CANCEL) self.notification_view.append_column(self.cancel_column) scrollwin = new_scrollarea() scrollwin.add(self.notification_view) self.notebook.append_page(scrollwin, self.notifications_label) # Event log display self.event_list = gtk.ListStore(gtk.gdk.Pixbuf, str, object, object) self.event_view = gtk.TreeView(self.event_list) self.event_view.set_headers_visible(False) self.event_view.connect('row-activated', self.event_row_activated_cb) cell_pic = gtk.CellRendererPixbuf() cell_msg = gtk.CellRendererText() column = gtk.TreeViewColumn('') column.pack_start(cell_pic, False) column.pack_start(cell_msg) column.add_attribute(cell_pic, 'pixbuf', self.COL_ICON) self.event_view.append_column(column) column.add_attribute(cell_msg, 'text', self.COL_MSG) scrollwin = new_scrollarea() scrollwin.add(self.event_view) scrollwin.get_vadjustment().connect('value-changed', self.event_view_scrolled) self.notebook.append_page(scrollwin, self.events_label) style = self.notification_view.get_style() apply_iconset = style.lookup_icon_set(gtk.STOCK_APPLY) self.apply_icon = apply_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON) cancel_iconset = style.lookup_icon_set(gtk.STOCK_CANCEL) self.cancel_icon = cancel_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON) self.connect('expose-event', self.exposed) self.pack_start(self.notebook) gui.add_page(self) self.show_all() self.active_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.ICON)) self.inactive_icon = self.active_icon.copy() self.active_icon.saturate_and_pixelate(self.inactive_icon, 0.0, False) self.information_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.INFORMATION)) self.important_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.IMPORTANT)) self.statusbar_icon = gui.add_statusbar_icon(self.inactive_icon, 'Notifications', self.statusbar_icon_clicked) self.notification_plugin.register_ui(self)
def initialize_profile_page_widgets(self): self.profile_main_vbox = gtk.VBox() swindow = new_scrollarea() swindow.set_border_width(0) main_hbox = gtk.HBox(False, 20) picture_vbox = gtk.VBox() self.profile_image = gtk.Image() self.profile_image.set_size_request(MAX_FACE_DIMENSION+10, MAX_FACE_DIMENSION+10) eventbox = gtk.EventBox() eventbox.connect("button-press-event", self.image_clicked) eventbox.add(self.profile_image) picture_vbox.pack_start(gtk.Label('Click picture to change')) picture_vbox.pack_start(eventbox, True, True) # User always has a nick widget = gtk.Entry() widget.set_text(self.user.get('nick')) widget.connect("focus-out-event", self.entry_focus_out, 'nick') self.profile_widgets['nick'] = widget nick_label = gtk.Label('Nick:') nick_label.set_alignment(0, 0) picture_vbox.pack_start(nick_label, False, False) picture_vbox.pack_start(widget, False, False) left_hbox = gtk.VBox(False, 20) left_hbox.pack_start(picture_vbox, False, False) user_info_vbox = gtk.VBox(False, 5) profile_components = (('Name:', 'name'), ('Age:', 'age'), ('Gender:', 'gender'), ('City:', 'city'), ('State:', 'state'), ('Country:', 'country'), ('Birth Date:', 'birth_date'), ('E-mail:', 'email'), ('WWW:', 'www'), ('Occupation:', 'occupation'), ('Phone Numbers:', 'phone_numbers'), ('Languages:', 'languages'), ('Description:', 'description'), ) genders = ('Male', 'Female') for header, key in profile_components: hbox = gtk.HBox() label = gtk.Label(header) label.set_size_request(130, -1) label.set_alignment(0, 0) value = self.user.get(key) if value == None: value = '' if key == 'gender': # create gender widget separately widget = gtk.combo_box_entry_new_text() for gender in genders: widget.append_text(gender) entry = widget.child entry.set_text(str(value)) widget.connect("changed", self.combo_changed, key) elif key == 'description': widget = gtk.TextView() widget.get_buffer().set_text(str(value)) widget.set_property("wrap-mode", gtk.WRAP_CHAR) widget.set_size_request(-1, 100) entry = widget else: widget = gtk.Entry() widget.set_text(str(value)) entry = widget entry.connect("focus-out-event", self.entry_focus_out, key) hbox.pack_start(label, False, False) hbox.pack_start(widget, True, True) self.profile_widgets[key] = entry user_info_vbox.pack_start(hbox, False, False) main_hbox.pack_start(left_hbox, False, False) main_hbox.pack_start(user_info_vbox, True, True) swindow.add_with_viewport(main_hbox) self.update_profile_widgets() self.pack_start(swindow, True, True)
def initialize_widgets(self): fwindow = new_scrollarea() viewport = gtk.Viewport() self.widgets_to_hide = [] self.main_vbox = gtk.VBox() self.main_vbox.set_size_request(-1, 500) self.image_hbox = gtk.HBox() self.main_vbox.pack_start(self.image_hbox, False, False) # Community name, personal cbox, area size and image self.name_vbox = gtk.VBox() hbox = gtk.HBox() self.name_label = gtk.Label('Community\'s name:') hbox.pack_start(self.name_label, False, True) self.name_vbox.pack_start(hbox, False, True) self.name_entry = gtk.Entry() self.name_entry.set_size_request(-1, 32) self.name_vbox.pack_start(self.name_entry, False, True) hbox = gtk.HBox() self.personal_label = gtk.Label('Personal Community:') hbox.pack_start(self.personal_label, False, True) if self.community.personal_communities: self.name_vbox.pack_start(hbox, False, True) self.personal_cbutton = gtk.CheckButton() self.personal_cbutton.set_active(False) self.personal_cbutton.set_size_request(-1, 32) self.personal_cbutton.connect("clicked", self.checkbutton_clicked) hbox = gtk.HBox() hbox.pack_start(self.personal_cbutton, True, True) if self.community.personal_communities: self.name_vbox.pack_start(hbox, False, True) self.image_hbox.pack_start(self.name_vbox, False, True) self.image_eb = gtk.EventBox() self.image_eb.connect("button-press-event", self.image_clicked) self.image = gtk.Image() self.image.set_size_request(MAX_FACE_DIMENSION+10, MAX_FACE_DIMENSION+10) self.image.set_from_file(get_path(DEFAULT_COMMUNITY_ICON)) self.image_eb.add(self.image) vbox = gtk.VBox() vbox.pack_start(self.image_eb, True, True) vbox.pack_start(gtk.Label('Click community\nicon to change it'), True, False) self.image_hbox.pack_end(vbox, False, False) hbox = gtk.HBox() desc_label = gtk.Label('Description: ') desc_label.set_size_request(-1, 32) hbox.pack_start(desc_label, False, True) self.main_vbox.pack_start(hbox, False, True) self.description_tview = gtk.TextView() self.description_tview.set_property("wrap-mode", gtk.WRAP_CHAR) self.description_tbuffer = gtk.TextBuffer() self.description_tbuffer.set_text("<<Insert description>>") self.description_tview.set_buffer(self.description_tbuffer) self.description_tview.set_size_request(300, 100) self.main_vbox.pack_start(self.description_tview, False, True) self.main_vbox.show_all() viewport.add(self.main_vbox) fwindow.add(viewport) self.dialog.vbox.pack_start(fwindow)
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)
def __init__(self, gui): GUI_Page.__init__(self, 'Messaging') self.main_gui = gui self.toggle_dialog = None self.statusbar_icon = None self.atbottom = True self.active_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.STATUSBAR_ICON)) self.inactive_icon = self.active_icon.copy() self.active_icon.saturate_and_pixelate(self.inactive_icon, 0.0, False) # GUI stores liststores and buttos as (store, button) tuples indexed # by Conversation self.gui_storebutton = {} self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY) self.messaging = get_plugin_by_type(PLUGIN_TYPE_MESSAGING) self.notification = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION) # the currently active conversation self.active_conversation = None messaging_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.MESSAGING_ICON)) self.community.community_gui.register_user_event(messaging_icon, 'Chat', self.start_messaging_cb) self.community.community_gui.register_com_event(messaging_icon, 'Chat', self.start_messaging_cb) self.right_vbox = gtk.VBox() self.left_vbox = gtk.VBox() vseparator = gtk.VSeparator() self.pack_start(self.left_vbox, False, True) self.pack_start(vseparator, False, False) self.pack_start(self.right_vbox, True, True) self.top_hbox = gtk.HBox() separator1 = gtk.HSeparator() scrollwin = new_scrollarea() separator2 = gtk.HSeparator() self.bottom_hbox = gtk.HBox() # adding top level self.right_vbox.pack_start(self.top_hbox, expand = False) self.right_vbox.pack_start(separator1, expand = False) self.right_vbox.pack_start(scrollwin) self.right_vbox.pack_end(self.bottom_hbox, expand = False) self.right_vbox.pack_end(separator2, expand = False) # creatind the top row self.headline = gtk.Label() self.end_chat_eb = gtk.EventBox() self.end_chat_img = gtk.Image() # setting up the button icons in the top row self.end_chat_eb.add(self.end_chat_img) self.end_chat_img.set_from_file(join(get_dir(ICON_DIR), self.END_CHAT_ICON)) # forming the top row self.top_hbox.pack_start(self.headline) self.top_hbox.pack_end(self.end_chat_eb, expand = False) # creating the chat area cr_icon = gtk.CellRendererPixbuf() self.chat_tw = gtk.TreeView() self.chat_tw_cr1 = gtk.CellRendererText() self.chat_tw_cr2 = gtk.CellRendererText() self.chat_tw_cr3 = gtk.CellRendererText() column = gtk.TreeViewColumn('Time') column.pack_start(cr_icon) column.pack_start(self.chat_tw_cr1) column.add_attribute(cr_icon, "pixbuf", self.COL_ICON) column.add_attribute(self.chat_tw_cr1, "text", self.COL_TIME) self.chat_tw.append_column(column) self.nick_column = gtk.TreeViewColumn('Nick') self.nick_column.pack_start(self.chat_tw_cr2) self.nick_column.add_attribute(self.chat_tw_cr2, "text", self.COL_NICK) self.chat_tw.append_column(self.nick_column) column = gtk.TreeViewColumn('Message') column.pack_start(self.chat_tw_cr3) column.add_attribute(self.chat_tw_cr3, "text", self.COL_MESSAGE) self.chat_tw.append_column(column) # to keep the fields aligned to the top of each row self.chat_tw_cr1.set_property('yalign', 0.0) self.chat_tw_cr2.set_property('yalign', 0.0) self.chat_tw_cr3.set_property('yalign', 0.0) self.chat_tw_cr3.set_property('wrap-mode', pango.WRAP_WORD_CHAR) self.chat_tw.set_property('enable-search', False) self.chat_tw.set_property('headers-visible', False) self.chat_tw.connect('size-allocate', self.resized) self.chat_tw.connect('row-activated', self.chat_row_activated_cb) scrollwin.add(self.chat_tw) scrollwin.get_vadjustment().connect('value-changed', self.chat_tw_scrolled) # creating the left area for chat tabs self.left_vbox.set_size_request(200, -1) chatlist_label = gtk.Label('Active chats') self.left_vbox.pack_start(chatlist_label, False, True) self.chatlist_scroll = new_scrollarea() self.left_vbox.pack_start(self.chatlist_scroll, True, True) self.chatlist = gtk.VBox() self.chatlist.set_size_request(200-2, -1) self.chatlist_scroll.add_with_viewport(self.chatlist) # creating the bottom area self.entry = gtk.Entry() self.bottom_hbox.pack_start(self.entry) self.show_all() gui.add_page(self) style = self.headline.get_style() self.normal_text_color = style.fg[gtk.STATE_NORMAL].copy() self.warning_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.WARNING_ICON)) # callbacks: # connecting press of enter to sending message self.entry.connect('activate', self.entry_activate_cb) self.end_chat_eb.connect('button-press-event', self.close_active_conversation_cb) # monitor chat page visibility self.connect('expose-event', self.exposed) self.messaging.register_ui(self)
def __init__(self, gui): self.register_plugin(PLUGIN_TYPE_FILE_TRANSFER) self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY) self.notification = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION) self.filesharing = get_plugin_by_type(PLUGIN_TYPE_FILE_SHARING) self.main_gui = gui self.ft_statusbar_icon = gtk.gdk.pixbuf_new_from_file_at_size( join(get_dir(ICON_DIR), self.STATUSBAR_ICON), STATUSBAR_ICON_SIZE, STATUSBAR_ICON_SIZE ) self.ft_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.STATUSBAR_ICON)) self.statusbar_icon = None self.page = GUI_Page("File transfers") self.main_vbox = gtk.VBox() # Top row top_hbox = gtk.HBox() headline = gtk.Label("File Transfers") close_eb = gtk.EventBox() close_img = gtk.Image() close_eb.add(close_img) close_img.set_from_file(join(get_dir(ICON_DIR), self.CLOSE_ICON)) top_hbox.pack_start(headline) top_hbox.pack_end(close_eb, expand=False) self.main_vbox.pack_start(top_hbox, False, False) # store = (icon, message, transfer, delete_icon) self.transfer_list = gtk.ListStore(gtk.gdk.Pixbuf, str, int, object, gtk.gdk.Pixbuf) cr_icon = gtk.CellRendererPixbuf() cr_msg = gtk.CellRendererText() cr_prog = ProgressCellRenderer() cr_delete_icon = gtk.CellRendererPixbuf() self.transfer_view = gtk.TreeView(self.transfer_list) self.transfer_view.set_headers_visible(False) self.transfer_view.connect("row-activated", self.row_activated_cb) column = gtk.TreeViewColumn("") column.pack_start(cr_icon, False) column.pack_start(cr_msg) column.add_attribute(cr_icon, "pixbuf", self.COL_ICON) column.add_attribute(cr_msg, "text", self.COL_MSG) column.set_expand(True) self.transfer_view.append_column(column) column = gtk.TreeViewColumn("") column.pack_start(cr_prog) column.add_attribute(cr_prog, "percent", self.COL_PROG) self.transfer_view.append_column(column) self.delete_column = gtk.TreeViewColumn("") self.delete_column.pack_start(cr_delete_icon, False) self.delete_column.add_attribute(cr_delete_icon, "pixbuf", self.COL_DELETE) self.transfer_view.append_column(self.delete_column) scrollwin = new_scrollarea() scrollwin.add(self.transfer_view) self.main_vbox.pack_start(scrollwin, True, True) style = self.transfer_view.get_style() abort_iconset = style.lookup_icon_set(gtk.STOCK_CLOSE) self.abort_icon = abort_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON) delete_iconset = style.lookup_icon_set(gtk.STOCK_DELETE) self.delete_icon = delete_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON) self.statusLabel = gtk.Label("") self.statusLabel.set_padding(3, 3) self.abort_all = gtk.Button("Abort all") self.delete_all = gtk.Button("Delete all") self.open_dldir = gtk.Button("Open download directory") status_hbox = gtk.HBox() status_hbox.set_size_request(-1, 50) status_hbox.pack_start(self.statusLabel, True, True) status_hbox.pack_start(self.open_dldir, False, False, padding=5) status_hbox.pack_start(self.delete_all, False, False, padding=5) status_hbox.pack_start(self.abort_all, False, False, padding=5) self.main_vbox.pack_start(status_hbox, False, False) # callbacks self.delete_all.connect("clicked", self.delete_all_cb) self.abort_all.connect("clicked", self.abort_all_cb) self.open_dldir.connect("clicked", self.open_dldir_cb) close_eb.connect("button-press-event", self.close_cb) self.page.pack_start(self.main_vbox) self.page.show_all() self.main_gui.add_page(self.page)