public void RemoveTag (Tag t)
		{
			if (tags_removed == null)
				tags_removed = new List<Tag> ();
			if (tags_added != null)
				tags_added.Remove (t);
			tags_removed.Add (t);
		}
示例#2
0
 void PopulatePeopleCategories(TreeStore treeStore ,Tag parent,TreeIter parentIter,int level)
 {
     foreach (Tag tag in (parent as Category).Children) {
         if (tag is Category) {
             //Log.Debug("Append  : "+tag.Name + " to "+parent.Name);
             TreeIter iter =
                 (parentIter.Equals(TreeIter.Zero) ?
                 treeStore.AppendValues(tag.Name,/*parent,*/tag):
                     treeStore.AppendValues(parentIter,tag.Name,/*parent,*/tag)) ;
             PopulatePeopleCategories (treeStore,tag,iter,level+1);
         }
     }
 }
		public static void Create (Tag [] tags, Gtk.Menu menu)
		{
			Gtk.MenuItem item = new Gtk.MenuItem (String.Format (Catalog.GetPluralString ("Find _With", "Find _With", tags.Length), tags.Length));

			Gtk.Menu submenu = GetSubmenu (tags);
			if (submenu == null)
				item.Sensitive = false;
			else
				item.Submenu = submenu;

			menu.Append (item);
			item.Show ();
		}
        public static Tag[] GetTagsData(this SelectionData selection_data)
        {
            int size = sizeof (uint);
            int length = selection_data.Length / size;

            TagStore tag_store = MainWindow.Toplevel.Database.Tags;

            Tag [] tags = new Tag [length];

            for (int i = 0; i < length; i ++) {
                uint id = System.BitConverter.ToUInt32 (selection_data.Data, i * size);
                tags[i] = tag_store.Get (id);
            }

            return tags;
        }
示例#5
0
文件: Face.cs 项目: kanitw/facespot
        public Face(uint id,uint leftX,uint topY,uint width,Photo photo,
		             Tag tag,bool tagConfirmed, bool autoDetected, bool autoRecognized, Pixbuf icon,long unix_time)
            : base(id)
        {
            this.leftX = leftX;
            this.topY = topY;
            this.width = width;
            this.photo = photo;
            this.tag = tag;
            this.tagConfirmed = tagConfirmed;
            this.autoDetected = autoDetected;
            this.autoRecognized = autoRecognized;
            this.iconPixbuf = icon;
            this.unix_time = unix_time;
            //FIXME Possible Error HERE
            photo_md5 = photo.MD5Sum;
        }
示例#6
0
 private void HandleAttachTag(Tag tag, Term parent, Literal after)
 {
     InsertTerm (new Tag [] {tag}, parent, after);
 }
示例#7
0
        public void UnInclude(Tag [] tags)
        {
            ArrayList new_tags = new ArrayList(tags.Length);
            foreach (Tag tag in tags) {
                if (rootTerm.TagIncluded (tag))
                    new_tags.Add (tag);
            }

            if (new_tags.Count == 0)
                return;

            tags = (Tag []) new_tags.ToArray (typeof (Tag));

            bool needsUpdate = false;
            preventUpdate = true;
            foreach (Term parent in rootTerm.LiteralParents ()) {
                if (parent.Count == 1) {
                    foreach (Tag tag in tags) {
                        if ((parent.Last as Literal).Tag == tag) {
                            (parent.Last as Literal).RemoveSelf ();
                            needsUpdate = true;
                            break;
                        }
                    }
                }
            }
            preventUpdate = false;

            if (needsUpdate)
                UpdateQuery ();
        }
示例#8
0
 public bool TagIncluded(Tag tag)
 {
     return rootTerm.TagIncluded (tag);
 }
示例#9
0
        /** Helper Functions **/
        public void PhotoTagsChanged(Tag [] tags)
        {
            bool refresh_required = false;

            foreach (Tag tag in tags) {
                if ((rootTerm.FindByTag (tag)).Count > 0) {
                    refresh_required = true;
                    break;
                }
            }

            if (refresh_required)
                UpdateQuery ();
        }
