Esempio n. 1
0
    def clone_image(self, image):
        storage = image.get_storage_type()
        if storage == gtk.IMAGE_PIXMAP:
            img, mask = image.get_pixmap()
            return gtk.image_new_from_pixmap(img, mask)
        if storage == gtk.IMAGE_IMAGE:
            img, mask = image.get_image()
            return gtk.image_new_from_image(img, mask)
        if storage == gtk.IMAGE_PIXBUF:
            return gtk.image_new_from_pixbuf(image.get_pixbuf())
        if storage == gtk.IMAGE_STOCK:
            img, size = image.get_stock()
            return gtk.image_new_from_stock(img, size)
        if storage == gtk.IMAGE_ICON_SET:
            img, size = image.get_icon_set()
            return gtk.image_new_from_icon_set(img, size)
        if storage == gtk.IMAGE_ANIMATION:
            return gtk.image_new_from_animation(image.get_animation())
        if storage == gtk.IMAGE_ICON_NAME:
            img, size = image.get_icon_name()
            return gtk.image_new_from_icon_name(img, size)


#		if storage == gtk.IMAGE_EMPTY:
        img = gtk.Image()
        img.set_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU)
        return img
Esempio n. 2
0
	def clone_image(self, image):
		storage = image.get_storage_type()
		if storage == gtk.IMAGE_PIXMAP:
			img, mask = image.get_pixmap()
			return gtk.image_new_from_pixmap(img, mask)
		if storage == gtk.IMAGE_IMAGE:
			img, mask = image.get_image()
			return gtk.image_new_from_image(img, mask)
		if storage == gtk.IMAGE_PIXBUF:
			return gtk.image_new_from_pixbuf(image.get_pixbuf())
		if storage == gtk.IMAGE_STOCK:
			img, size = image.get_stock()
			return gtk.image_new_from_stock(img, size)
		if storage == gtk.IMAGE_ICON_SET:
			img, size = image.get_icon_set()
			return gtk.image_new_from_icon_set(img, size)
		if storage == gtk.IMAGE_ANIMATION:
			return gtk.image_new_from_animation(image.get_animation())
		if storage == gtk.IMAGE_ICON_NAME:
			img, size = image.get_icon_name()
			return gtk.image_new_from_icon_name(img, size)
#		if storage == gtk.IMAGE_EMPTY:
		img = gtk.Image()
		img.set_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU)
		return img
Esempio n. 3
0
    def __init__(self, callback, avatar_path):

        gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0,
            yscale=1.0)
        self.callback = callback
        #for reconnecting
        self.reconnect_timer_id = None
        if avatar_path == '':
            self.avatar_path = gui.theme.logo
        else:
            self.avatar_path = avatar_path

        th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None,
                animated=True)
        self.throbber = gtk.image_new_from_animation(th_pix)

        self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.b_cancel.connect('clicked', self._on_cancel_clicked)
        self.b_cancel.set_border_width(8)

        self.label = gtk.Label()
        self.label.set_markup('<b>Connecting...</b>')
        self.label_timer = gtk.Label()
        self.label_timer.set_markup('<b>Connection error!\n </b>')

        self.img_account = gtk.Image()
        self.img_account.set_from_pixbuf(utils.safe_gtk_pixbuf_load(self.avatar_path,(96,96)))

        al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.2)
        al_button_cancel = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.15)
        al_label = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_label_timer = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_logo = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)

        al_throbber.add(self.throbber)
        al_button_cancel.add(self.b_cancel)
        al_label.add(self.label)
        al_label_timer.add(self.label_timer)
        al_logo.add(self.img_account)

        vbox = gtk.VBox()
        vbox.pack_start(al_logo, True, False)
        vbox.pack_start(al_label, True, False)
        vbox.pack_start(al_label_timer, True, False)
        vbox.pack_start(al_throbber, True, False)
        vbox.pack_start(al_button_cancel, True, True)

        self.add(vbox)
        vbox.show_all()

        self.dim = 96
        gobject.timeout_add(20, self.do_animation)

        self.label.hide()
        self.throbber.hide()
        self.label_timer.hide()
Esempio n. 4
0
    def _makeUI(self):
        self.set_spacing(6)
        anim = gtk.gdk.PixbufAnimation(get_pixmap_dir() + "/busy.gif")
        self.busyanim = gtk.image_new_from_animation(anim)
        self.busyanim.show()

        self.erroricon = gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING,
                                                  gtk.ICON_SIZE_SMALL_TOOLBAR)
        self.erroricon.show()

        self.infolabel = gtk.Label(self._importingmessage)
        self.infolabel.set_alignment(0, 0.5)
        self.infolabel.show()

        self.questionbutton = gtk.Button()
        self.questionbutton.set_image(
            gtk.image_new_from_stock(gtk.STOCK_INFO,
                                     gtk.ICON_SIZE_SMALL_TOOLBAR))
        self.questionbutton.connect("clicked", self._questionButtonClickedCb)
        self.questionbutton.show()
        self._questionshowing = False

        self.pack_start(self.busyanim, expand=False)
        self._busyshowing = True
        self.pack_start(self.infolabel, expand=True, fill=True)
