Example #1
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
Example #2
0
    def show_tooltip(self, view, origCoords, path_array, obj):
        ''' shows the tooltip of an e3.Contact '''
        self.tag = -1

        text = xml.sax.saxutils.escape(Renderers.msnplus_to_plain_text(obj.nick)) 
        text += '\n' + xml.sax.saxutils.escape(Renderers.msnplus_to_plain_text(obj.message))
        text += '\n' + self.data_string % (\
            obj.account, self.yes_no[bool(obj.blocked)])

        self.label.set_markup(text)

        # Sets tooltip image
        if obj.picture!="":
            pixbuf = utils.gtk_pixbuf_load(obj.picture, (96,96))
        else:
            pixbuf = utils.gtk_pixbuf_load(gui.theme.user_def_image)

        if bool(obj.blocked)==True:
            pixbufblock=utils.gtk_pixbuf_load(gui.theme.blocked_overlay_big)
            utils.simple_images_overlap(pixbuf,pixbufblock,-pixbufblock.props.width,-pixbufblock.props.width)

        self.image.set_from_pixbuf(pixbuf)
        self.image.show()

        # set the location of the tooltip
        x, y = self.computePosition(origCoords, view.window)
        self.move(x, y)
        self.show()
        return False
Example #3
0
    def show_tooltip(self, view, origCoords, path_array, obj):
        ''' shows the tooltip of an e3.Contact '''
        self.tag = -1

        text = xml.sax.saxutils.escape(Plus.msnplus_strip(obj.display_name))
        message = Plus.msnplus_strip(obj.message) \
                    if obj.media == '' else obj.media
        text += '\n<span size="small">' \
                + xml.sax.saxutils.escape(message) + '</span>'
        text += '\n' + self.data_string % (\
            obj.account, obj.status_string, self.yes_no[bool(obj.blocked)])

        self.label.set_markup(text)

        # Sets tooltip image
        if obj.picture and obj.picture != "":
            pixbuf = utils.gtk_pixbuf_load(obj.picture, (96,96))
        else:
            pixbuf = utils.gtk_pixbuf_load(gui.theme.image_theme.user_def_image)

        if bool(obj.blocked):
            pixbufblock = utils.gtk_pixbuf_load(
                                    gui.theme.image_theme.blocked_overlay_big)
            utils.simple_images_overlap(pixbuf, pixbufblock, \
                            -pixbufblock.props.width, -pixbufblock.props.width)

        self.image.set_from_pixbuf(pixbuf)
        self.image.show()

        # set the location of the tooltip
        x, y = self.computePosition(origCoords, view.window)
        self.move(x, y)
        self.show()
        return False
Example #4
0
    def show_tooltip(self, view, origCoords, path_array, obj):
        ''' shows the tooltip of an e3.Contact '''
        self.tag = -1

        text = xml.sax.saxutils.escape(Plus.msnplus_strip(obj.display_name))
        message = Plus.msnplus_strip(obj.message) \
                    if obj.media == '' else obj.media
        text += '\n<span size="small">' \
                + xml.sax.saxutils.escape(message) + '</span>'
        text += '\n' + self.data_string % (\
            obj.account, obj.status_string, self.yes_no[bool(obj.blocked)])

        self.label.set_markup(text)

        # Sets tooltip image
        if obj.picture and obj.picture != "":
            pixbuf = utils.gtk_pixbuf_load(obj.picture, (96, 96))
        else:
            pixbuf = utils.gtk_pixbuf_load(
                gui.theme.image_theme.user_def_image)

        if bool(obj.blocked):
            pixbufblock = utils.gtk_pixbuf_load(
                gui.theme.image_theme.blocked_overlay_big)
            utils.simple_images_overlap(pixbuf, pixbufblock, \
                            -pixbufblock.props.width, -pixbufblock.props.width)

        self.image.set_from_pixbuf(pixbuf)
        self.image.show()

        # set the location of the tooltip
        x, y = self.computePosition(origCoords, view.window)
        self.move(x, y)
        self.show()
        return False
