Пример #1
0
    def __init__(self, controller):
        '''Constructor'''
        gtk.HBox.__init__(self)

        self.controller = controller
        self.theme = controller.theme
        self.config = controller.config

        self.set_border_width(2)

        self.smileysCache = {}
        self.hasSmilies = True

        self.tNick = gtk.Entry(max=129)
        self.tNick.set_text(self.controller.msn.nick.replace('\n', ' '))
        self.tNick.set_no_show_all(True)
        
        self.lNick = SmileyLabel('', self.controller.widget_style)
        self.lNick.set_ellipsize(pango.ELLIPSIZE_END)

        self.bNick = gtk.Button()
        self.bNick.set_relief(gtk.RELIEF_NONE)
        self.bNick.set_alignment(0, 0)
        self.bNick.add(self.lNick)

        iconMail = self.theme.getSmiley("(e)") #email icon

        self.mailButton = ImageButton(iconMail, '(0)')
        self.mailButton.set_relief(gtk.RELIEF_NONE)
        self.mailButton.set_tooltip_text(_('Click here to access your mail'))

        self.statusIcon = self.theme.statusToPixbuf(self.controller.msn.status)
        self.statusButton = ImageButton(self.statusIcon)
        self.controller.msn.connect('self-status-changed',\
                                          self.update_status_icon)
        self.statusButton.set_relief(gtk.RELIEF_NONE)
        self.statusButton.set_tooltip_text(_('Click here to change your status'))

        self.statusMenu = StatusMenu.StatusMenu(self.controller)

        self.tPersonalMessage = gtk.Entry(max=129)
        self.tPersonalMessage.set_text(self.controller.contacts.get_message())
        self.tPersonalMessage.set_no_show_all(True)
        self.lPersonalMessage = SmileyLabel('',
            self.controller.widget_style)
        self.lPersonalMessage.set_ellipsize(pango.ELLIPSIZE_END)
        self.bPersonalMessage = gtk.Button()
        self.bPersonalMessage.set_relief(gtk.RELIEF_NONE)
        self.bPersonalMessage.set_alignment(0, 0)
        self.bPersonalMessage.add(self.lPersonalMessage)

        mediaIcon = self.theme.getSmiley("(8)") #media icon
        # at the bottom is the code to handle starting toggled
        self.mediaButton = ImageToggleButton(mediaIcon)
        self.mediaButton.set_relief(gtk.RELIEF_NONE)
        
        try: # why, oh why, gtk must be so angry?
            self.mediaButton.set_tooltip_text(_('Toggle sending current playing song'))
        except:
            pass
            
        self.lMedia = gtk.Label(_("No media playing"))
        self.lMedia.set_ellipsize(pango.ELLIPSIZE_END)
        self.bMedia = gtk.Button()
        self.bMedia.set_relief(gtk.RELIEF_NONE)
        self.bMedia.set_alignment(0, 0)
        self.bMedia.add(self.lMedia)
        self.bMedia.connect('clicked', self.onMediaClicked)
        self.lMedia.set_no_show_all(True)
        self.bMedia.set_no_show_all(True)

        self.bNick.set_tooltip_text(_('Click here to set your nick name'))
        self.bPersonalMessage.set_tooltip_text(_('Click here to set your personal message'))
        self.bMedia.set_tooltip_text(_('Your current media'))

        self.image = Widgets.avatarHolder(cellDimention = 48)
        self.imageEventBox = gtk.EventBox()
        self.imageEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.imageEventBox.connect('button-press-event', self.avatarClicked)
        self.imageEventBox.add(self.image)
        self.imageEventBox.set_tooltip_text(_('Click here to set your avatar'))
        #frame = gtk.AspectFrame()
        #frame.add(self.imageEventBox)
        if self.controller.avatar:
            self.image.set_from_pixbuf(self.controller.avatar.getThumb())
        else:
            self.pixbuf = self.controller.theme.getImage('userPanel')
            self.image.set_from_pixbuf(self.pixbuf)

        self.tNick.connect('activate', self.on_nick_changed, None, False)
        self.tNick.connect('focus-out-event', self.on_nick_changed, True)
        self.bNick.connect('clicked', self.on_nick_clicked)
        self.tPersonalMessage.connect('activate', self.on_pm_changed, None, False)
        self.tPersonalMessage.connect('focus-out-event', self.on_pm_changed, True)
        self.bPersonalMessage.connect('clicked', self.on_pm_clicked)
        self.mediaButton.connect("toggled", self.onToggleMedia)

        self.mailButton.connect('clicked', self.onMaiButtonClicked)

        self.controller.msn.connect('self-personal-message-changed',
            self.personalMessageChanged)
        self.controller.msn.connect('self-nick-changed', self.selfNickChanged)
        self.controller.msn.connect('self-current-media-changed',
            self.currentMediaChanged)

        self.mailButton.setText('('+str(self.controller.getUnreadMails()) +')')
        self.controller.msn.connect('initial-mail-notification',
            self.updateMailCount)
        self.controller.msn.connect('new-mail-notification',
            self.updateMailCount)
        self.controller.msn.connect('mail-movement-notification',
            self.updateMailCount)

        self.statusButton.connect('button-press-event', self.pop_up_status_menu)

        self.hbox = gtk.HBox()
        self.pack_start(self.imageEventBox, False, False)

        self.vbox1 = gtk.VBox()
        self.vbox2 = gtk.VBox(True)
        self.hbox1 = gtk.HBox()
        self.hbox2 = gtk.HBox()

        self.hbox1.pack_start(self.tNick, True, True)
        self.hbox1.pack_start(self.bNick, True, True)

        self.hbox2.pack_start(self.tPersonalMessage, True, True)
        self.hbox2.pack_start(self.bPersonalMessage, True, True)
        self.hbox2.pack_start(self.bMedia, True, True)

        self.vbox2h1 = gtk.HBox()
        self.vbox2h1.pack_end(self.mailButton, True, False)
        self.vbox2h1aligned = gtk.Alignment(1, 0, 0, 0)
        self.vbox2h1aligned.add(self.vbox2h1)

        self.vbox2h2 = gtk.HBox()
        self.vbox2h2.pack_start(self.mediaButton, True, False)
        self.vbox2h2.pack_end(self.statusButton, True, False)
        self.vbox2h2aligned = gtk.Alignment(1, 0, 0, 0)
        self.vbox2h2aligned.add(self.vbox2h2)
        
        self.vbox2.pack_start(self.vbox2h1aligned, True, False)
        self.vbox2.pack_start(self.vbox2h2aligned, True, False)

        self.vbox1.pack_start(self.hbox1, True, False, 1)
        self.vbox1.pack_start(self.hbox2, True, False, 1)

        self.hbox.pack_start(self.vbox1, True, True)
        self.hbox.pack_start(self.vbox2, False, False)
        self.pack_start(self.hbox)

        self.show_all()

        # if in the config is active we activate it emitting the toggled signal
        if controller.config.user['mediaEnabled']:
            self.mediaButton.set_active(True)

        self.mediaButton.hide()

        try:
            if not DOMAIN_REGEXP.match(self.controller.userEmail.split("@")[1]):
                self.mailButton.hide()
        except Exception, e:
            print "error! " + str(e)