Esempio n. 5
0
    def __get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if contact.picture:
            try:
                animation = gtk.gdk.PixbufAnimation(contact.picture)
            except gobject.GError:
                pix = utils.safe_gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
                return picture

            if animation.is_static_image():
                pix = utils.safe_gtk_pixbuf_load(contact.picture,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
            else:
                picture = gtk.image_new_from_animation(animation)

        else:
            pix = utils.safe_gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
            picture = gtk.image_new_from_pixbuf(pix)

        return picture
Esempio n. 6
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if contact.picture:
            try:
                animation = gtk.gdk.PixbufAnimation(contact.picture)
            except gobject.GError:
                pix = utils.safe_gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
                return picture

            if animation.is_static_image():
                pix = utils.safe_gtk_pixbuf_load(contact.picture,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
            else:
                picture = gtk.image_new_from_animation(animation)

        else:
            pix = utils.safe_gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
            picture = gtk.image_new_from_pixbuf(pix)

        return picture
Esempio n. 7
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if contact.picture:
            try:
                animation = gtk.gdk.PixbufAnimation(contact.picture)
            except gobject.GError:
                pix = utils.gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
                return picture

            if animation.is_static_image():
                pix = utils.gtk_pixbuf_load(contact.picture,
                        (self.avatar_size, self.avatar_size))
                if bool(contact.blocked)==True:
                    pixbufblock=utils.gtk_pixbuf_load(gui.theme.blocked_overlay)
                    utils.simple_images_overlap(pix,pixbufblock,-pixbufblock.props.width,-pixbufblock.props.width)
                picture = gtk.image_new_from_pixbuf(pix)
            else:
                picture = gtk.image_new_from_animation(animation)

        else:
            pix = utils.gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
            if bool(contact.blocked)==True:
                pixbufblock=utils.gtk_pixbuf_load(gui.theme.blocked_overlay)
                utils.simple_images_overlap(pix,pixbufblock,-pixbufblock.props.width,-pixbufblock.props.width)
            picture = gtk.image_new_from_pixbuf(pix)

        return picture
Esempio n. 8
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if contact.picture:
            # TODO: This could be handled in AvatarManager in the same
            # way as avatars from the Avatar class
            try:
                animation = gtk.gdk.PixbufAnimation(contact.picture)
            except gobject.GError:
                pix = utils.gtk_pixbuf_load(
                    gui.theme.image_theme.user,
                    (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
                return picture

            if animation.is_static_image():
                pix = utils.gtk_pixbuf_load(
                    contact.picture, (self.avatar_size, self.avatar_size))

                if bool(contact.blocked):
                    pixbufblock = utils.gtk_pixbuf_load(
                        gui.theme.image_theme.blocked_overlay)
                    utils.simple_images_overlap(pix, pixbufblock,
                                                -pixbufblock.props.width,
                                                -pixbufblock.props.width)

                picture = gtk.image_new_from_pixbuf(pix)
            else:
                myanimation = utils.simple_animation_scale(
                    contact.picture, self.avatar_size, self.avatar_size)

                if bool(contact.blocked):
                    pixbufblock = utils.gtk_pixbuf_load(
                        gui.theme.image_theme.blocked_overlay)
                    static_image = myanimation.get_static_image()
                    pix = static_image.scale_simple(self.avatar_size,
                                                    self.avatar_size,
                                                    gtk.gdk.INTERP_BILINEAR)
                    utils.simple_images_overlap(pix, pixbufblock,
                                                -pixbufblock.props.width,
                                                -pixbufblock.props.width)
                    picture = gtk.image_new_from_pixbuf(pix)
                else:
                    picture = gtk.image_new_from_animation(myanimation)
        else:
            pix = utils.gtk_pixbuf_load(gui.theme.image_theme.user,
                                        (self.avatar_size, self.avatar_size))

            if bool(contact.blocked):
                pixbufblock = utils.gtk_pixbuf_load(
                    gui.theme.image_theme.blocked_overlay)
                utils.simple_images_overlap(pix, pixbufblock,
                                            -pixbufblock.props.width,
                                            -pixbufblock.props.width)

            picture = gtk.image_new_from_pixbuf(pix)

        return picture
Esempio n. 9
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if contact.picture:
            # TODO: This could be handled in AvatarManager in the same
            # way as avatars from the Avatar class
            try:
                animation = gtk.gdk.PixbufAnimation(contact.picture)
            except gobject.GError:
                pix = utils.gtk_pixbuf_load(gui.theme.image_theme.user,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
                return picture

            if animation.is_static_image():
                pix = utils.gtk_pixbuf_load(contact.picture,
                        (self.avatar_size, self.avatar_size))

                if bool(contact.blocked):
                    pixbufblock=utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay)
                    utils.simple_images_overlap(pix, pixbufblock,
                                                -pixbufblock.props.width,
                                                -pixbufblock.props.width)

                picture = gtk.image_new_from_pixbuf(pix)
            else:
                myanimation = utils.simple_animation_scale(contact.picture,
                                                           self.avatar_size,
                                                           self.avatar_size)

                if bool(contact.blocked):
                    pixbufblock=utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay)
                    static_image = myanimation.get_static_image()
                    pix = static_image.scale_simple(self.avatar_size,
                                                    self.avatar_size,
                                                    gtk.gdk.INTERP_BILINEAR)

                    utils.simple_images_overlap(pix, pixbufblock,
                                                -pixbufblock.props.width,
                                                -pixbufblock.props.width)

                    picture = gtk.image_new_from_pixbuf(pix)
                else:
                    picture = gtk.image_new_from_animation(myanimation)
        else:
            pix = utils.gtk_pixbuf_load(gui.theme.image_theme.user,
                        (self.avatar_size, self.avatar_size))

            if bool(contact.blocked):
                pixbufblock=utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay)
                utils.simple_images_overlap(pix, pixbufblock,
                                            -pixbufblock.props.width,
                                            -pixbufblock.props.width)

            picture = gtk.image_new_from_pixbuf(pix)

        return picture
Esempio n. 10
0
    def __init__(self, callback, avatar_path):

        gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0,
            yscale=1.0)
        self.callback = callback

        #for reconnecting
        self.reconnect_timer_id = None

        Avatar = extension.get_default('avatar')

        th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None,
                animated=True)
        self.throbber = gtk.image_new_from_animation(th_pix)

        self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.b_cancel.connect('clicked', self._on_cancel_clicked)
        self.b_cancel.set_border_width(8)

        self.label = gtk.Label()
        self.label.set_markup('<b>Connecting...</b>')
        self.label_timer = gtk.Label()
        self.label_timer.set_markup('<b>Connection error!\n </b>')

        self.avatar = Avatar(cellDimention=96)
        self.avatar.set_from_file(avatar_path)

        al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.2)
        al_button_cancel = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.15)
        al_label = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_label_timer = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_logo = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)

        al_throbber.add(self.throbber)
        al_button_cancel.add(self.b_cancel)
        al_label.add(self.label)
        al_label_timer.add(self.label_timer)
        al_logo.add(self.avatar)

        vbox = gtk.VBox()
        vbox.pack_start(al_logo, True, False)
        vbox.pack_start(al_label, True, False)
        vbox.pack_start(al_label_timer, True, False)
        vbox.pack_start(al_throbber, True, False)
        vbox.pack_start(al_button_cancel, True, True)

        self.add(vbox)
        vbox.show_all()

        self.label_timer.hide()
Esempio n. 11
0
    def __init__(self, callback, avatar_path):

        gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0,
            yscale=1.0)
        self.callback = callback

        #for reconnecting
        self.reconnect_timer_id = None

        Avatar = extension.get_default('avatar')

        th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None,
                animated=True)
        self.throbber = gtk.image_new_from_animation(th_pix)

        self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.b_cancel.connect('clicked', self._on_cancel_clicked)
        self.b_cancel.set_border_width(8)

        self.label = gtk.Label()
        self.label.set_markup('<b>Connecting...</b>')
        self.label_timer = gtk.Label()
        self.label_timer.set_markup('<b>Connection error!\n </b>')

        self.avatar = Avatar(cellDimention=96)
        self.avatar.set_from_file(avatar_path)

        al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.2)
        al_button_cancel = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.15)
        al_label = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_label_timer = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_logo = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)

        al_throbber.add(self.throbber)
        al_button_cancel.add(self.b_cancel)
        al_label.add(self.label)
        al_label_timer.add(self.label_timer)
        al_logo.add(self.avatar)

        vbox = gtk.VBox()
        vbox.pack_start(al_logo, True, False)
        vbox.pack_start(al_label, True, False)
        vbox.pack_start(al_label_timer, True, False)
        vbox.pack_start(al_throbber, True, False)
        vbox.pack_start(al_button_cancel, True, True)

        self.add(vbox)
        vbox.show_all()

        self.label_timer.hide()
Esempio n. 12
0
    def __get_contact_pixbuf_or_default(self, path):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if path is not None and path != '':
            pixbuf = utils.simple_animation_scale(path, self.avatar_size, 
                                                  self.avatar_size)
            picture = gtk.image_new_from_animation(pixbuf)
        else:
            pix = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.user,
                        (self.avatar_size, self.avatar_size))
            picture = gtk.image_new_from_pixbuf(pix)

        return picture
Esempio n. 13
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        Avatar = extension.get_default('avatar')
        avatar_image = Avatar(cell_dimension=self.avatar_size, crossfade = False, cell_radius = 0)
        avatar_image.set_from_file(contact.picture, bool(contact.blocked))

        if avatar_image.current_animation:
            image = gtk.image_new_from_animation(avatar_image.current_animation)
        else:
            image = gtk.image_new_from_pixbuf(avatar_image._pixbuf)

        return image
Esempio n. 14
0
    def __get_contact_pixbuf_or_default(self, path):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if path is not None and path != '':
            pixbuf = utils.simple_animation_scale(path, self.avatar_size, 
                                                  self.avatar_size)
            picture = gtk.image_new_from_animation(pixbuf)
        else:
            pix = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.user,
                        (self.avatar_size, self.avatar_size))
            picture = gtk.image_new_from_pixbuf(pix)

        return picture
Esempio n. 15
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        Avatar = extension.get_default('avatar')
        avatar_image = Avatar(cell_dimension=self.avatar_size,
                              crossfade=False,
                              cell_radius=0)
        avatar_image.set_from_file(contact.picture, bool(contact.blocked))

        if avatar_image.current_animation:
            image = gtk.image_new_from_animation(
                avatar_image.current_animation)
        else:
            image = gtk.image_new_from_pixbuf(avatar_image._pixbuf)

        return image
Esempio n. 16
0
    def load_wait(self, base, txt):

        ebox = gtk.EventBox()
        ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF"))

        vbox = gtk.VBox()
        align = self.define_align(vbox, 0.5, 0.5)
        ebox.add(align)

        animation = gtk.gdk.PixbufAnimation(ICON + "wait.gif")
        image = gtk.image_new_from_animation(animation)
        vbox.pack_start(image)

        base.statelabel = label = gtk.Label()
        base.statelabel.set_markup("<span foreground='#0092CE' font_desc='10'>%s</span>" % _(txt))
        vbox.pack_start(label)

        ebox.show_all()
        return ebox