示例#10
0
        // Add a tag or group of tags to the rootTerm, at the end of the Box
        public void Include(Tag [] tags)
        {
            // Filter out any tags that are already included
            ArrayList new_tags = new ArrayList(tags.Length);
            foreach (Tag tag in tags) {
                if (! rootTerm.TagIncluded (tag))
                    new_tags.Add (tag);

            }

            if (new_tags.Count == 0)
                return;

            tags = (Tag []) new_tags.ToArray (typeof (Tag));

            InsertTerm (tags, rootTerm, null);
        }
        public static void SetTagsData(this SelectionData selection_data, Tag [] tags, Atom target)
        {
            byte [] data = new byte [tags.Length * sizeof (uint)];

            int i = 0;
            foreach (Tag tag in tags) {
                byte [] bytes = System.BitConverter.GetBytes (tag.Id);

                foreach (byte b in bytes) {
                    data[i] = b;
                    i++;
                }
            }

            selection_data.Set (target, 8, data, data.Length);
        }
		private IDictionary<string, object> CreateDictFromTag (Tag t)
		{
			Dictionary<string, object> result = new Dictionary<string, object> ();

			result.Add ("Id", t.Id);
			result.Add ("Name", t.Name);

			StringBuilder builder = new StringBuilder ();

			if (t is Category) {
				foreach (Tag child in (t as Category).Children) {
					if (builder.Length > 0)
						builder.Append (",");

					builder.Append (child.Name);
				}
			}

			result.Add ("Children", builder.ToString ());

			return result;
		}
示例#13
0
 // FIXME: This should be removed (I think)
 public bool HasTag(Tag tag)
 {
     return(tags.Contains(tag));
 }
示例#14
0
 // This doesn't check if the tag is already there, use with caution.
 public void AddTagUnsafely(Tag tag)
 {
     tags.Add(tag);
     changes.AddTag(tag);
 }
示例#15
0
    public string Upload(IBrowsableItem photo, IFilter filter, bool is_public, bool is_family, bool is_friend)
    {
        if (token == null)
        {
            throw new Exception("Must Login First");
        }
        // FIXME flickr needs rotation
        string error_verbose;

        using (FilterRequest request = new FilterRequest(photo.DefaultVersionUri)) {
            try {
                string tags = null;

                filter.Convert(request);
                string path = request.Current.LocalPath;

                if (ExportTags && photo.Tags != null)
                {
                    StringBuilder taglist  = new StringBuilder();
                    FSpot.Tag []  t        = photo.Tags;
                    FSpot.Tag     tag_iter = null;

                    for (int i = 0; i < t.Length; i++)
                    {
                        if (i > 0)
                        {
                            taglist.Append(",");
                        }

                        taglist.Append(String.Format("\"{0}\"", t[i].Name));

                        // Go through the tag parents
                        if (ExportTagHierarchy)
                        {
                            tag_iter = t[i].Category;
                            while (tag_iter != Core.Database.Tags.RootCategory && tag_iter != null)
                            {
                                // Skip top level tags because they have no meaning in a linear tag database
                                if (ExportIgnoreTopLevel && tag_iter.Category == Core.Database.Tags.RootCategory)
                                {
                                    break;
                                }

                                // FIXME Look if the tag is already there!
                                taglist.Append(",");
                                taglist.Append(String.Format("\"{0}\"", tag_iter.Name));
                                tag_iter = tag_iter.Category;
                            }
                        }
                    }

                    tags = taglist.ToString();
                }
                try {
                    string photoid =
                        flickr.UploadPicture(path, photo.Name, photo.Description, tags, is_public, is_family, is_friend);
                    return(photoid);
                } catch (FlickrNet.FlickrException ex) {
                    Console.WriteLine("Problems uploading picture: " + ex.ToString());
                    error_verbose = ex.ToString();
                }
            } catch (Exception e) {
                // FIXME we need to distinguish between file IO errors and xml errors here
                throw new System.Exception("Error while uploading", e);
            }
        }

        throw new System.Exception(error_verbose);
    }
