예제 #1
0
    def __init__(self,
                 program,
                 programSize,
                 pos,
                 font,
                 w=100,
                 h=600,
                 borderColor=(0, 0, 0),
                 fillColor=(240, 240, 240)):
        WindowRectangle.__init__(self, program, programSize, pos, w, h,
                                 borderColor, fillColor)

        self.rect_border.center = (self.pos[0], self.pos[1])
        self.rect.center = (self.pos[0], self.pos[1])

        self.username_field = TextField.TextField(
            (self.pos[0], self.pos[1] - self.height / 2 + 50), 20,
            "Username: "******"Server IP: ",
            font)
        self.server_pass_field = TextField.TextField(
            (self.pos[0], self.server_field.pos[1] + 50), 20,
            "Server Password: "******"Connect", font)

        self.load_cfg()
예제 #2
0
    def __init__(self,
                 program,
                 programSize,
                 pos,
                 font,
                 client,
                 w=600,
                 h=300,
                 borderColor=(0, 0, 0),
                 fillColor=(240, 240, 240)):
        WindowTextlist.__init__(self, program, programSize, pos, w, h,
                                borderColor, fillColor)
        self.client = client
        self.counter = 0
        self.chat_rect_border = pygame.Rect(
            0, 0, self.width - 8, self.height - font.size("X")[1] - 26)
        self.chat_rect_border.topleft = (self.pos[0] + 4, self.pos[1] + 3)

        self.chat_rect = pygame.Rect(0, 0, self.width - 10,
                                     self.height - font.size("X")[1] - 28)
        self.chat_rect.topleft = (self.pos[0] + 5, self.pos[1] + 4)

        self.chat_field = TextField.TextField(
            (pos[0] + w / 2, pos[1] + h - font.size("X")[1] - 4),
            int(w / font.size("X")[0]) - (len(client.username) * 2) -
            2,  #max chars
            client.username,  #username
            font)  #font
예제 #3
0
    def __init__(self, session):
        '''constructor'''
        gtk.VBox.__init__(self)

        self.session = session
        self.config_dir = session.config_dir
        self._enabled = True

        Avatar = extension.get_default('avatar')

        self.avatar = Avatar(cell_dimension=48)

        self.avatarBox = gtk.EventBox()
        self.avatarBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.avatarBox.connect('button-press-event', self.on_avatar_click)
        self.avatarBox.add(self.avatar)
        self.avatarBox.set_tooltip_text(_('Click here to set your avatar'))
        self.avatarBox.set_border_width(4)

        self.avatar_path = self.config_dir.get_path("last_avatar")

        if not self.session.config_dir.file_readable(self.avatar_path):
            path = gui.theme.image_theme.user
        else:
            path = self.avatar_path
        self.avatar.set_from_file(path)

        self.nick = TextField.TextField(session.contacts.me.display_name,
                                        session.contacts.me.account, False)
        self.nick.set_tooltip_text(_('Click here to set your nick name'))
        self.status = StatusButton.StatusButton(session)
        self.status.set_tooltip_text(_('Click here to change your status'))
        self.status.set_status(session.contacts.me.status)
        self.search = gtk.ToggleButton()
        self.search.set_tooltip_text(_('Search (Ctrl+F)'))
        self.mail = gtk.Button(label="(0)")
        self.mail.set_tooltip_text(_('Click here to access your mail'))

        self.mail.get_settings().set_property("gtk-button-images", True)

        self.mail.set_image(
            gtk.image_new_from_file(gui.theme.image_theme.mailbox))
        self.mail.set_relief(gtk.RELIEF_NONE)
        self.search.set_image(
            gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU))
        self.search.set_relief(gtk.RELIEF_NONE)

        self.empty_message_text = _("Click here to set your message")
        self.message = TextField.TextField(
            session.contacts.me.message,
            '[I]' + self.empty_message_text + '[/I]', True)
        self.message.set_tooltip_text(self.empty_message_text)
        self.toolbar = gtk.HBox()

        hbox = gtk.HBox()
        hbox.set_border_width(1)
        hbox.pack_start(self.avatarBox, False)

        vbox = gtk.VBox()
        nick_hbox = gtk.HBox()
        nick_hbox.pack_start(self.nick, True, True)
        nick_hbox.pack_start(self.mail, False)
        nick_hbox.pack_start(self.search, False)

        # enable this code and you'll get a nice button which fires a signal
        #def do_something_weird(item):
        #    from e3.base.Event import Event
        #    session.add_event(Event.EVENT_DISCONNECTED, 'Tested disconnection', 0)
        #test_btn=gtk.Button(label="(!)")
        #test_btn.connect('clicked', do_something_weird)
        #test_btn.show()
        #nick_hbox.pack_start(test_btn, False)

        vbox.pack_start(nick_hbox, False)
        message_hbox = gtk.HBox()
        message_hbox.pack_start(self.message, True, True)
        message_hbox.pack_start(self.status, False)
        vbox.pack_start(message_hbox, False)

        hbox.pack_start(vbox, True, True)

        self.pack_start(hbox, True, True)
        self.pack_start(self.toolbar, False)

        hbox.show()
        nick_hbox.show()
        message_hbox.show()
        vbox.show()

        self._add_subscriptions()