Esempio n. 17
0
    def load_wait(self, base, txt):

        ebox = gtk.EventBox()
        ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF"))

        vbox = gtk.VBox()
        align = self.define_align(vbox, 0.5, 0.5)
        ebox.add(align)

        animation = gtk.gdk.PixbufAnimation(ICON + "wait.gif")
        image = gtk.image_new_from_animation(animation)
        vbox.pack_start(image)

        base.statelabel = label = gtk.Label()
        base.statelabel.set_markup(
            "<span foreground='#0092CE' font_desc='10'>%s</span>" % _(txt))
        vbox.pack_start(label)

        ebox.show_all()
        return ebox
Esempio n. 18
0
    def __init__(self, callback):

        gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0,
            yscale=1.0)
        self.callback = callback

        th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None,
                animated=True)
        self.throbber = gtk.image_new_from_animation(th_pix)

        self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.b_cancel.connect('clicked', self._on_cancel_clicked)
        self.b_cancel.set_border_width(8)
        
        self.label = gtk.Label()
        self.label.set_markup('<b>Connecting... </b>')

        img_account = gtk.Image()
        img_account.set_from_pixbuf(utils.safe_gtk_pixbuf_load(gui.theme.logo))

        al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.2)
        al_button_cancel = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.15)
        al_label = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_logo = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        
        al_throbber.add(self.throbber)
        al_button_cancel.add(self.b_cancel)
        al_label.add(self.label)
        al_logo.add(img_account)
        
        vbox = gtk.VBox()
        vbox.pack_start(al_logo, True, False)
        vbox.pack_start(al_label, True, False)
        vbox.pack_start(al_throbber, True, False)
        vbox.pack_start(al_button_cancel, True, True)
      
        self.add(vbox)
        vbox.show_all()
Esempio n. 19
0
    def _makeUI(self):
        self.set_spacing(6)
        anim = gtk.gdk.PixbufAnimation(get_pixmap_dir() + "/busy.gif")
        self.busyanim = gtk.image_new_from_animation(anim)
        self.busyanim.show()

        self.erroricon = gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_SMALL_TOOLBAR)
        self.erroricon.show()

        self.infolabel = gtk.Label(self._importingmessage)
        self.infolabel.set_alignment(0, 0.5)
        self.infolabel.show()

        self.questionbutton = gtk.Button()
        self.questionbutton.set_image(gtk.image_new_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_SMALL_TOOLBAR))
        self.questionbutton.connect("clicked", self._questionButtonClickedCb)
        self.questionbutton.show()
        self._questionshowing = False

        self.pack_start(self.busyanim, expand=False)
        self._busyshowing = True
        self.pack_start(self.infolabel, expand=True, fill=True)
Esempio n. 20
0
    def __init__(self, callback, on_preferences_changed, account,
            accounts=None, remember_account=None, remember_password=None,
            statuses=None, proxy=None, use_http=False, session_id=None):

        gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0,
            yscale=1.0)

        account = account or e3.Account("", "", e3.status.ONLINE)
        self.callback = callback
        self.on_preferences_changed = on_preferences_changed
        self.accounts = accounts or {}
        self.l_remember_account = remember_account or []
        self.l_remember_password = remember_password or []
        self.statuses = statuses or {}
        # the id of the default extension that handles the session
        # used to select the default session on the preference dialog
        self.use_http = use_http
        self.session_id = session_id

        if proxy is None:
            self.proxy = e3.Proxy()
        else:
            self.proxy = proxy

        liststore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf)
        completion = gtk.EntryCompletion()
        completion.set_model(liststore)
        pixbufcell = gtk.CellRendererPixbuf()
        completion.pack_start(pixbufcell)
        completion.add_attribute(pixbufcell, 'pixbuf', 1)
        completion.set_text_column(0)
        completion.set_inline_selection(True)

        pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.user)

        for mail in sorted(self.accounts):
            liststore.append([mail, utils.scale_nicely(pixbuf)])

        self.cmb_account = gtk.ComboBoxEntry(liststore, 0)
        self.cmb_account.get_children()[0].set_completion(completion)
        self.cmb_account.get_children()[0].connect('key-press-event',
            self._on_account_key_press)
        self.cmb_account.connect('changed',
            self._on_account_changed)

        if account:
            self.cmb_account.prepend_text(account.account)

        self.btn_status = StatusButton.StatusButton()

        status_padding = gtk.Label()
        status_padding.set_size_request(*self.btn_status.size_request())

        self.txt_password = gtk.Entry()
        self.txt_password.set_visibility(False)

        if account:
            self.txt_password.set_text(account.password)

        self.txt_password.connect('key-press-event',
            self._on_password_key_press)


        pix_account = utils.safe_gtk_pixbuf_load(gui.theme.user)
        pix_password = utils.safe_gtk_pixbuf_load(gui.theme.password)
        img_logo = utils.safe_gtk_image_load(gui.theme.logo)
        th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None, animated=True)
        self.throbber = gtk.image_new_from_animation(th_pix)

        self.remember_account = gtk.CheckButton(_('Remember account'))
        self.remember_password = gtk.CheckButton(_('Remember password'))

        self.remember_account.connect('toggled',
            self._on_remember_account_toggled)
        self.remember_password.connect('toggled',
            self._on_remember_password_toggled)

        vbox_remember = gtk.VBox(spacing=4)
        vbox_remember.set_border_width(8)
        vbox_remember.pack_start(self.throbber)
        vbox_remember.pack_start(self.remember_account)
        vbox_remember.pack_start(self.remember_password)

        self.b_connect = gtk.Button(stock=gtk.STOCK_CONNECT)
        self.b_connect.connect('clicked', self._on_connect_clicked)
        self.b_connect.set_border_width(8)

        vbox = gtk.VBox()
        vbox.set_border_width(2)

        hbox_account = gtk.HBox(spacing=6)
        img_account = gtk.Image()
        img_account.set_from_pixbuf(utils.scale_nicely(pix_account))
        hbox_account.pack_start(img_account, False)
        hbox_account.pack_start(self.cmb_account, True, True)
        hbox_account.pack_start(status_padding, False)

        hbox_password = gtk.HBox(spacing=6)
        img_password = gtk.Image()
        img_password.set_from_pixbuf(utils.scale_nicely(pix_password))
        hbox_password.pack_start(img_password, False)
        hbox_password.pack_start(self.txt_password, True, True)
        hbox_password.pack_start(self.btn_status, False)

        vbox_entries = gtk.VBox(spacing=12)
        vbox_entries.set_border_width(8)
        vbox_entries.pack_start(hbox_account)
        vbox_entries.pack_start(hbox_password)

        self.b_preferences = gtk.Button()
        self.img_preferences = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES,
            gtk.ICON_SIZE_MENU)
        self.img_preferences.set_sensitive(False)
        self.b_preferences.set_image(self.img_preferences)
        self.b_preferences.set_relief(gtk.RELIEF_NONE)
        self.b_preferences.connect('enter-notify-event',
            self._on_preferences_enter)
        self.b_preferences.connect('leave-notify-event',
            self._on_preferences_leave)
        self.b_preferences.connect('clicked',
            self._on_preferences_selected)

        al_vbox_entries = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.0)
        al_vbox_remember = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.2)
        al_button = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.0)
        al_logo = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_preferences = gtk.Alignment(xalign=1.0, yalign=0.5)

        al_vbox_entries.add(vbox_entries)
        al_vbox_remember.add(vbox_remember)
        al_button.add(self.b_connect)
        al_logo.add(img_logo)
        al_preferences.add(self.b_preferences)

        vbox.pack_start(al_logo, True, True, 10)
        vbox.pack_start(al_vbox_entries, True, True)
        vbox.pack_start(al_vbox_remember, True, True)
        vbox.pack_start(al_button, True, True)
        vbox.pack_start(al_preferences, False)

        self.add(vbox)
        vbox.show_all()
        
        self.throbber.hide()