示例#16
0
        public static Gtk.Menu GetSubmenu(Tag [] tags)
        {
            Tag single_tag = null;
            if (tags != null && tags.Length == 1)
                single_tag = tags[0];

            //Console.WriteLine ("creating find with menu item");
            if (LogicWidget.Root == null || LogicWidget.Root.SubTerms.Count == 0) {
                //Console.WriteLine ("root is null or has no terms");
                return null;
            } else {
                //Console.WriteLine ("root is not null and has terms");
                Gtk.Menu m = new Gtk.Menu ();

                Gtk.MenuItem all_item = GtkUtil.MakeMenuItem (m, Catalog.GetString ("All"), new EventHandler (MainWindow.Toplevel.HandleRequireTag));
                GtkUtil.MakeMenuSeparator (m);

                int sensitive_items = 0;
                foreach (Term term in LogicWidget.Root.SubTerms) {
                    ArrayList term_parts = new ArrayList ();

                    bool contains_tag = AppendTerm (term_parts, term, single_tag);

                    string name = "_" + String.Join (", ", (string []) term_parts.ToArray (typeof(string)));

                    Gtk.MenuItem item = GtkUtil.MakeMenuItem (m, name, new EventHandler (MainWindow.Toplevel.HandleAddTagToTerm));
                    item.Sensitive = !contains_tag;

                    if (!contains_tag)
                        sensitive_items++;
                }

                if (sensitive_items == 0)
                    all_item.Sensitive = false;

                return m;
            }
        }
 private void HandleTagMenuSelected(Tag t)
 {
     selected_tags = new Tag [] { t };
 }
示例#18
0
 public bool TagIncluded(Tag tag)
 {
     return logic_widget.TagIncluded (tag);
 }
		private bool RemoveTag (Tag t)
		{
			if (t == null)
				return false;

			try {
				// remove tags from photos first
				Core.Database.Photos.Remove (new Tag [] { t });
				// then remove tag
				tag_store.Remove (t);
				return true;
			}
			catch {
				return false;
			}
		}
示例#20
0
 public bool TagRequired(Tag tag)
 {
     return logic_widget.TagRequired (tag);
 }
示例#21
0
 void HandleTagSelected(Tag t)
 {
     tag_button.Label = t.Name;
     Preferences.Set (SCREENSAVER_TAG, (int) t.Id);
 }
示例#22
0
 public void UnInclude(Tag [] tags)
 {
     logic_widget.UnInclude (tags);
 }
示例#23
0
        public ArrayList InsertTerm(Tag [] tags, Term parent, Literal after)
        {
            int position;
            if (after != null)
                position = WidgetPosition (after.Widget) + 1;
            else
                position = Children.Length - 1;

            ArrayList added = new ArrayList ();

            foreach (Tag tag in tags) {
                //Console.WriteLine ("Adding tag {0}", tag.Name);

                // Don't put a tag into a Term twice
                if (parent != Root && (parent.FindByTag (tag, true)).Count > 0)
                    continue;

                if (parent.Count > 0) {
                    Widget sep = parent.SeparatorWidget ();

                    InsertWidget (position, sep);
                    position++;
                }

                // Encapsulate new OR terms within a new AND term of which they are the
                // only member, so later other terms can be AND'd with them
                //
                // TODO should really see what type of term the parent is, and
                // encapsulate this term in a term of the opposite type. This will
                // allow the query system to be expanded to work for multiple levels much easier.
                if (parent == rootTerm) {
                    parent = new AndTerm (rootTerm, after);
                    after = null;
                }

                Literal term  = new Literal (parent, tag, after);
                term.TagsAdded  += HandleTagsAdded;
                term.LiteralsMoved += HandleLiteralsMoved;
                term.AttachTag  += HandleAttachTag;
                term.NegatedToggled += HandleNegated;
                term.Removing  += HandleRemoving;
                term.Removed  += HandleRemoved;
                term.RequireTag  += Require;
                term.UnRequireTag += UnRequire;

                added.Add (term);

                // Insert this widget into the appropriate place in the hbox
                InsertWidget (position, term.Widget);
            }

            UpdateQuery ();

            return added;
        }
示例#24
0
 public void UnRequire(Tag [] tags)
 {
     logic_widget.UnRequire (tags);
 }
