예제 #1
0
        public void Activate(Gdk.EventButton eb, Literal literal, Gtk.Menu popupMenu, bool isPopup)
        {
            /*MenuItem attach_item = new MenuItem (Catalog.GetString ("Find With"));
            TagMenu attach_menu = new TagMenu (attach_item, App.Instance.Database.Tags);
            attach_menu.TagSelected += literal.HandleAttachTagCommand;
            attach_item.ShowAll ();
            popup_menu.Append (attach_item);*/

            if (literal.IsNegated) {
                GtkUtil.MakeMenuItem (popupMenu,
                              String.Format (Catalog.GetString ("Include Photos Tagged \"{0}\""), literal.Tag.Name),
                              new EventHandler (literal.HandleToggleNegatedCommand),
                              true);
            } else {
                GtkUtil.MakeMenuItem (popupMenu,
                              String.Format (Catalog.GetString ("Exclude Photos Tagged \"{0}\""), literal.Tag.Name),
                              new EventHandler (literal.HandleToggleNegatedCommand),
                              true);
            }

            GtkUtil.MakeMenuItem (popupMenu, Catalog.GetString ("Remove From Search"),
                          "gtk-remove",
                          new EventHandler (literal.HandleRemoveCommand),
                          true);

            if (isPopup) {
                if (eb != null)
                    popupMenu.Popup (null, null, null, eb.Button, eb.Time);
                else
                    popupMenu.Popup (null, null, null, 0, Gtk.Global.CurrentEventTime);
            }
        }
		public LiteralMenu (MenuItem item, Literal literal)
		{
			popup = new LiteralPopup ();

			this.literal = literal;

			item.Submenu = this;
			item.Activated += HandlePopulate;
		}
예제 #3
0
		public Term (Term parent, Literal after)
		{
			this.parent = parent;

			if (parent != null) {
				if (after == null)
					parent.Add (this);
				else
					parent.SubTerms.Insert (parent.SubTerms.IndexOf (after) + 1, this);
			}
		}
예제 #4
0
파일: Term.cs 프로젝트: Yetangitu/f-spot
        protected Term(Term parent, Literal after)
        {
            this.parent = parent;
            SubTerms = new List<Term> ();

            if (parent != null)
                if (after == null) {
                    parent.Add (this);
                } else {
                    parent.SubTerms.Insert (parent.SubTerms.IndexOf (after) + 1, this);
                }
        }
		public void Activate (Gdk.EventButton eb, Literal literal, Gtk.Menu popup_menu, bool is_popup)
		{
			//this.literal = literal;

			/*MenuItem attach_item = new MenuItem (Catalog.GetString ("Find With"));
			TagMenu attach_menu = new TagMenu (attach_item, MainWindow.Toplevel.Database.Tags);
			attach_menu.TagSelected += literal.HandleAttachTagCommand;
			attach_item.ShowAll ();
			popup_menu.Append (attach_item);*/

			if (literal.IsNegated) {
				GtkUtil.MakeMenuItem (popup_menu,
						      Catalog.GetString ("Include"),
						      "gtk-cancel",
						      new EventHandler (literal.HandleToggleNegatedCommand),
						      true);
			} else {
				GtkUtil.MakeMenuItem (popup_menu,
						      Catalog.GetString ("Exclude"),
						      "gtk-delete",
						      new EventHandler (literal.HandleToggleNegatedCommand),
						      true);
			}

			GtkUtil.MakeMenuItem (popup_menu, Catalog.GetString ("Remove"),
					      "gtk-remove",
					      new EventHandler (literal.HandleRemoveCommand),
					      true);

			if (is_popup) {
				if (eb != null)
					popup_menu.Popup (null, null, null, eb.Button, eb.Time);
				else
					popup_menu.Popup (null, null, null, 0, Gtk.Global.CurrentEventTime);
			}
		}
		private void HandleTermAdded (Term parent, Literal after)
		{
			InsertTerm (parent, after);
		}
예제 #7
0
		public static OrTerm FromTags(Tag [] from_tags)
		{
			if (from_tags == null || from_tags.Length == 0)
				return null;

			OrTerm or = new OrTerm(null, null);
			foreach (Tag t in from_tags) {
				Literal l = new Literal(t);
				l.Parent = or;
			}
			return or;
		}
예제 #8
0
        void HandleRemoving(Literal term)
        {
            foreach (Widget w in HangersOn (term))
            Remove (w);

            // Remove the term's widget
            Remove (term.Widget);
        }
 private void HandleTermAdded(Term parent, Literal after)
 {
     InsertTerm(parent, after);
 }