Esempio n. 21
0
    def __init__(self, callback, args=None):
        gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=0.0, yscale=1.0)

        self.dialog = extension.get_default("dialog")
        Avatar = extension.get_default("avatar")
        NiceBar = extension.get_default("nice bar")

        self.liststore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf)
        completion = gtk.EntryCompletion()
        completion.set_model(self.liststore)
        pixbufcell = gtk.CellRendererPixbuf()
        completion.pack_start(pixbufcell)
        completion.add_attribute(pixbufcell, "pixbuf", 1)
        completion.set_text_column(0)
        completion.set_inline_selection(True)

        self.pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.user)

        self.cmb_account = gtk.ComboBoxEntry(self.liststore, 0)
        self.cmb_account.set_tooltip_text(_("Account"))
        self.cmb_account.get_children()[0].set_completion(completion)
        self.cmb_account.get_children()[0].connect("key-press-event", self._on_account_key_press)
        self.cmb_account.connect("changed", self._on_account_changed)
        self.cmb_account.connect("key-release-event", self._on_account_key_release)

        self.btn_status = StatusButton.StatusButton()
        self.btn_status.set_tooltip_text(_("Status"))
        self.btn_status.set_status(e3.status.ONLINE)
        self.btn_status.set_size_request(34, -1)

        self.txt_password = gtk.Entry()
        self.txt_password.set_tooltip_text(_("Password"))
        self.txt_password.set_visibility(False)
        self.txt_password.connect("key-press-event", self._on_password_key_press)
        self.txt_password.connect("changed", self._on_password_changed)
        self.txt_password.set_sensitive(False)

        pix_account = utils.safe_gtk_pixbuf_load(gui.theme.user)
        pix_password = utils.safe_gtk_pixbuf_load(gui.theme.password)

        self.avatar = Avatar()

        self.remember_account = gtk.CheckButton(_("Remember me"))
        self.remember_password = gtk.CheckButton(_("Remember password"))
        self.auto_login = gtk.CheckButton(_("Auto-login"))

        self.remember_account.connect("toggled", self._on_remember_account_toggled)
        self.remember_password.connect("toggled", self._on_remember_password_toggled)
        self.auto_login.connect("toggled", self._on_auto_login_toggled)

        self.remember_account.set_sensitive(False)
        self.remember_password.set_sensitive(False)
        self.auto_login.set_sensitive(False)

        self.forget_me = gtk.Button()
        self.forget_me.set_tooltip_text(_("Delete user"))
        forget_img = gtk.image_new_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_MENU)
        self.forget_me.set_image(forget_img)
        self.forget_me.set_relief(gtk.RELIEF_NONE)
        self.forget_me.set_border_width(0)
        self.forget_me.set_size_request(34, -1)
        self.forget_me.connect("clicked", self._on_forget_me_clicked)
        self.forget_me.set_sensitive(False)

        hboxremember = gtk.HBox(spacing=2)
        hboxremember.pack_start(self.remember_account, False)

        vbox_remember = gtk.VBox(spacing=4)
        vbox_remember.set_border_width(8)
        vbox_remember.pack_start(hboxremember)
        vbox_remember.pack_start(self.remember_password)
        vbox_remember.pack_start(self.auto_login)
        vbox_remember.pack_start(gtk.Label())

        self.b_connect = gtk.Button(stock=gtk.STOCK_CONNECT)
        self.b_connect.set_sensitive(False)

        self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.b_cancel.connect("clicked", self._on_cancel_clicked)

        vbuttonbox = gtk.VButtonBox()
        vbuttonbox.set_spacing(8)
        vbuttonbox.pack_start(self.b_connect)
        vbuttonbox.pack_start(self.b_cancel)

        vbox_content = gtk.VBox()

        hbox_account = gtk.HBox(spacing=6)
        img_accountpix = gtk.Image()
        img_accountpix.set_from_pixbuf(utils.scale_nicely(pix_account))
        hbox_account.pack_start(img_accountpix, False)
        hbox_account.pack_start(self.cmb_account)
        hbox_account.pack_start(self.forget_me, False)

        hbox_password = gtk.HBox(spacing=6)
        img_password = gtk.Image()
        img_password.set_from_pixbuf(utils.scale_nicely(pix_password))
        hbox_password.pack_start(img_password, False)
        hbox_password.pack_start(self.txt_password)
        hbox_password.pack_start(self.btn_status, False)

        session_combo_store = gtk.ListStore(gtk.gdk.Pixbuf, str)
        crp = gtk.CellRendererPixbuf()
        crt = gtk.CellRendererText()
        crp.set_property("xalign", 0)
        crt.set_property("xalign", 0)

        self.session_combo = gtk.ComboBox()
        self.session_combo.set_tooltip_text(_("Choose your network"))
        self.session_combo.set_model(session_combo_store)
        self.session_combo.pack_start(crp)
        self.session_combo.pack_start(crt)
        self.session_combo.add_attribute(crp, "pixbuf", 0)
        self.session_combo.add_attribute(crt, "text", 1)

        self.b_preferences = gtk.Button()
        self.b_preferences.set_tooltip_text(_("Preferences"))
        self.img_preferences = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU)
        self.img_preferences.set_sensitive(False)
        self.b_preferences.set_image(self.img_preferences)
        self.b_preferences.set_relief(gtk.RELIEF_NONE)
        self.b_preferences.connect("enter-notify-event", self._on_preferences_enter)
        self.b_preferences.connect("leave-notify-event", self._on_preferences_leave)
        self.b_preferences.connect("clicked", self._on_preferences_selected)
        self.b_preferences.set_size_request(34, -1)

        img_sessionpix = gtk.image_new_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_MENU)
        img_sessionpix.set_size_request(20, -1)
        img_sessionpix.set_sensitive(False)
        hbox_session = gtk.HBox(spacing=6)
        hbox_session.pack_start(img_sessionpix, False)
        hbox_session.pack_start(self.session_combo)
        hbox_session.pack_start(self.b_preferences, False)

        vbox_entries = gtk.VBox(spacing=12)
        vbox_entries.set_border_width(8)
        vbox_entries.pack_start(hbox_account)
        vbox_entries.pack_start(hbox_password)
        vbox_entries.pack_start(hbox_session)

        self.nicebar = NiceBar()

        th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None, animated=True)
        self.throbber = gtk.image_new_from_animation(th_pix)
        self.label_timer = gtk.Label()
        self.label_timer.set_markup(_("<b>Connection error!\n </b>"))

        al_label_timer = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0)
        al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.1, yscale=0.1)
        al_vbox_entries = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2, yscale=0.0)
        al_vbox_remember = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.2)
        al_button = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2)
        al_account = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.3)

        al_label_timer.add(self.label_timer)
        al_throbber.add(self.throbber)
        al_vbox_entries.add(vbox_entries)
        al_vbox_remember.add(vbox_remember)
        al_button.add(vbuttonbox)
        al_account.add(self.avatar)

        vbox = gtk.VBox()
        vbox_top = gtk.VBox()
        vbox_far_bottom = gtk.VBox()

        vbox_bottom = gtk.VBox(False)
        vbox_content.pack_start(gtk.Label(""), True, True)
        vbox_content.pack_start(al_account, True, False)
        vbox_content.pack_start(gtk.Label(""), True, True)
        vbox_content.pack_start(al_vbox_entries, False)
        vbox_content.pack_start(al_vbox_remember, True, False)
        vbox_bottom.set_size_request(-1, 100)
        vbox_bottom.pack_start(al_label_timer, True, False)
        vbox_bottom.pack_start(al_throbber, False)
        vbox_bottom.pack_start(gtk.Label(""), True, True)
        vbox_bottom.pack_start(al_button)
        vbox_content.pack_start(vbox_bottom)
        vbox_content.pack_start(gtk.Label(""), True, True)

        vbox.pack_start(self.nicebar, False)
        vbox.pack_start(vbox_top)
        vbox.pack_start(vbox_content)
        vbox.pack_start(vbox_far_bottom)

        self.add(vbox)
        vbox.show_all()