Example #5
0
    def set_from_file(self, filename, blocked=False):
        self.filename = filename
        self.blocked = blocked
        if not gui.gtkui.utils.file_readable(filename):
            if self._dimension > 32:
                # use big fallback image
                self.filename = gui.theme.image_theme.user_def_imagetool
            else:
                self.filename = gui.theme.image_theme.user

        try:
            animation = gtk.gdk.PixbufAnimation(self.filename)
        except gobject.GError:
            animation = gtk.gdk.PixbufAnimation(gui.theme.image_theme.user)

        if animation.is_static_image() or self.blocked:
            static_image = animation.get_static_image()
            static_image = static_image.scale_simple(self._dimension,
                                                     self._dimension,
                                                     gtk.gdk.INTERP_BILINEAR)
        else:
            animation = utils.simple_animation_scale(self.filename,
                                                     self._dimension,
                                                     self._dimension)
            static_image = animation.get_static_image()

        if self.blocked:
            if self._dimension > 32:
                # use big fallback image
                newdim = int(self._dimension * 0.5)
                pixbufblock = utils.gtk_pixbuf_load(
                    gui.theme.image_theme.blocked_overlay_big,
                    (newdim, newdim))
            else:
                pixbufblock = utils.gtk_pixbuf_load(
                    gui.theme.image_theme.blocked_overlay)

            output_pixbuf = utils.simple_images_overlap(
                static_image, pixbufblock, -pixbufblock.props.width,
                -pixbufblock.props.width)

            self.__set_from_pixbuf(output_pixbuf)
            self.current_animation = None
            return
        elif animation.is_static_image():
            self.__set_from_pixbuf(static_image)
            self.current_animation = None
            return

        self.current_animation = animation
        self._start_animation(animation)
Example #6
0
    def set_from_file(self, filename, blocked=False):
        self.filename = filename
        self.blocked  = blocked
        if not gui.gtkui.utils.file_readable(filename):
            if self._dimension > 32:
                # use big fallback image
                self.filename = gui.theme.image_theme.user_def_imagetool
            else:
                self.filename = gui.theme.image_theme.user

        try:
            animation = gtk.gdk.PixbufAnimation(self.filename)
        except gobject.GError:
            animation = gtk.gdk.PixbufAnimation(gui.theme.image_theme.user)

        if animation.is_static_image() or self.blocked:
            static_image = animation.get_static_image()
            static_image = static_image.scale_simple(self._dimension,
                                                    self._dimension,
                                                    gtk.gdk.INTERP_BILINEAR)
        else:
            animation = utils.simple_animation_scale(self.filename,
                                                self._dimension,
                                                self._dimension)
            static_image = animation.get_static_image()

        if self.blocked:
            if self._dimension > 32:
                # use big fallback image
                pixbufblock = utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay_big,
                                                    (int(self._dimension * 0.5),
                                                     int(self._dimension * 0.5)))
            else:
                pixbufblock = utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay)

            output_pixbuf = utils.simple_images_overlap(static_image, pixbufblock,
                                                        -pixbufblock.props.width,
                                                        -pixbufblock.props.width)

            self.__set_from_pixbuf(output_pixbuf)
            self.current_animation = None
            return
        #FIXME: animations are broken on gtk3, use static pixbuf for now
        elif animation.is_static_image() or check_gtk3():
            self.__set_from_pixbuf(static_image)
            self.current_animation = None
            return

        self.current_animation = animation
        self._start_animation(animation)
Example #7
0
    def set_from_file(self, filename, blocked=False):
        self.filename = filename
        self.blocked  = blocked
        if not gui.gtkui.utils.file_readable(filename):
            self.filename = gui.theme.image_theme.user

        try:
            animation = gtk.gdk.PixbufAnimation(self.filename)
        except gobject.GError:
            animation = gtk.gdk.PixbufAnimation(gui.theme.image_theme.user)

        if self.blocked:
            pixbufblock=utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay_big)
            static_image = animation.get_static_image()

            output_pixbuf =utils.simple_images_overlap(static_image, pixbufblock,
                                                        -pixbufblock.props.width,
                                                        -pixbufblock.props.width)

            self.__set_from_pixbuf(output_pixbuf)
            self.current_animation = None
            return
        elif animation.is_static_image():
            self.__set_from_pixbuf(animation.get_static_image())
            self.current_animation = None
            return

        self.current_animation = animation
        self._start_animation(animation)
Example #8
0
    def set_from_file(self, filename, blocked=False):
        self.filename = filename
        self.blocked = blocked
        if not gui.gtkui.utils.file_readable(filename):
            self.filename = gui.theme.image_theme.user

        try:
            animation = gtk.gdk.PixbufAnimation(self.filename)
        except gobject.GError:
            animation = gtk.gdk.PixbufAnimation(gui.theme.image_theme.user)

        if self.blocked:
            pixbufblock = utils.gtk_pixbuf_load(
                gui.theme.image_theme.blocked_overlay_big)
            static_image = animation.get_static_image()

            output_pixbuf = utils.simple_images_overlap(
                static_image, pixbufblock, -pixbufblock.props.width,
                -pixbufblock.props.width)

            self.__set_from_pixbuf(output_pixbuf)
            self.current_animation = None
            return
        elif animation.is_static_image():
            self.__set_from_pixbuf(animation.get_static_image())
            self.current_animation = None
            return

        self.current_animation = animation
        self._start_animation(animation)
Example #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
Example #10
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