Exemple #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;
		}
		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);
			}
		}
Exemple #4
0
        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);
			}
		}
Exemple #6
0
 void HandleRemoved(Literal group)
 {
     UpdateQuery ();
 }
Exemple #7
0
 void HandleNegated(Literal group)
 {
     UpdateQuery ();
 }
Exemple #8
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 ();
        }
Exemple #9
0
 void HandleAttachTag(Tag tag, Term parent, Literal after)
 {
     InsertTerm (new Tag [] {tag}, parent, after);
 }
Exemple #10
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;
        }
Exemple #11
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;
        }
		public AbstractLiteral(Term parent, Literal after) : base (parent, after) {}
Exemple #13
0
        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;
        }
		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;
		}
		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);
		}
		private void HandleTermAdded (Term parent, Literal after)
		{
			InsertTerm (parent, after);
		}
		//private Literal literal;

		public void Activate (Gdk.EventButton eb, Literal literal)
		{
			Activate (eb, literal, new Gtk.Menu (), true);
		}
Exemple #18
0
 public Literal(Term parent, Tag tag, Literal after)
     : base(parent, after)
 {
     Tag = tag;
 }
Exemple #19
0
        void HandleRemoving(Literal term)
        {
            foreach (Widget w in HangersOn (term))
            Remove (w);

            // Remove the term's widget
            Remove (term.Widget);
        }
Exemple #20
0
 void HandleTagsAdded(Tag[] tags, Term parent, Literal after)
 {
     InsertTerm (tags, parent, after);
 }
Exemple #21
0
 public OrTerm(Term parent, Literal after)
     : base(parent, after)
 {
 }