Esempio n. 22
0
    def __init__(self, callback, args=None):
        gtk.Alignment.__init__(self,
                               xalign=0.5,
                               yalign=0.5,
                               xscale=0.0,
                               yscale=1.0)

        self.dialog = extension.get_default('dialog')
        Avatar = extension.get_default('avatar')
        NiceBar = extension.get_default('nice bar')

        self.liststore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf)
        completion = gtk.EntryCompletion()
        completion.set_model(self.liststore)
        pixbufcell = gtk.CellRendererPixbuf()
        completion.pack_start(pixbufcell)
        completion.add_attribute(pixbufcell, 'pixbuf', 1)
        completion.set_text_column(0)
        completion.set_inline_selection(True)

        self.pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.user)

        self.cmb_account = gtk.ComboBoxEntry(self.liststore, 0)
        self.cmb_account.set_tooltip_text(_('Account'))
        self.cmb_account.get_children()[0].set_completion(completion)
        self.cmb_account.get_children()[0].connect('key-press-event',
                                                   self._on_account_key_press)
        self.cmb_account.connect('changed', self._on_account_changed)
        self.acc_key_rel_handler = self.cmb_account.connect(
            'key-release-event', self._on_account_key_release)

        self.btn_status = StatusButton.StatusButton()
        self.btn_status.set_tooltip_text(_('Status'))
        self.btn_status.set_status(e3.status.ONLINE)
        self.btn_status.set_size_request(34, -1)

        self.txt_password = gtk.Entry()
        self.txt_password.set_tooltip_text(_('Password'))
        self.txt_password.set_visibility(False)
        self.txt_password.connect('key-press-event',
                                  self._on_password_key_press)
        self.txt_password.connect('changed', self._on_password_changed)
        self.txt_password.set_sensitive(False)

        pix_account = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.user)
        pix_password = utils.safe_gtk_pixbuf_load(
            gui.theme.image_theme.password)

        self.avatar = Avatar()

        self.remember_account = gtk.CheckButton(_('Remember me'))
        self.remember_password = gtk.CheckButton(_('Remember password'))
        self.auto_login = gtk.CheckButton(_('Auto-login'))

        self.remember_account.connect('toggled',
                                      self._on_remember_account_toggled)
        self.remember_password.connect('toggled',
                                       self._on_remember_password_toggled)
        self.auto_login.connect('toggled', self._on_auto_login_toggled)

        self.remember_account.set_sensitive(False)
        self.remember_password.set_sensitive(False)
        self.auto_login.set_sensitive(False)

        self.forget_me = gtk.Button()
        self.forget_me.set_tooltip_text(_('Delete user'))
        forget_img = gtk.image_new_from_stock(gtk.STOCK_CANCEL,
                                              gtk.ICON_SIZE_MENU)
        self.forget_me.set_image(forget_img)
        self.forget_me.set_relief(gtk.RELIEF_NONE)
        self.forget_me.set_border_width(0)
        self.forget_me.set_size_request(34, -1)
        self.forget_me.connect('clicked', self._on_forget_me_clicked)
        self.forget_me.set_sensitive(False)

        hboxremember = gtk.HBox(spacing=2)
        hboxremember.pack_start(self.remember_account, False)

        vbox_remember = gtk.VBox(spacing=4)
        vbox_remember.set_border_width(8)
        vbox_remember.pack_start(hboxremember)
        vbox_remember.pack_start(self.remember_password)
        vbox_remember.pack_start(self.auto_login)
        vbox_remember.pack_start(gtk.Label())

        self.b_connect = gtk.Button(stock=gtk.STOCK_CONNECT)
        self.b_connect.set_sensitive(False)

        self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.b_cancel.connect('clicked', self._on_cancel_clicked)

        vbuttonbox = gtk.VButtonBox()
        vbuttonbox.set_spacing(8)
        vbuttonbox.pack_start(self.b_connect)
        vbuttonbox.pack_start(self.b_cancel)

        vbox_content = gtk.VBox()

        hbox_account = gtk.HBox(spacing=6)
        img_accountpix = gtk.Image()
        img_accountpix.set_from_pixbuf(utils.scale_nicely(pix_account))
        hbox_account.pack_start(img_accountpix, False)
        hbox_account.pack_start(self.cmb_account)
        hbox_account.pack_start(self.forget_me, False)

        hbox_password = gtk.HBox(spacing=6)
        img_password = gtk.Image()
        img_password.set_from_pixbuf(utils.scale_nicely(pix_password))
        hbox_password.pack_start(img_password, False)
        hbox_password.pack_start(self.txt_password)
        hbox_password.pack_start(self.btn_status, False)

        session_combo_store = gtk.ListStore(gtk.gdk.Pixbuf, str)
        crp = gtk.CellRendererPixbuf()
        crt = gtk.CellRendererText()
        crp.set_property("xalign", 0)
        crt.set_property("xalign", 0)

        self.session_combo = gtk.ComboBox()
        self.session_combo.set_tooltip_text(_('Choose your network'))
        self.session_combo.set_model(session_combo_store)
        self.session_combo.pack_start(crp)
        self.session_combo.pack_start(crt)
        self.session_combo.add_attribute(crp, "pixbuf", 0)
        self.session_combo.add_attribute(crt, "text", 1)

        self.b_preferences = gtk.Button()
        self.b_preferences.set_tooltip_text(_('Preferences'))
        self.img_preferences = gtk.image_new_from_stock(
            gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU)
        self.img_preferences.set_sensitive(False)
        self.b_preferences.set_image(self.img_preferences)
        self.b_preferences.set_relief(gtk.RELIEF_NONE)
        self.b_preferences.connect('enter-notify-event',
                                   self._on_preferences_enter)
        self.b_preferences.connect('leave-notify-event',
                                   self._on_preferences_leave)
        self.b_preferences.connect('clicked', self._on_preferences_selected)
        self.b_preferences.set_size_request(34, -1)

        img_sessionpix = gtk.image_new_from_stock(gtk.STOCK_CONNECT,
                                                  gtk.ICON_SIZE_MENU)
        img_sessionpix.set_size_request(20, -1)
        img_sessionpix.set_sensitive(False)
        hbox_session = gtk.HBox(spacing=6)
        hbox_session.pack_start(img_sessionpix, False)
        hbox_session.pack_start(self.session_combo)
        hbox_session.pack_start(self.b_preferences, False)

        vbox_entries = gtk.VBox(spacing=12)
        vbox_entries.set_border_width(8)
        vbox_entries.pack_start(hbox_account)
        vbox_entries.pack_start(hbox_password)
        vbox_entries.pack_start(hbox_session)

        self.nicebar = NiceBar()

        th_pix = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.throbber,
                                            None,
                                            animated=True)

        self.throbber = gtk.image_new_from_animation(th_pix)
        self.label_timer = gtk.Label()
        self.label_timer.set_markup(_('<b>Connection error!\n </b>'))

        al_label_timer = gtk.Alignment(xalign=0.5,
                                       yalign=0.5,
                                       xscale=0.0,
                                       yscale=0.0)

        al_throbber = gtk.Alignment(xalign=0.5,
                                    yalign=0.5,
                                    xscale=0.1,
                                    yscale=0.1)

        al_vbox_entries = gtk.Alignment(xalign=0.5,
                                        yalign=0.5,
                                        xscale=0.2,
                                        yscale=0.0)

        al_vbox_remember = gtk.Alignment(xalign=0.5,
                                         yalign=0.5,
                                         xscale=0.0,
                                         yscale=0.2)

        al_button = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2)

        al_account = gtk.Alignment(xalign=0.5,
                                   yalign=0.5,
                                   xscale=0.0,
                                   yscale=0.3)

        al_label_timer.add(self.label_timer)
        al_throbber.add(self.throbber)
        al_vbox_entries.add(vbox_entries)
        al_vbox_remember.add(vbox_remember)
        al_button.add(vbuttonbox)
        al_account.add(self.avatar)

        vbox = gtk.VBox()
        vbox_top = gtk.VBox()
        vbox_far_bottom = gtk.VBox()

        vbox_bottom = gtk.VBox(False)
        vbox_content.pack_start(gtk.Label(""), True, True)
        vbox_content.pack_start(al_account, True, False)
        vbox_content.pack_start(gtk.Label(""), True, True)
        vbox_content.pack_start(al_vbox_entries, False)
        vbox_content.pack_start(al_vbox_remember, True, False)
        vbox_bottom.set_size_request(-1, 100)
        vbox_bottom.pack_start(al_label_timer, True, False)
        vbox_bottom.pack_start(al_throbber, False)
        vbox_bottom.pack_start(gtk.Label(""), True, True)
        vbox_bottom.pack_start(al_button)
        vbox_content.pack_start(vbox_bottom)
        vbox_content.pack_start(gtk.Label(""), True, True)

        vbox.pack_start(self.nicebar, False)
        vbox.pack_start(vbox_top)
        vbox.pack_start(vbox_content)
        vbox.pack_start(vbox_far_bottom)

        self.add(vbox)
        vbox.show_all()
