Exemple #1
0
def get_user_profile_picture(user, status_icons=True, center=True):
    """ Returns picture saved in user's profile as a GDK Pixbuf,
        or the default picture with a background color
        generated from uid.
        Status icons are added to the picture, if status_icons == True.
        """
    try:
        icon = gtk.gdk.pixbuf_new_from_file(proximatestate.seek_face_name(user))
    except gobject.GError:
        icon = create_default_user_picture(user)

    if center:
        # center image if it's smaller than MAX_FACE_DIMENSION
        smaller_dimension = min(icon.get_width(), icon.get_height())
        if smaller_dimension < MAX_FACE_DIMENSION:
            icon = center_image(icon, MAX_FACE_DIMENSION, MAX_FACE_DIMENSION)

    if status_icons:
        # add small status icons
        community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        if not user == community.get_myself():
            if user.get('key_fname'):
                status_icon = gtk.gdk.pixbuf_new_from_file(get_path(SMALL_KEYS_ICON))
                add_icon_to_image(icon, status_icon, 4)

        user_status = user.get('status_icon')
        if user_status:
            add_icon_to_image(icon, get_status_icon(user_status, 32), 0)

    return icon
Exemple #2
0
    def handle_icon_request(self, user, request):
        iconid = request.get('iconid')
        if iconid == None or type(iconid) != str:
            return None

        debug('Icon request from %s: %s\n' % (user.get('nick'), iconid))

        if iconid == 'user':
            icon = read_file_contents(seek_face_name(self.myself))
            version = self.myself.get('faceversion')
            limiter = self.iconfetchlimiters['user']

        elif iconid.startswith('c:'):
            cname = iconid[2:]
            if not valid_community(cname):
                return None
            if cname not in self.myself.get('communities'):
                return None
            com = self.get_ordinary_community(cname)
            if com == None:
                return None
            if com.get('myiconversion') != com.get('iconversion'):
                # Do not reply with a old version of the icon!
                return
            icon = read_file_contents(seek_community_icon_name(com))
            version = com.get('iconversion')
            limiter = self.iconfetchlimiters.get(iconid)
            if limiter == None:
                limiter = Rate_Limiter(ICON_PUSH_INTERVAL)
                self.iconfetchlimiters[iconid] = limiter
        else:
            return None

        if icon == None:
            icon = ''
        if version == None:
            version = 0

        request = {'t': 'iconpush', 'iconid': iconid, 'icon': icon, 'version': version}

        if normal_traffic_mode():
            self.fetcher.fetch(user, PLUGIN_TYPE_COMMUNITY, request, None, ack=False)
        elif limiter == None or limiter.check():
            self.fetcher.fetch_community(self.get_default_community(), PLUGIN_TYPE_COMMUNITY, request, None, ack=False)

        return {}
Exemple #3
0
 def image_clicked(self, widget, event):
     self.pic_dialog.set_picture(proximatestate.seek_face_name(self.user))
     self.pic_dialog.show()