예제 #4
0
    def Add(self, display_surf, type, xmlObject):

        if type == 'text':
            line = xmlObject.firstChild.data

            words = line.split(' ')

            self.bloc.append(words)
            self.tipus.append('text')

            for word in words:
                tmpSurf = self.font.render(word, 1, Constants.colorBlack)
                surf = pygame.Surface((self.font.size(word))).convert()
                surf.fill(self.backgroundColor)
                if (self.xActCell +
                        self.font.size(word)[0]) > self.Rect.width - 10:
                    self.xActCell = self.X_NEW_LINE
                    self.yActCell += self.OFFSET_TOP_NEW_LINE

                surf.blit(tmpSurf, (0, 0))

                rect = pygame.Rect((self.xActCell, self.yActCell),
                                   (surf.get_size()))
                textCell = TextCell(rect, self.idCell, 'text')

                contentCell = ContentCell()
                contentCell.img = surf.copy()
                if (self.isOrder != None):
                    contentCell.id = None
                else:
                    contentCell.id = self.idCell
                    self.idCell = self.idCell + 1
                textCell.contentCell = contentCell

                self.textCells.append(textCell)

                #self.idCell = self.idCell + 1
                self.xActCell += rect.width + 5
                if self.xActCell >= self.Rect.width - 10:
                    self.xActCell = self.X_NEW_LINE
                    self.yActCell += self.OFFSET_TOP_NEW_LINE

        elif type == 'text2':

            if (xmlObject == '\n'):
                self.bloc.append('\n')
                self.tipus.append('return')

            else:
                line = xmlObject.firstChild.data

                try:
                    text = xmlObject.getElementsByTagName(
                        "text")[0].firstChild.data
                    line = text
                except:
                    pass

                words = line.split(' ')

                self.bloc.append(words)
                self.numeracio.append(self.numCells)
                self.tipus.append('text2')
                self.lenTipus2 += 1

                for word in words:
                    tmpSurf = self.font.render(word, 1, Constants.colorLila)
                    surf = pygame.Surface((self.font.size(word))).convert()
                    surf.fill(Constants.colorBlack)
                    if (self.xActCell +
                            self.font.size(word)[0]) > self.Rect.width - 10:
                        self.xActCell = self.X_NEW_LINE
                        self.yActCell += self.OFFSET_TOP_NEW_LINE

                    surf.blit(tmpSurf, (0, 0))

                    rect = pygame.Rect((self.xActCell, self.yActCell),
                                       (surf.get_size()))
                    textCell = TextCell(rect, self.idCell, 'text')

                    contentCell = ContentCell()
                    contentCell.img = surf.copy()
                    contentCell.id = self.id
                    textCell.contentCell = contentCell

                    textCell.contentCell.id = self.id

                    self.textCells2.append(textCell)

                    self.numCells += 1

                    #self.idCell = self.idCell + 1
                    self.xActCell += rect.width + 5
                    if self.xActCell >= self.Rect.width - 10:
                        self.xActCell = self.X_NEW_LINE
                        self.yActCell += self.OFFSET_TOP_NEW_LINE

                self.ids.append(self.id)

                self.id += 1

        elif type == 'cell':
            try:
                width = int(xmlObject.getAttribute('width'))
                height = int(xmlObject.getAttribute('height'))
                image = xmlObject.getAttribute('image')
                image = self.mediaBag[image]
                fullPath = self.pathToMedia + '/' + image

                cellRect = pygame.Rect(self.xActCell, self.yActCell, width,
                                       height)
                cell = Cell(cellRect, display_surf, self.idCell, True)

                contentCell = ContentCell()
                contentCell.id = self.idCell
                contentCell.img = pygame.Surface((width, height))
                cellImg = pygame.image.load(fullPath).convert_alpha()
                cellImg = pygame.transform.scale(cellImg, (width, height))

                contentCell.img.blit(cellImg, (0, 0))
                cell.contentCell = contentCell

                self.textCells.append(cell)
                self.idCell += 1
                self.xActCell += width + int(
                    (Constants.ACTIVITY_WIDTH -
                     (self.numCells * width)) / self.numCells)
            except:
                pass

        elif type == 'textField':
            textField = TextField(xmlObject, self.font, self.backgroundColor)
            textField.Load(self.xActCell, self.yActCell, display_surf)
            textCell = TextCell(None, self.idCell, 'textField')
            textCell.contentCell = textField
            self.textCells.append(textCell)
            self.idCell += 1
            self.xActCell = self.X_NEW_LINE
            self.yActCell += textField.textCell.Rect.height + self.OFFSET_TOP_NEW_LINE

        elif type == 'target':
            try:
                '''Si el target es de tipus optionList'''
                xmlObject.getElementsByTagName('optionList')

                if (self.xActCell + Constants.widthOpt +
                        self.font.size('V')[0]) > self.Rect.width:
                    self.xActCell = self.X_NEW_LINE
                    self.yActCell += self.OFFSET_TOP_NEW_LINE

                option = OptionList(xmlObject, self.font)
                option.Load(self.xActCell, self.yActCell, display_surf)

                optionCell = TextCell(None, self.idCell, 'option')
                optionCell.contentCell = option

                self.textCells.append(optionCell)

                self.idCell = self.idCell + 1
                self.xActCell += option.textCell.Rect.width + option.openCell.Rect.width + 5
                if self.xActCell >= self.Rect.width:
                    self.xActCell = self.X_NEW_LINE
                    self.yActCell += self.OFFSET_TOP_NEW_LINE
                return
            except:
                print 'no es optionList'

            try:
                '''Si el target es de tipus response'''
                xmlObject.getElementsByTagName('response')
                print 'es de tipus response'
                resp = Response(xmlObject, self.font, self.backgroundColor)
                resp.Load(self.xActCell, self.yActCell, display_surf)

                respCell = TextCell(None, self.idCell, 'response')
                respCell.contentCell = resp

                self.textCells.append(respCell)

                self.idCell += 1
                self.xActCell += respCell.contentCell.totalWidth + 5
                if self.xActCell >= self.Rect.width:
                    self.xActCell = self.X_NEW_LINE
                    self.yActCell += self.OFFSET_TOP_NEW_LINE
                return
            except:
                print 'no es de tipus response'