示例#25
0
        // AND this tag with all terms
        public void Require(Tag [] tags)
        {
            // TODO it would be awesome if this was done by putting parentheses around
            // OR terms and ANDing the result with this term (eg factored out)

            // Trim out tags that are already required
            ArrayList new_tags = new ArrayList(tags.Length);
            foreach (Tag tag in tags) {
                if (! rootTerm.TagRequired (tag))
                    new_tags.Add (tag);
            }

            if (new_tags.Count == 0)
                return;

            tags = (Tag []) new_tags.ToArray (typeof (Tag));

            bool added = false;
            preventUpdate = true;
            foreach (Term parent in rootTerm.LiteralParents ()) {
                // TODO logic could be broken if a term's SubTerms are a mixture
                // of Literals and non-Literals
                InsertTerm (tags, parent, parent.Last as Literal);
                added = true;
            }

            // If there were no LiteralParents to add this tag to, then add it to the rootTerm
            // TODO should add the first tag in the array,
            // then add the others to the first's parent (so they will be ANDed together)
            if (!added)
                InsertTerm (tags, rootTerm, null);

            preventUpdate = false;

            UpdateQuery ();
        }
		private void HandleTagMenuSelected (Tag t) 
		{
			selected_tags = new Tag [] { t };
		}
示例#27
0
 public bool TagRequired(Tag tag)
 {
     return rootTerm.TagRequired (tag);
 }
示例#28
0
		void MergeTags (Tag tag_to_merge)
		{
			TagStore from_store = from_db.Tags;
			TagStore to_store = to_db.Tags;

			if (tag_to_merge != from_store.RootCategory) { //Do not merge RootCategory
				Tag dest_tag = to_store.GetTagByName (tag_to_merge.Name);
				if (dest_tag == null) {
					Category parent = (tag_to_merge.Category == from_store.RootCategory) ?
							to_store.RootCategory :
							to_store.GetTagByName (tag_to_merge.Category.Name) as Category;
					dest_tag = to_store.CreateTag (parent, tag_to_merge.Name);
					//FIXME: copy the tag icon and commit
				}
				tag_map [tag_to_merge.Id] = dest_tag;
			}

			if (!(tag_to_merge is Category))
				return;

			foreach (Tag t in (tag_to_merge as Category).Children)
				MergeTags (t);
		}
示例#29
0
        public void UnRequire(Tag [] tags)
        {
            // Trim out tags that are not required
            ArrayList new_tags = new ArrayList(tags.Length);
            foreach (Tag tag in tags) {
                if (rootTerm.TagRequired (tag))
                    new_tags.Add (tag);
            }

            if (new_tags.Count == 0)
                return;

            tags = (Tag []) new_tags.ToArray (typeof (Tag));

            preventUpdate = true;
            foreach (Term parent in rootTerm.LiteralParents ()) {
                // Don't remove if this tag is the only child of a term
                if (parent.Count > 1) {
                    foreach (Tag tag in tags) {
                        ((parent.FindByTag (tag))[0] as Literal).RemoveSelf ();
                    }
                }
            }

            preventUpdate = false;

            UpdateQuery ();
        }
示例#30
0
 void HandleQueryTagSelected(Tag tag)
 {
     options.QueryTag = tag;
     tag_button.Label = tag.Name;
     tag_button.Image = tag.Icon != null ? new Gtk.Image (PixbufUtils.ScaleDown (tag.Icon, 16, 16)) : null;
 }
示例#31
0
 private void HandleTagsAdded(Tag[] tags, Term parent, Literal after)
 {
     InsertTerm (tags, parent, after);
 }
		private void AddTagNameToList (List<string> list, Tag tag)
		{
			if (tag != tag_store.RootCategory)
				list.Add (tag.Name);

			if (tag is Category) {
				foreach (Tag child in (tag as Category).Children)
					AddTagNameToList (list, child);
			}
		}
示例#33
0
        private static bool AppendTerm(ArrayList parts, Term term, Tag single_tag)
        {
            bool tag_matches = false;
            if (term != null) {
                Literal literal = term as Literal;
                if (literal != null) {
                    if (literal.Tag == single_tag)
                        tag_matches = true;

                    if (literal.IsNegated)
                        parts.Add (String.Format (Catalog.GetString ("Not {0}"), literal.Tag.Name));
                    else
                        parts.Add (literal.Tag.Name);
                } else {
                    foreach (Term subterm in term.SubTerms) {
                        tag_matches |= AppendTerm (parts, subterm, single_tag);
                    }
                }
            }

            return tag_matches;
        }
		private void AddTagIdToList (List<uint> list, Tag tag)
		{
			if (tag != tag_store.RootCategory)
				list.Add (tag.Id);

			if (tag is Category) {
				foreach (Tag child in (tag as Category).Children)
					AddTagIdToList (list, child);
			}
		}