예제 #10
0
        public List<Gtk.Widget> HangersOn(Literal term)
        {
            var w = new List<Gtk.Widget> ();

            // Find separators that only exist because of this term
            if (term.Parent != null) {
                if (term.Parent.Count > 1)
                {
                    if (term == term.Parent.Last)
                        w.Add (Children[WidgetPosition (term.Widget) - 1]);
                    else
                        w.Add (Children[WidgetPosition (term.Widget) + 1]);
                }
                else if (term.Parent.Count == 1)
                {
                    if (term.Parent.Parent != null) {
                        if (term.Parent.Parent.Count > 1) {
                            if (term.Parent == term.Parent.Parent.Last)
                                w.Add (Children[WidgetPosition (term.Widget) - 1]);
                            else
                                w.Add (Children[WidgetPosition (term.Widget) + 1]);
                        }
                    }
                }
            }
            return w;
        }
예제 #11
0
파일: Term.cs 프로젝트: Yetangitu/f-spot
        public static Term TermFromOperator(string op, Term parent, Literal after)
        {
            //Console.WriteLine ("finding type for operator {0}", op);
            //op = op.Trim ();
            op = op.ToLower ();

            if (AndTerm.Operators.Contains (op))
                return new AndTerm (parent, after);

            if (OrTerm.Operators.Contains (op))
                return new OrTerm (parent, after);

            Log.DebugFormat ("Do not have Term for operator {0}", op);
            return null;
        }
예제 #12
0
 public Literal(Term parent, Tag tag, Literal after) : base(parent, after)
 {
     this.tag = tag;
 }
예제 #13
0
        public List <Literal> InsertTerm(Tag [] tags, Term parent, Literal after)
        {
            int position;

            if (after != null)
            {
                position = WidgetPosition(after.Widget) + 1;
            }
            else
            {
                position = Children.Length - 1;
            }

            var added = new List <Literal>();

            foreach (var 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 == Root)
                {
                    parent = new AndTerm(Root, after);
                    after  = null;
                }

                var 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);
        }
예제 #14
0
 void HandleRemoved(Literal group)
 {
     UpdateQuery();
 }
예제 #15
0
 void HandleNegated(Literal group)
 {
     UpdateQuery();
 }
예제 #16
0
 void HandleAttachTag(Tag tag, Term parent, Literal after)
 {
     InsertTerm(new Tag [] { tag }, parent, after);
 }
예제 #17
0
 void HandleTagsAdded(Tag[] tags, Term parent, Literal after)
 {
     InsertTerm(tags, parent, after);
 }
		private void InsertTerm (Term parent, Literal after)
		{
			if (Literal.FocusedLiterals.Count != 0) {
				HandleLiteralsMoved (Literal.FocusedLiterals, parent, after);

				// Prevent them from being removed again
				Literal.FocusedLiterals = null;
			}
			else
				InsertTerm (tag_selection_widget.TagHighlight, parent, after);
		}
예제 #19
0
		public AbstractLiteral(Term parent, Literal after) : base (parent, after) {}
예제 #20
0
파일: OrTerm.cs 프로젝트: Yetangitu/f-spot
 public OrTerm(Term parent, Literal after)
     : base(parent, after)
 {
 }
예제 #21
0
 void HandleAttachTag(Tag tag, Term parent, Literal after)
 {
     InsertTerm (new Tag [] {tag}, parent, after);
 }
예제 #22
0
 void HandleNegated(Literal group)
 {
     UpdateQuery ();
 }
예제 #23
0
        public List<Literal> InsertTerm(Tag [] tags, Term parent, Literal after)
        {
            int position;
            if (after != null)
                position = WidgetPosition (after.Widget) + 1;
            else
                position = Children.Length - 1;

            var added = new List<Literal>();

            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;
        }
        //private Literal literal;

        public void Activate(Gdk.EventButton eb, Literal literal)
        {
            Activate(eb, literal, new Gtk.Menu(), true);
        }
예제 #25
0
        void HandleLiteralsMoved(List<Literal> literals, Term parent, Literal after)
        {
            preventUpdate = true;
            foreach (Literal term in literals) {
                Tag tag = term.Tag;

                // Don't listen for it to be removed since we are
                // moving it. We will update when we're done.
                term.Removed -= HandleRemoved;
                term.RemoveSelf ();

                // Add it to where it was dropped
                List<Literal> groups = InsertTerm (new [] {tag}, parent, after);

                if (term.IsNegated)
                    foreach (Literal group in groups)
                        group.IsNegated = true;
            }
            preventUpdate = false;
            UpdateQuery ();
        }
예제 #26
0
파일: Literal.cs 프로젝트: Yetangitu/f-spot
 public Literal(Term parent, Tag tag, Literal after)
     : base(parent, after)
 {
     Tag = tag;
 }
예제 #27
0
 void HandleRemoved(Literal group)
 {
     UpdateQuery ();
 }
예제 #28
0
 public AndTerm(Term parent, Literal after) : base(parent, after)
 {
 }
예제 #29
0
 void HandleTagsAdded(Tag[] tags, Term parent, Literal after)
 {
     InsertTerm (tags, parent, after);
 }
		//private Literal literal;

		public void Activate (Gdk.EventButton eb, Literal literal)
		{
			Activate (eb, literal, new Gtk.Menu (), true);
		}