Пример #2
0
 def __init__(self, controller):
     '''Constructor'''        
     self.tooltip = gtk.Tooltips()
     self.controller = controller
     self.theme = controller.theme
     self.config = controller.config
     gtk.HBox.__init__(self)
     self.set_border_width(4)
     self.set_spacing(2)
     self.smileysCache = {}
     self.hasSmilies = True
     self.tNick = gtk.Entry(max=129)
     self.tNick.set_text(self.controller.msn.nick)
     self.tNick.set_no_show_all(True)
     if self.config.user['useFancyLabel']:
         self.lNick = FancyLabel.FancyLabel(self.controller)
         self.lNick.set_wrap(False) 
     else:
         self.lNick = SmileyLabel('', self.controller.widget_style)
         self.lNick.set_ellipsize(pango.ELLIPSIZE_END)
     self.bNick = gtk.Button()
     self.bNick.set_relief(gtk.RELIEF_NONE)
     self.bNick.set_alignment(0, 0)
     self.bNick.add(self.lNick)
     nick = self.controller.msn.nick
     if not self.config.user['useFancyLabel']:
         parser = self.controller.unifiedParser.getParser(nick, \
             PangoDataType)
         nick = parser.get(self.hasSmilies, self.smileysCache)
     self.lNick.set_markup(nick)
     iconMail = self.theme.getSmiley("(e)") #email icon
     self.mailButton = ImageButton(iconMail, '(0)')
     self.mailButton.set_relief(gtk.RELIEF_NONE)
     self.tPersonalMessage = gtk.Entry()
     self.tPersonalMessage.set_text(self.controller.contacts.get_message())
     self.tPersonalMessage.set_no_show_all(True)
     self.lPersonalMessage = SmileyLabel('', 
         self.controller.widget_style)
     self.lPersonalMessage.set_ellipsize(pango.ELLIPSIZE_END)
     self.bPersonalMessage = gtk.Button()
     self.bPersonalMessage.set_relief(gtk.RELIEF_NONE)
     self.bPersonalMessage.set_alignment(0, 0)
     self.bPersonalMessage.add(self.lPersonalMessage)
     pm = self.controller.contacts.get_message()
     if pm != '':
         parser = self.controller.unifiedParser.getParser(pm, PangoDataType)
         pm = parser.get(self.hasSmilies, self.smileysCache)
         self.lPersonalMessage.set_markup(pm)
     else:
         self.lPersonalMessage.set_text('<i>&lt;' + _('Click here to set your personal message') + '&gt;</i>')
     mediaIcon = self.theme.getSmiley("(8)") #media icon
     self.mediaButton = ImageToggleButton(mediaIcon)
     self.mediaButton.set_relief(gtk.RELIEF_NONE)
     self.lMedia = gtk.Label(_("No media playing"))
     self.lMedia.set_ellipsize(pango.ELLIPSIZE_END)
     self.bMedia = gtk.Button()
     self.bMedia.set_relief(gtk.RELIEF_NONE)
     self.bMedia.set_alignment(0, 0)
     self.bMedia.add(self.lMedia)
     self.bMedia.connect('clicked', self.onMediaClicked)
     self.lMedia.set_no_show_all(True)
     self.bMedia.set_no_show_all(True)
     self.tooltip.set_tip(self.bNick, _('Click here to set your nick name'))
     self.tooltip.set_tip(self.bPersonalMessage, _('Click here to set your personal message'))
     self.tooltip.set_tip(self.bMedia, _('Your current media'))
     self.image = Widgets.avatarHolder(cellDimention = 48)
     self.imageEventBox = gtk.EventBox()
     self.imageEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
     self.imageEventBox.connect('button-press-event', self.avatarClicked)
     self.imageEventBox.add(self.image)
     if self.controller.avatar != None:
         self.image.set_from_pixbuf(self.controller.avatar.getThumb())
     else:
         self.pixbuf = self.controller.theme.getImage('userPanel')
         self.image.set_from_pixbuf(self.pixbuf)
     self.tNick.connect('activate', self.on_nick_changed)
     self.tNick.connect('focus-out-event', self.on_nick_changed)
     self.bNick.connect('clicked', self.on_nick_clicked)
     self.tPersonalMessage.connect('activate', self.on_pm_changed)
     self.tPersonalMessage.connect('focus-out-event', self.on_pm_changed)
     self.bPersonalMessage.connect('clicked', self.on_pm_clicked)
     self.mediaButton.connect("toggled", self.onToggleMedia)
     self.mailButton.connect('clicked', self.onMaiButtonClicked)
     self.controller.msn.connect('self-personal-message-changed', self.personalMessageChanged)
     self.controller.msn.connect('self-nick-changed', self.selfNickChanged)
     self.controller.msn.connect('self-current-media-changed', self.currentMediaChanged)
     self.mailButton.setText('('+str(self.controller.getUnreadMails()) +')')
     self.controller.msn.connect('initial-mail-notification', self.updateMailCount)
     self.controller.msn.connect('new-mail-notification', self.updateMailCount)
     self.controller.msn.connect('mail-movement-notification', self.updateMailCount)
     self.hbox = gtk.HBox()
     self.pack_start(self.imageEventBox, False, False)
     self.vbox1 = gtk.VBox()
     self.vbox2 = gtk.VBox(True)
     self.hbox1 = gtk.HBox()
     self.hbox2 = gtk.HBox()
     self.hbox1.pack_start(self.tNick, True, True)
     self.hbox1.pack_start(self.bNick, True, True)
     self.hbox2.pack_start(self.tPersonalMessage, True, True)
     self.hbox2.pack_start(self.bPersonalMessage, True, True)
     self.hbox2.pack_start(self.bMedia, True, True)
     self.vbox2h1 = gtk.HBox()
     self.vbox2h1.pack_start(self.mailButton, True, True)
     self.vbox2h2 = gtk.HBox()
     self.vbox2h2.pack_start(self.mediaButton, True, True)
     self.vbox2.pack_start(self.vbox2h1, True, False)
     self.vbox2.pack_start(self.vbox2h2, True, False)
     self.vbox1.pack_start(self.hbox1, True, False, 1)
     self.vbox1.pack_start(self.hbox2, True, False, 1)
     self.hbox.pack_start(self.vbox1, True, True)
     self.hbox.pack_start(self.vbox2, False, False)
     self.pack_start(self.hbox)
     self.show_all()
     if controller.config.user['mediaEnabled']:
         self.mediaButton.set_active(True)
     self.mediaButton.hide()
     try:
         if not DOMAIN_REGEXP.match(self.controller.userEmail.split("@")[1]):
             self.mailButton.hide()
     except Exception, e:
         print "error! " + str(e)