예제 #5
0
    def __init__(self, session):
        '''constructor'''
        gtk.VBox.__init__(self)

        self.session = session
        self.config_dir = session.config_dir
        self._enabled = True

        Avatar = extension.get_default('avatar')

        self.avatar = Avatar(cellDimention=48)

        self.avatarBox = gtk.EventBox()
        self.avatarBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.avatarBox.connect('button-press-event', self.on_avatar_click)
        self.avatarBox.add(self.avatar)
        self.avatarBox.set_tooltip_text(_('Click here to set your avatar'))
        self.avatarBox.set_border_width(4)

        self.avatar_path = self.config_dir.get_path("last_avatar")

        if not self.session.config_dir.file_readable(self.avatar_path):
            path = gui.theme.user
        else:
            path = self.avatar_path
        self.avatar.set_from_file(path)

        self.nick = TextField.TextField(session.contacts.me.display_name,
                                        session.contacts.me.account, False)
        self.nick.set_tooltip_text(_('Click here to set your nick name'))
        self.status = StatusButton.StatusButton(session)
        self.status.set_tooltip_text(_('Click here to change your status'))
        self.status.set_status(session.contacts.me.status)
        self.search = gtk.ToggleButton()
        self.search.set_tooltip_text(_('Search (Ctrl+F)'))
        self.mail = gtk.Button(label="(0)")
        self.mail.set_tooltip_text(_('Click here to access your mail'))

        self.mail.get_settings().set_property("gtk-button-images", True)

        self.mail.set_image(gtk.image_new_from_file(gui.theme.mailbox))
        self.mail.set_relief(gtk.RELIEF_NONE)
        self.search.set_image(
            gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU))
        self.search.set_relief(gtk.RELIEF_NONE)

        self.message = TextField.TextField(
            session.contacts.me.message, '[C=#969696][I]' +
            _("Click here to set your message") + '[/I][/C]', True)
        self.message.set_tooltip_text(_('Click here to set your message'))
        self.toolbar = gtk.HBox()

        hbox = gtk.HBox()
        hbox.set_border_width(1)
        hbox.pack_start(self.avatarBox, False)

        vbox = gtk.VBox()
        nick_hbox = gtk.HBox()
        nick_hbox.pack_start(self.nick, True, True)
        nick_hbox.pack_start(self.mail, False)
        nick_hbox.pack_start(self.search, False)
        vbox.pack_start(nick_hbox, False)
        message_hbox = gtk.HBox()
        message_hbox.pack_start(self.message, True, True)
        message_hbox.pack_start(self.status, False)
        vbox.pack_start(message_hbox, False)

        hbox.pack_start(vbox, True, True)

        self.pack_start(hbox, True, True)
        self.pack_start(self.toolbar, False)

        hbox.show()
        nick_hbox.show()
        message_hbox.show()
        vbox.show()

        session.signals.message_change_succeed.subscribe(
            self.on_message_change_succeed)
        session.signals.media_change_succeed.subscribe(
            self.on_media_change_succeed)
        session.signals.status_change_succeed.subscribe(
            self.on_status_change_succeed)
        session.signals.contact_list_ready.subscribe(
            self.on_contact_list_ready)
        session.signals.picture_change_succeed.subscribe(
            self.on_picture_change_succeed)
        session.signals.profile_get_succeed.subscribe(
            self.on_profile_update_succeed)
        session.signals.profile_set_succeed.subscribe(
            self.on_profile_update_succeed)
