def _create_tabs(self): '''create all the tabs on the window''' self.info = InformationWidget(self.session, self.account) self.avatar_manager = gui.base.AvatarManager(self.session) account_path = self.avatar_manager.get_contact_avatars_dir( self.account) self.avatars = IconView(_('Avatar history'), [account_path], None, None, IconView.TYPE_SELF_PICS, None) self.status = ListWidget(self.session, self.account) self.chats = ChatWidget(self.session, self.account) self.tabs.append_page(self.info, gtk.Label(_('Information'))) if self.session.session_has_service(e3.Session.SERVICE_CONTACT_NICK): self.nicks = ListWidget(self.session, self.account) self.tabs.append_page(self.nicks, gtk.Label(_('Nick history'))) self.tabs.append_page(self.avatars, gtk.Label(_('Avatar history'))) if self.session.session_has_service(e3.Session.SERVICE_CONTACT_PM): self.messages = ListWidget(self.session, self.account) self.tabs.append_page(self.messages, gtk.Label(_('Message history'))) self.tabs.append_page(self.status, gtk.Label(_('Status history'))) self.tabs.append_page(self.chats, gtk.Label(_('Chat history')))
def __init__(self, response_cb, picture_path='', cache_path='.', contact_cache_path='.', faces_paths=[], avatar_manager=None): '''Constructor, response_cb receive the response number, the new file selected and a list of the paths on the icon view. picture_path is the path of the current display picture, ''' gtk.Window.__init__(self) self.set_icon(gui.theme.logo) self.response_cb = response_cb self.avatar_manager = avatar_manager self.set_title("Avatar chooser") self.set_default_size(620, 400) self.set_border_width(4) self.set_position(gtk.WIN_POS_CENTER) self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.views = [] self.views.append(IconView(_('Used'), [cache_path], self)) self.views.append(IconView(_('System pictures'), faces_paths, self)) self.views.append( IconView(_('Contact pictures'), [contact_cache_path], self)) vbox = gtk.VBox(spacing=4) side_vbox = gtk.VBox(spacing=4) hbox = gtk.HBox(spacing=4) hbbox = gtk.HButtonBox() hbbox.set_spacing(4) hbbox.set_layout(gtk.BUTTONBOX_END) vbbox = gtk.VButtonBox() vbbox.set_spacing(4) vbbox.set_layout(gtk.BUTTONBOX_START) b_clear = gtk.Button("No picture") self.b_add = gtk.Button(stock=gtk.STOCK_ADD) self.b_remove = gtk.Button(stock=gtk.STOCK_REMOVE) self.b_remove_all = gtk.Button("Remove all") b_accept = gtk.Button(stock=gtk.STOCK_OK) b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL) b_clear.connect('clicked', self._on_clear) self.b_add.connect('clicked', self._on_add) self.b_remove.connect('clicked', self.on_remove) self.b_remove_all.connect('clicked', self._on_remove_all) b_accept.connect('clicked', self.on_accept) b_cancel.connect('clicked', self._on_cancel) self.connect('delete-event', self._on_close) self.connect("key-press-event", self.on_key_press) self.img_current = gtk.Image() self.img_current.set_size_request(96, 96) frame_current = gtk.Frame("Current") frame_current.add(self.img_current) hbbox.pack_start(b_clear, False) hbbox.pack_start(b_cancel, False) hbbox.pack_start(b_accept, False) vbbox.pack_start(self.b_add, False) vbbox.pack_start(self.b_remove, False) vbbox.pack_start(self.b_remove_all, False) side_vbox.pack_start(frame_current, False) side_vbox.pack_start(vbbox) self.notebook = gtk.Notebook() self.notebook.set_show_tabs(True) for view in self.views: self.notebook.append_page(view, view.label) self.notebook.connect("switch-page", self._on_tab_changed) hbox.pack_start(self.notebook, True, True) hbox.pack_start(side_vbox, False, False) vbox.pack_start(hbox, True, True) vbox.pack_start(hbbox, False) vbox.show_all() self.add(vbox) self.set_current_picture(picture_path)
def __init__(self, session): '''Constructor, response_cb receive the response number, the new file selected and a list of the paths on the icon view. picture_path is the path of the current display picture, ''' gtk.Window.__init__(self) self.set_modal(True) self.config = session.config self.avatar_manager = gui.base.AvatarManager(session) self.set_title(_("Avatar chooser")) self.set_default_size(620, 400) self.set_border_width(4) self.set_position(gtk.WIN_POS_CENTER) self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) cache_path = self.avatar_manager.get_avatars_dir() faces_paths = self.avatar_manager.get_system_avatars_dirs() contact_cache_path = self.avatar_manager.get_cached_avatars_dir() self.views = [] self.views.append( IconView(_('Used'), [cache_path], self.on_remove, self.on_accept, IconView.TYPE_SELF_PICS, self._on_image_area_selector)) self.views.append( IconView(_('System pictures'), faces_paths, self.on_remove, self.on_accept, IconView.TYPE_SYSTEM_PICS, None)) self.views.append( IconView(_('Contact pictures'), contact_cache_path, self.on_remove, self.on_accept, IconView.TYPE_CONTACTS_PICS, None)) vbox = gtk.VBox(spacing=4) side_vbox = gtk.VBox(spacing=4) hbox = gtk.HBox(spacing=4) hbbox = gtk.HButtonBox() hbbox.set_spacing(4) hbbox.set_layout(gtk.BUTTONBOX_END) vbbox = gtk.VButtonBox() vbbox.set_spacing(4) vbbox.set_layout(gtk.BUTTONBOX_START) b_clear = gtk.Button(_("No picture")) self.b_add = gtk.Button(stock=gtk.STOCK_ADD) self.b_remove = gtk.Button(stock=gtk.STOCK_REMOVE) self.b_remove_all = gtk.Button(_("Remove all")) b_accept = gtk.Button(stock=gtk.STOCK_OK) b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL) b_clear.connect('clicked', self._on_clear) self.b_add.connect('clicked', self._on_add) self.b_remove.connect('clicked', self.on_remove) self.b_remove_all.connect('clicked', self._on_remove_all) b_accept.connect('clicked', self.on_accept) b_cancel.connect('clicked', self._on_cancel) self.connect('delete-event', self._on_close) self.connect("key-press-event", self.on_key_press) Avatar = extension.get_default('avatar') img_current = Avatar() img_current.set_size_request(96, 96) frame_current = gtk.Frame() frame_current.set_label(_("Current")) frame_current.add(img_current) hbbox.pack_start(b_clear, False) hbbox.pack_start(b_cancel, False) hbbox.pack_start(b_accept, False) vbbox.pack_start(self.b_add, False) vbbox.pack_start(self.b_remove, False) vbbox.pack_start(self.b_remove_all, False) side_vbox.pack_start(frame_current, False) side_vbox.pack_start(vbbox) self.notebook = gtk.Notebook() self.notebook.set_show_tabs(True) for view in self.views: self.notebook.append_page(view, view.label) self.notebook.connect("switch-page", self._on_tab_changed) hbox.pack_start(self.notebook, True, True) hbox.pack_start(side_vbox, False, False) vbox.pack_start(hbox, True, True) vbox.pack_start(hbbox, False) vbox.show_all() self.add(vbox) current_avatar = session.config.last_avatar img_current.set_from_file(current_avatar)