Esempio n. 23
0
    def __init__(self, callback, args=None):
        gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=1.0)

        self.dialog = extension.get_default('dialog')
        Avatar = extension.get_default('avatar')
        NiceBar = extension.get_default('nice bar')

        default_session = extension.get_default('session')

        self.liststore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf)
        completion = gtk.EntryCompletion()
        completion.set_model(self.liststore)
        pixbufcell = gtk.CellRendererPixbuf()
        completion.pack_start(pixbufcell)
        completion.add_attribute(pixbufcell, 'pixbuf', 1)
        completion.set_text_column(0)
        completion.set_inline_selection(True)

        self.pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.user)

        self.cmb_account = gtk.ComboBoxEntry(self.liststore, 0)
        self.cmb_account.get_children()[0].set_completion(completion)
        self.cmb_account.get_children()[0].connect('key-press-event',
            self._on_account_key_press)
        self.cmb_account.connect('changed',
            self._on_account_changed)
        self.cmb_account.connect('key-release-event',
            self._on_account_key_release)

        self.btn_status = StatusButton.StatusButton()
        self.btn_status.set_status(e3.status.ONLINE)

        self.txt_password = gtk.Entry()
        self.txt_password.set_visibility(False)
        self.txt_password.connect('key-press-event',
            self._on_password_key_press)
        self.txt_password.connect('changed', self._on_password_changed)
        self.txt_password.set_sensitive(False)

        pix_account = utils.safe_gtk_pixbuf_load(gui.theme.user)
        pix_password = utils.safe_gtk_pixbuf_load(gui.theme.password)

        self.avatar = Avatar()

        self.remember_account = gtk.CheckButton(_('Remember me'))
        self.remember_password = gtk.CheckButton(_('Remember password'))
        self.auto_login = gtk.CheckButton(_('Auto-login'))

        self.remember_account.connect('toggled',
            self._on_remember_account_toggled)
        self.remember_password.connect('toggled',
            self._on_remember_password_toggled)
        self.auto_login.connect('toggled',
            self._on_auto_login_toggled)

        self.remember_account.set_sensitive(False)
        self.remember_password.set_sensitive(False)
        self.auto_login.set_sensitive(False)

        self.forget_me = gtk.Button()
        self.forget_me.set_tooltip_text(_('Delete user'))
        forget_img = gtk.image_new_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_MENU)
        self.forget_me.set_image(forget_img)
        self.forget_me.set_relief(gtk.RELIEF_NONE)
        self.forget_me.set_border_width(0)
        self.forget_me.connect('clicked', self._on_forget_me_clicked)
        self.forget_me.set_sensitive(False)

        hboxremember = gtk.HBox(spacing=2)
        hboxremember.pack_start(self.remember_account, False, False)

        vbox_remember = gtk.VBox(spacing=4)
        vbox_remember.set_border_width(8)
        vbox_remember.pack_start(hboxremember)
        vbox_remember.pack_start(self.remember_password)
        vbox_remember.pack_start(self.auto_login)

        self.b_connect = gtk.Button(stock=gtk.STOCK_CONNECT)
        self.b_connect.connect('clicked', self._on_connect_clicked)
        self.b_connect.set_sensitive(False)

        self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.b_cancel.connect('clicked', self._on_cancel_clicked)

        vbuttonbox = gtk.VButtonBox()
        vbuttonbox.set_spacing(8)
        vbuttonbox.pack_start(self.b_connect)
        vbuttonbox.pack_start(self.b_cancel)

        vbox = gtk.VBox()

        hbox_account = gtk.HBox(spacing=6)
        img_accountpix = gtk.Image()
        img_accountpix.set_from_pixbuf(utils.scale_nicely(pix_account))
        hbox_account.pack_start(img_accountpix, False)
        hbox_account.pack_start(self.cmb_account, True, True)
        hbox_account.pack_start(self.forget_me, False)

        hbox_password = gtk.HBox(spacing=6)
        img_password = gtk.Image()
        img_password.set_from_pixbuf(utils.scale_nicely(pix_password))
        hbox_password.pack_start(img_password, False)
        hbox_password.pack_start(self.txt_password, True, True)
        hbox_password.pack_start(self.btn_status, False)

        vbox_entries = gtk.VBox(spacing=12)
        vbox_entries.set_border_width(8)
        vbox_entries.pack_start(hbox_account)
        vbox_entries.pack_start(hbox_password)

        self.b_preferences = gtk.Button()
        self.img_preferences = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES,
            gtk.ICON_SIZE_MENU)
        self.img_preferences.set_sensitive(False)
        self.b_preferences.set_image(self.img_preferences)
        self.b_preferences.set_relief(gtk.RELIEF_NONE)
        self.b_preferences.connect('enter-notify-event',
            self._on_preferences_enter)
        self.b_preferences.connect('leave-notify-event',
            self._on_preferences_leave)
        self.b_preferences.connect('clicked',
            self._on_preferences_selected)

        self.nicebar = NiceBar()

        th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None,
                animated=True)
        self.throbber = gtk.image_new_from_animation(th_pix)
        self.label_timer = gtk.Label()
        self.label_timer.set_markup(_('<b>Connection error!\n </b>'))

        al_label_timer = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.2)
        al_vbox_entries = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.0)
        al_vbox_remember = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.2)
        al_button = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2)
        al_account = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_preferences = gtk.Alignment(xalign=1.0, yalign=0.5)

        al_label_timer.add(self.label_timer)
        al_throbber.add(self.throbber)
        al_vbox_entries.add(vbox_entries)
        al_vbox_remember.add(vbox_remember)
        al_button.add(vbuttonbox)
        al_account.add(self.avatar)
        al_preferences.add(self.b_preferences)

        vbox_bottom = gtk.VBox(True)
        vbox.pack_start(self.nicebar, False)
        vbox.pack_start(al_account, True, False)
        vbox.pack_start(al_vbox_entries, True, True)
        vbox.pack_start(al_vbox_remember, True, False)
        vbox_bottom.pack_start(al_label_timer, True, False)
        vbox_bottom.pack_start(al_throbber, False, False)
        vbox_bottom.pack_start(al_button, True, True)
        vbox.pack_start(vbox_bottom, True, True)
        vbox.pack_start(al_preferences, True, False)

        self.add(vbox)
        vbox.show_all()