Пример #3
0
    def __init__(self, controller):
        '''Constructor'''
        gtk.HBox.__init__(self)

        self.controller = controller
        self.theme = controller.theme
        self.config = controller.config

        self.set_border_width(2)

        self.smileysCache = {}
        self.hasSmilies = True

        self.tNick = gtk.Entry(max=129)
        self.tNick.set_text(self.controller.msn.nick.replace('\n', ' '))
        self.tNick.set_no_show_all(True)

        self.lNick = SmileyLabel('', self.controller.widget_style)
        self.lNick.set_ellipsize(pango.ELLIPSIZE_END)

        self.bNick = gtk.Button()
        self.bNick.set_relief(gtk.RELIEF_NONE)
        self.bNick.set_alignment(0, 0)
        self.bNick.add(self.lNick)

        iconMail = self.theme.getSmiley("(e)")  #email icon

        self.mailButton = ImageButton(iconMail, '(0)')
        self.mailButton.set_relief(gtk.RELIEF_NONE)
        self.mailButton.set_tooltip_text(_('Click here to access your mail'))

        i = self.controller.contacts.get_status()
        status = self.controller.status_ordered[0][i]
        self.statusIcon = self.theme.statusToPixbuf(status)
        self.statusButton = ImageButton(self.statusIcon)
        self.statusButton.set_relief(gtk.RELIEF_NONE)
        self.statusButton.set_tooltip_text(
            _('Click here to change your status'))

        self.statusMenu = StatusMenu.StatusMenu(self.controller)

        self.tPersonalMessage = gtk.Entry(max=129)
        self.tPersonalMessage.set_text(self.controller.contacts.get_message())
        self.tPersonalMessage.set_no_show_all(True)
        self.lPersonalMessage = SmileyLabel('', self.controller.widget_style)
        self.lPersonalMessage.set_ellipsize(pango.ELLIPSIZE_END)
        self.bPersonalMessage = gtk.Button()
        self.bPersonalMessage.set_relief(gtk.RELIEF_NONE)
        self.bPersonalMessage.set_alignment(0, 0)
        self.bPersonalMessage.add(self.lPersonalMessage)

        mediaIcon = self.theme.getSmiley("(8)")  #media icon
        # at the bottom is the code to handle starting toggled
        self.mediaButton = ImageToggleButton(mediaIcon)
        self.mediaButton.set_relief(gtk.RELIEF_NONE)

        try:  # why, oh why, gtk must be so angry?
            self.mediaButton.set_tooltip_text(
                _('Toggle sending current playing song'))
        except:
            pass

        self.lMedia = gtk.Label(_("No media playing"))
        self.lMedia.set_ellipsize(pango.ELLIPSIZE_END)
        self.bMedia = gtk.Button()
        self.bMedia.set_relief(gtk.RELIEF_NONE)
        self.bMedia.set_alignment(0, 0)
        self.bMedia.add(self.lMedia)
        self.bMedia.connect('clicked', self.onMediaClicked)
        self.lMedia.set_no_show_all(True)
        self.bMedia.set_no_show_all(True)

        self.bNick.set_tooltip_text(_('Click here to set your nick name'))
        self.bPersonalMessage.set_tooltip_text(
            _('Click here to set your personal message'))
        self.bMedia.set_tooltip_text(_('Your current media'))

        self.image = Widgets.avatarHolder(cellDimention=48)
        self.imageEventBox = gtk.EventBox()
        self.imageEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.imageEventBox.connect('button-press-event', self.avatarClicked)
        self.imageEventBox.add(self.image)
        self.imageEventBox.set_tooltip_text(_('Click here to set your avatar'))
        #frame = gtk.AspectFrame()
        #frame.add(self.imageEventBox)
        if self.controller.avatar:
            self.image.set_from_pixbuf(self.controller.avatar.getThumb())
        else:
            self.pixbuf = self.controller.theme.getImage('userPanel')
            self.image.set_from_pixbuf(self.pixbuf)

        self.tNick.connect('activate', self.on_nick_changed)
        self.tNick.connect('focus-out-event', self.on_nick_changed)
        self.bNick.connect('clicked', self.on_nick_clicked)
        self.tPersonalMessage.connect('activate', self.on_pm_changed)
        self.tPersonalMessage.connect('focus-out-event', self.on_pm_changed)
        self.bPersonalMessage.connect('clicked', self.on_pm_clicked)
        self.mediaButton.connect("toggled", self.onToggleMedia)

        self.mailButton.connect('clicked', self.onMaiButtonClicked)

        self.controller.msn.connect('self-personal-message-changed',
                                    self.personalMessageChanged)
        self.controller.msn.connect('self-nick-changed', self.selfNickChanged)
        self.controller.msn.connect('self-current-media-changed',
                                    self.currentMediaChanged)

        self.mailButton.setText('(' + str(self.controller.getUnreadMails()) +
                                ')')
        self.controller.msn.connect('initial-mail-notification',
                                    self.updateMailCount)
        self.controller.msn.connect('new-mail-notification',
                                    self.updateMailCount)
        self.controller.msn.connect('mail-movement-notification',
                                    self.updateMailCount)

        self.statusButton.connect('button-press-event',
                                  self.pop_up_status_menu)
        self.controller.msn.connect('self-status-changed',\
                                          self.update_status_icon)

        self.hbox = gtk.HBox()
        self.pack_start(self.imageEventBox, False, False)

        self.vbox1 = gtk.VBox()
        self.vbox2 = gtk.VBox(True)
        self.hbox1 = gtk.HBox()
        self.hbox2 = gtk.HBox()

        self.hbox1.pack_start(self.tNick, True, True)
        self.hbox1.pack_start(self.bNick, True, True)

        self.hbox2.pack_start(self.tPersonalMessage, True, True)
        self.hbox2.pack_start(self.bPersonalMessage, True, True)
        self.hbox2.pack_start(self.bMedia, True, True)

        self.vbox2h1 = gtk.HBox()
        self.vbox2h1.pack_end(self.mailButton, True, False)
        self.vbox2h1aligned = gtk.Alignment(1, 0, 0, 0)
        self.vbox2h1aligned.add(self.vbox2h1)

        self.vbox2h2 = gtk.HBox()
        self.vbox2h2.pack_start(self.mediaButton, True, False)
        self.vbox2h2.pack_end(self.statusButton, True, False)
        self.vbox2h2aligned = gtk.Alignment(1, 0, 0, 0)
        self.vbox2h2aligned.add(self.vbox2h2)

        self.vbox2.pack_start(self.vbox2h1aligned, True, False)
        self.vbox2.pack_start(self.vbox2h2aligned, True, False)

        self.vbox1.pack_start(self.hbox1, True, False, 1)
        self.vbox1.pack_start(self.hbox2, True, False, 1)

        self.hbox.pack_start(self.vbox1, True, True)
        self.hbox.pack_start(self.vbox2, False, False)
        self.pack_start(self.hbox)

        self.show_all()

        # if in the config is active we activate it emitting the toggled signal
        if controller.config.user['mediaEnabled']:
            self.mediaButton.set_active(True)

        self.mediaButton.hide()

        try:
            if not DOMAIN_REGEXP.match(
                    self.controller.userEmail.split("@")[1]):
                self.mailButton.hide()
        except Exception, e:
            print "error! " + str(e)