예제 #6
0
    def __init__(self, session):
        '''constructor'''
        gtk.VBox.__init__(self)

        self.session = session
        self.config_dir = session.config_dir
        self._enabled = True

        Avatar = extension.get_default('avatar')
        AvatarManager = extension.get_default('avatar manager')

        self.avatar = Avatar(cellDimention=48)

        self.avatarBox = gtk.EventBox()
        self.avatarBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.avatarBox.connect('button-press-event', self.on_avatar_click)
        self.avatarBox.add(self.avatar)
        self.avatarBox.set_tooltip_text(_('Click here to set your avatar'))

        self.avatar_path = self.config_dir.get_path("last_avatar")
        self.avatar_manager = AvatarManager(self.session)

        if not self.session.config_dir.file_readable(self.avatar_path):
            path = gui.theme.user
        else:
            path = self.avatar_path
        self.avatar.set_from_file(path)

        self.nick = TextField.TextField(session.contacts.me.display_name, '',
                                        False)
        self.status = StatusButton.StatusButton(session)
        self.status.set_status(session.contacts.me.status)
        self.search = gtk.ToggleButton()
        self.search.set_image(
            gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU))
        self.search.set_relief(gtk.RELIEF_NONE)

        self.message = TextField.TextField(
            session.contacts.me.message,
            '<span style="italic">&lt;Click here to set message&gt;</span>',
            True)
        self.toolbar = gtk.HBox()

        hbox = gtk.HBox()
        hbox.set_border_width(2)
        hbox.pack_start(self.avatarBox, False)

        vbox = gtk.VBox()
        nick_hbox = gtk.HBox()
        nick_hbox.pack_start(self.nick, True, True)
        nick_hbox.pack_start(self.search, False)
        vbox.pack_start(nick_hbox, False)
        message_hbox = gtk.HBox()
        message_hbox.pack_start(self.message, True, True)
        message_hbox.pack_start(self.status, False)
        vbox.pack_start(message_hbox, False)

        hbox.pack_start(vbox, True, True)

        self.pack_start(hbox, True, True)
        self.pack_start(self.toolbar, False)

        hbox.show()
        nick_hbox.show()
        message_hbox.show()
        vbox.show()

        session.signals.message_change_succeed.subscribe(
            self.on_message_change_succeed)
        session.signals.media_change_succeed.subscribe(
            self.on_media_change_succeed)
        session.signals.status_change_succeed.subscribe(
            self.on_status_change_succeed)
        session.signals.contact_list_ready.subscribe(
            self.on_contact_list_ready)
        session.signals.picture_change_succeed.subscribe(
            self.on_picture_change_succeed)
        session.signals.profile_get_succeed.subscribe(
            self.on_profile_update_succeed)
        session.signals.profile_set_succeed.subscribe(
            self.on_profile_update_succeed)