Esempio n. 24
0
    def buildInterface(self, interface):
        self.currentInterface = interface
        
        lUser = gtk.Label(_('_User:'******'_Password:'******'_Status:'))
        
        lUser.set_use_underline(True)
        lPass.set_use_underline(True)
        lStatus.set_use_underline(True)
        
        #we add the completion to the user entry
        
        self.tUser = gtk.combo_box_entry_new_text()
        self.userListStore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf)
        self.userCompletion = gtk.EntryCompletion()
        #set up the completion on entry child
        self.tUser.get_children()[0].set_completion(self.userCompletion)
        self.userCompletion.set_model(self.userListStore)
        self.userPixbufCell = gtk.CellRendererPixbuf()
        self.userCompletion.pack_start(self.userPixbufCell)
        self.userCompletion.add_attribute(self.userPixbufCell, 'pixbuf', 1)
        # create a gtk.CellRendererText and pack it in the completion.
        # Also set the 'text' attribute
        self.userCompletion.set_text_column(0)
        self.userCompletion.connect('match-selected', self.matchSelected)
        self.tUser.connect("changed", self.on_comboxEntry_changed)
        self.tUser.connect("key-release-event", self.on_comboxEntry_keyrelease)
        
        self.statusListStore = gtk.ListStore(gtk.gdk.Pixbuf, 
                                              gobject.TYPE_STRING,
                                              gobject.TYPE_STRING)
        self.tStatus = gtk.ComboBox(self.statusListStore)
        self.statusPixbufCell = gtk.CellRendererPixbuf()
        self.statusTextCell = gtk.CellRendererText()
        self.tStatus.pack_start(self.statusPixbufCell, False)
        self.tStatus.pack_start(self.statusTextCell, False)
        self.statusPixbufCell.set_property('xalign', 0.0)
        self.statusPixbufCell.set_property('xpad', 5)
        self.statusTextCell.set_property('xalign', 0.0)
        self.statusTextCell.set_property('xpad', 5)
        self.tStatus.add_attribute(self.statusTextCell, 'text', 2)
        self.tStatus.add_attribute(self.statusPixbufCell, 'pixbuf', 0)
            
        self.tPass = gtk.Entry(128)
        self.tPass.set_visibility(False)
        self.tPass.connect('activate' , self.bLogin_clicked)
        
        lUser.set_mnemonic_widget(self.tUser)
        lPass.set_mnemonic_widget(self.tPass)
        lStatus.set_mnemonic_widget(self.tStatus)
        
        # fill the status combobox
        self.statusList = []
        j = 0
        for i in self.controller.status_ordered[ 1 ]:
            if i != 'offline':
                self.statusListStore\
                        .append([ self.controller.theme.statusToPixbuf(
                               emesenelib.common.status_table[i]), i,
                               _(self.controller.status_ordered[2][ j]) ])
                self.statusList.append(i)
                j += 1
                            
        self.tStatus.set_active(0)
        
        pixbuf = self.controller.theme.getImage('login', False)
        self.loginImage = Widgets.avatarHolder()
        self.loginImage.set_from_pixbuf(pixbuf)
        self.pack_start(self.loginImage , True , False)
        
        self.fieldsBox = gtk.VBox(spacing=10)
        
        userBox = gtk.VBox(spacing=4)
        lUser.set_alignment(0.0, 0.5)
        userBox.pack_start(lUser , False , False)
        userBox.pack_start(self.tUser , False , False)
    
        self.fieldsBox.pack_start(userBox, False, False)
        
        passBox = gtk.VBox(spacing=4)
        lPass.set_alignment(0.0, 0.5)
        passBox.pack_start(lPass , False , False)
        passBox.pack_start(self.tPass , False , False)
        
        self.fieldsBox.pack_start(passBox, False, False)
        
        statusBox = gtk.VBox(spacing=4)
        lStatus.set_alignment(0.0, 0.5)
        statusBox.pack_start(lStatus , False , False)
        statusBox.pack_end(self.tStatus, True, True)

        self.fieldsBox.pack_start(statusBox, False, False)
        
        fieldsAlig = gtk.Alignment(0.5, 0.5, 0.75, 0.0)
        fieldsAlig.add(self.fieldsBox)
        self.pack_start(fieldsAlig, True, False)
        
        buttonBox = gtk.HButtonBox()
        
        if interface == 'login':
            self.bLogin = gtk.Button(_('_Login'), gtk.STOCK_CONNECT)
            self.bLogin.connect('clicked' , self.bLogin_clicked)
            buttonBox.pack_start(self.bLogin, False, False)
            
            self.cRemember = gtk.CheckButton(_('_Remember me'), True)
            self.cRemember.connect('toggled' , self.on_cRemember_toggled)
            
            self.forgetMe = gtk.EventBox()
            self.forgetMe.set_events(gtk.gdk.BUTTON_PRESS_MASK)
            self.forgetMeLabel = gtk.Label('<span foreground="#0000AA">(' + \
                                            _('Forget me') + ')</span>')
            self.forgetMeLabel.set_use_markup(True)
            self.forgetMe.add(self.forgetMeLabel)
            self.forgetMe.connect('button_press_event', self.onForgetMe)
     
            self.cRememberPass = gtk.CheckButton(_('R_emember password'), True)
            self.cRememberPass.connect('toggled' , self.on_cRememberPass_toggled)

            # TODO: find a better description and get-text it
            self.cAutoLogin = gtk.CheckButton(_('Auto-Login'), True)
            self.cAutoLogin.connect('toggled' , self.on_cAutoLogin_toggled)
            
            if self.controller.config.glob['rememberMe']:
                self.cRemember.set_active(True)
                
            if self.controller.config.glob['rememberMyPassword']:
                self.cRememberPass.set_active(True)

            self.checkBox = gtk.VBox(spacing=4)
        
            rememberBox = gtk.HBox(spacing=4)
            rememberBox.pack_start(self.cRemember , False , False)
            rememberBox.pack_start(self.forgetMe , False , False)
        
            self.checkBox.pack_start(rememberBox, False, False)
            self.checkBox.pack_start(self.cRememberPass , False , False)
            self.checkBox.pack_start(self.cAutoLogin , False , False)
            
            checkAlig = gtk.Alignment(0.5, 0.5)
            checkAlig.add(self.checkBox)
            
            self.pack_start(checkAlig , True , False)

        elif interface == 'reconnect':
            self.fieldsBox.set_sensitive(False)
            
            self.lConnectionError = gtk.Label()
            self.lConnectionError.set_markup('<b>' + _('Connection error') + '</b>')
            
            self.lReconnectCounter = gtk.Label()
            
            self.bCancelReconnect = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL)
            self.bCancelReconnect.connect('clicked', self.onCancelReconnect)
        
            self.pack_start(self.lConnectionError, True, False)
            self.pack_start(self.lReconnectCounter, True, False)
            buttonBox.pack_start(self.bCancelReconnect, False, False)
        elif interface == 'loading':
            self.fieldsBox.set_sensitive(False)

            pixbuf = self.controller.theme.getImage('loading', True)
            self.loading = gtk.image_new_from_animation(pixbuf)
        
            cancelButton = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL)
            cancelButton.connect('clicked', self.onCancelLogin)
            buttonBox.pack_start(cancelButton, False, False)
            
            self.pack_start(self.loading, False, False)
            # XXX: progress stuff maybe?

        self.pack_start(buttonBox, True, False)            
        self.fillUserList()
        self.show_all()
        self.tUser.grab_focus()
