Beispiel #1
0
        /// <summary>
        /// Adds the pixbuf to the recent avatars
        /// </summary>
        public static void AddAvatar(Gdk.Pixbuf avatar)
        {
            AvatarManager manager = AvatarManager.Instance;

            // The Manager only holds 16 avatars
            if (manager.avatars.Count == 16)
            {
                manager.avatars.RemoveAt(15);
            }
            manager.avatars.Insert(0, avatar);
        }
Beispiel #2
0
        private void OnAvatarButtonClicked(object o, EventArgs args)
        {
            AvatarButton button = (AvatarButton)o;

            if (AvatarSelected != null)
            {
                Gdk.Pixbuf avatar = AvatarManager.PromoteAvatar(button.Index);
                if (avatar != null)
                {
                    AvatarSelected(avatar);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Retrieves the avatar at index and promotes it to the top
        /// </summary>
        public static Gdk.Pixbuf PromoteAvatar(uint index)
        {
            AvatarManager manager = AvatarManager.Instance;

            if (index > manager.avatars.Count)
            {
                return(null);
            }

            Gdk.Pixbuf avatar = manager.avatars[(int)index];
            manager.avatars.RemoveAt((int)index);
            manager.avatars.Insert(0, avatar);
            return(avatar);
        }
Beispiel #4
0
        private void OnEditPicture(object sender, EventArgs args)
        {
//			FileSelection fs = new FileSelection(Catalog.GetString("Select an Avatar"));
//			int fsreturn = fs.Run();
//			fs.Hide();
            FileChooserDialog fc = new FileChooserDialog(Catalog.GetString("Select an Avatar"), null, FileChooserAction.Open,
                                                         "Cancel", ResponseType.Cancel,
                                                         "Open", ResponseType.Accept);


            FileFilter filter = new FileFilter();

            filter.Name = Catalog.GetString("PNG and JPEG images");
            filter.AddMimeType("image/png");
            filter.AddPattern("*.png");
            filter.AddMimeType("image/jpeg");
            filter.AddPattern("*.jpg");
            fc.AddFilter(filter);
            int    fcreturn = fc.Run();
            string filename = fc.Filename;

            fc.Destroy();
            if (fcreturn == (int)ResponseType.Accept)
            {
                Gdk.Pixbuf avatar;
                try {
                    avatar      = new Gdk.Pixbuf(filename);
                    this.Pixbuf = avatar;
                    AvatarManager.AddAvatar(avatar);
                    if (PersonManager.Me != null)
                    {
                        Logger.Debug("Setting Avatar");
                        PersonManager.Me.SetAvatar(avatar);
                    }
                } catch (Exception ex) {
                    Logger.Debug("Exception loading image from file: {0}", filename);
                    Logger.Debug(ex.Message);
                    return;
                }

                //Logger.Debug("FIXME: This should set the avatar but telepathy is broken!");
                // The following lines eventually call down into telepathy connection to set an avatar
                // and it crashes the app with an error that Avatars method doesn't exist
            }
        }
Beispiel #5
0
 private void OnClearRecentPictures(object sender, EventArgs args)
 {
     AvatarManager.Clear();
 }
Beispiel #6
0
        /// <summary>
        /// Clears the avatars from the manager
        /// </summary>
        public static void Clear()
        {
            AvatarManager manager = AvatarManager.Instance;

            manager.avatars.Clear();
        }