Esempio n. 25
0
    def buildInterface(self, interface):

        # Load users.dat
        self.users = UserManager(os.path.join(paths.CONFIG_DIR, 'users.dat'))

        self.currentInterface = interface

        lUser = gtk.Label(_('_User:'******'_Password:'******'')
        lStatus = gtk.Label(_('_Status:'))

        lUser.set_use_underline(True)
        lPass.set_use_underline(True)
        lStatus.set_use_underline(True)

        # Make a ListStore for users
        self.userListStore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf)
        # User entry with combo (from ListStore)
        self.tUser = gtk.ComboBoxEntry(self.userListStore, 0)
        self.tUser.connect("changed", self.on_comboxEntry_changed)
        self.tUser.connect("key-release-event", self.on_comboxEntry_keyrelease)
        # User entry completion (from ListStore)
        self.userCompletion = gtk.EntryCompletion()
        self.userCompletion.set_model(self.userListStore)
        self.tUser.get_children()[0].set_completion(self.userCompletion)
        self.userCompletion.connect('match-selected', self.matchSelected)
        # Add pictures to the completion
        self.userPixbufCell = gtk.CellRendererPixbuf()
        self.userCompletion.pack_start(self.userPixbufCell)
        self.userCompletion.add_attribute(self.userPixbufCell, 'pixbuf', 1)
        self.userCompletion.set_text_column(0)

        # Make a ListStore for Status
        self.statusListStore = gtk.ListStore(gtk.gdk.Pixbuf,
                                              gobject.TYPE_STRING,
                                              gobject.TYPE_STRING)

        self.tStatus = gtk.ComboBox(self.statusListStore)
        self.statusPixbufCell = gtk.CellRendererPixbuf()
        self.statusTextCell = gtk.CellRendererText()
        self.tStatus.pack_start(self.statusPixbufCell, False)
        self.tStatus.pack_start(self.statusTextCell, False)
        self.statusPixbufCell.set_property('xalign', 0.0)
        self.statusPixbufCell.set_property('xpad', 5)
        self.statusTextCell.set_property('xalign', 0.0)
        self.statusTextCell.set_property('xpad', 5)
        self.tStatus.add_attribute(self.statusTextCell, 'text', 2)
        self.tStatus.add_attribute(self.statusPixbufCell, 'pixbuf', 0)

        self.tPass = gtk.Entry(128)
        self.tPass.set_visibility(False)
        self.tPass.connect('activate' , self.bLogin_clicked)
        self.tPass.connect('key-press-event', self.on_password_keypressed)

        lUser.set_mnemonic_widget(self.tUser)
        lPass.set_mnemonic_widget(self.tPass)
        lStatus.set_mnemonic_widget(self.tStatus)

        # fill the status combobox
        self.statusList = []
        j = 0
        for i in self.controller.status_ordered[ 1 ]:
            if i != 'offline' and i not in self.statusList:
                self.statusListStore\
                        .append([ self.controller.theme.statusToPixbuf(
                               emesenelib.common.status_table[i]).scale_simple(20,20,gtk.gdk.INTERP_BILINEAR), i,
                               _(self.controller.status_ordered[2][j]) ])
                self.statusList.append(i)
            j += 1

        self.tStatus.set_active(0)

        pixbuf = self.controller.theme.getImage('login', False)
        self.loginImage = Widgets.avatarHolder()
        self.loginImage.set_from_pixbuf(pixbuf)
        if not self.controller.config.glob['dontShowAvatarInLoginWindow']:
            self.pack_start(self.loginImage , True , False)

        self.fieldsBox = gtk.VBox(spacing=10)

        userBox = gtk.VBox(spacing=4)
        lUser.set_alignment(0.0, 0.5)
        userBox.pack_start(lUser , False , False)
        userBox.pack_start(self.tUser , False , False)

        self.fieldsBox.pack_start(userBox, False, False)

        passBox = gtk.VBox(spacing=4)
        passLBox = gtk.HBox(spacing=6)
        lPass.set_alignment(0.0, 0.5)
        passLBox.pack_start(lPass , False , False)
        passLBox.pack_start(self.lCaps , False , False)
        passBox.pack_start(passLBox , False , False)
        passBox.pack_start(self.tPass , False , False)

        self.fieldsBox.pack_start(passBox, False, False)

        statusBox = gtk.VBox(spacing=4)
        lStatus.set_alignment(0.0, 0.5)
        statusBox.pack_start(lStatus , False , False)
        statusBox.pack_end(self.tStatus, True, True)

        self.fieldsBox.pack_start(statusBox, False, False)

        fieldsAlig = gtk.Alignment(0.5, 0.5, 0.75, 0.0)
        fieldsAlig.add(self.fieldsBox)
        self.pack_start(fieldsAlig, True, False)

        self.lReconnectCounter = None

        buttonBox = gtk.HButtonBox()

        if interface == 'login':
            self.bLogin = gtk.Button(_('_Login'), gtk.STOCK_CONNECT)
            self.bLogin.connect('clicked' , self.bLogin_clicked)
            buttonBox.pack_start(self.bLogin, False, False)

            self.cRemember = gtk.CheckButton(_('_Remember me'), True)
            self.cRemember.connect('toggled' , self.on_cRemember_toggled)

            self.forgetMe = gtk.EventBox()
            self.forgetMe.set_events(gtk.gdk.BUTTON_PRESS_MASK)
            self.forgetMeLabel = gtk.Label('<span foreground="#0000AA">(' + \
                                            _('Forget me') + ')</span>')
            self.forgetMeLabel.set_use_markup(True)
            self.forgetMe.add(self.forgetMeLabel)
            self.forgetMe.connect('button_press_event', self.onForgetMe)
            self.forgetMe.set_child_visible(False)

            self.cRememberPass = gtk.CheckButton(_('R_emember password'), True)
            self.cRememberPass.connect('toggled' , self.on_cRememberPass_toggled)

            # TODO: find a better description and get-text it
            self.cAutoLogin = gtk.CheckButton(_('Auto-Login'), True)
            self.cAutoLogin.connect('toggled' , self.on_cAutoLogin_toggled)

            #this fixes a bug with user config
            current_user = self.controller.config.getCurrentUser()

            if self.controller.config.glob['rememberMe'] and current_user != '':
                self.cRemember.set_active(True)

            if self.controller.config.glob['rememberMyPassword'] and current_user != '':
                self.cRememberPass.set_active(True)

            if self.controller.config.glob['autoLogin'] and current_user != '':
                self.cAutoLogin.set_active(True)

            self.checkBox = gtk.VBox(spacing=4)

            rememberBox = gtk.HBox(spacing=4)
            rememberBox.pack_start(self.cRemember , False , False)
            rememberBox.pack_start(self.forgetMe , False , False)
                
            self.checkBox.pack_start(rememberBox, False, False)
            self.checkBox.pack_start(self.cRememberPass, False, False)
            self.checkBox.pack_start(self.cAutoLogin, False, False)

            try:
                import locale
                link = "http://status.messenger.msn.com/Status.aspx?mkt="
                link += locale.getlocale()[0].replace('_','-')
                serverStatus = gtk.LinkButton(link,_('Service Status'))
                self.checkBox.pack_start(serverStatus, False, False)
            except:
                # some people have really weird python installs
                pass
                            
            checkAlig = gtk.Alignment(0.5, 0.5)
            checkAlig.add(self.checkBox)

            self.pack_start(checkAlig , True , False)

            serverBox = gtk.VBox(spacing=40)
            serverLBox = gtk.HBox(spacing=6)

            serverBox.pack_start(serverLBox , False , False)

            checkAlig1 = gtk.Alignment(0.5, 0.5)
            checkAlig1.add(serverBox)

            self.pack_start(buttonBox, True, False)
        
            self.pack_start(checkAlig1, True, False)

        elif interface == 'reconnect':
            self.fieldsBox.set_sensitive(False)

            self.lConnectionError = gtk.Label()
            self.lConnectionError.set_markup('<b>' + _('Connection error') + '</b>')

            self.lReconnectCounter = gtk.Label()

            self.bCancelReconnect = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL)
            self.bCancelReconnect.connect('clicked', self.onCancelReconnect)
            self.bReconnectNow = gtk.Button(_('Reconnect now'), gtk.STOCK_CONNECT)
            self.bReconnectNow.connect('clicked' , self.onReconnectNow)

            self.pack_start(self.lConnectionError, True, False)
            self.pack_start(self.lReconnectCounter, True, False)
            buttonBox.pack_start(self.bReconnectNow, True, False)
            buttonBox.pack_start(self.bCancelReconnect, False, False)
            self.pack_start(buttonBox, True, False)
        elif interface == 'loading':
            self.fieldsBox.set_sensitive(False)

            pixbuf = self.controller.theme.getImage('loading', True)
            self.loading = gtk.image_new_from_animation(pixbuf)

            cancelButton = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL)
            cancelButton.connect('clicked', self.onCancelLogin)
            buttonBox.pack_start(cancelButton, False, False)

            self.pack_start(self.loading, False, False)
            self.pack_start(buttonBox, True, False)
            # XXX: progress stuff maybe?

        # fill the user list
        self.refreshUserList()
        if self.users.userExists(self.controller.config.glob['lastLoggedAccount']):
                self.tUser.get_children()[0].set_text(self.controller.config.glob['lastLoggedAccount'])

        self.show_all()
        self.tUser.grab_focus()