Example #1
0
 static void NoMatches_cb(IntPtr inst)
 {
     try {
         EntryCompletion __obj = GLib.Object.GetObject(inst, false) as EntryCompletion;
         __obj.OnNoMatches();
     } catch (Exception e) {
         GLib.ExceptionManager.RaiseUnhandledException(e, false);
     }
 }
Example #2
0
 static void ActionActivated_cb(IntPtr inst, int index_)
 {
     try {
         EntryCompletion __obj = GLib.Object.GetObject(inst, false) as EntryCompletion;
         __obj.OnActionActivated(index_);
     } catch (Exception e) {
         GLib.ExceptionManager.RaiseUnhandledException(e, false);
     }
 }
Example #3
0
 static bool CursorOnMatch_cb(IntPtr inst, IntPtr model, IntPtr iter)
 {
     try {
         EntryCompletion __obj = GLib.Object.GetObject(inst, false) as EntryCompletion;
         bool            __result;
         __result = __obj.OnCursorOnMatch(Gtk.TreeModelAdapter.GetObject(model, false), Gtk.TreeIter.New(iter));
         return(__result);
     } catch (Exception e) {
         GLib.ExceptionManager.RaiseUnhandledException(e, true);
         // NOTREACHED: above call does not return.
         throw e;
     }
 }
Example #4
0
 static bool PrefixInserted_cb(IntPtr inst, IntPtr prefix)
 {
     try {
         EntryCompletion __obj = GLib.Object.GetObject(inst, false) as EntryCompletion;
         bool            __result;
         __result = __obj.OnPrefixInserted(GLib.Marshaller.Utf8PtrToString(prefix));
         return(__result);
     } catch (Exception e) {
         GLib.ExceptionManager.RaiseUnhandledException(e, true);
         // NOTREACHED: above call does not return.
         throw e;
     }
 }
Example #5
0
        public GenreEntry ()
        {
            genre_model = new ListStore (typeof (string));
            Model = genre_model;
            TextColumn = 0;

            EntryCompletion c = new EntryCompletion ();
            c.Model = genre_model;
            c.TextColumn = TextColumn;
            c.PopupCompletion = true;
            c.InlineCompletion = true;
            //c.InlineSelection = true; // requires 2.12
            c.PopupSingleMatch = false;
            Entry.Completion = c;

            foreach (string genre in ServiceManager.DbConnection.QueryEnumerable<string> (
                "SELECT DISTINCT Genre FROM CoreTracks ORDER BY Genre")) {
                if (!String.IsNullOrEmpty (genre)) {
                    genre_model.AppendValues (genre);
                }
            }
        }
Example #6
0
        public TextEntry(string completionTable, string completionColumn)
        {
            if (completionTable == null || completionColumn == null) {
                return;
            }

            ListStore completion_model = new ListStore (typeof (string));
            foreach (string val in ServiceManager.DbConnection.QueryEnumerable<string> (String.Format (
                "SELECT DISTINCT {1} FROM {0} ORDER BY {1}", completionTable, completionColumn))) {
                if (!String.IsNullOrEmpty (val)) {
                    completion_model.AppendValues (val);
                }
            }

            Completion = new EntryCompletion ();
            Completion.Model = completion_model;
            Completion.TextColumn = 0;
            Completion.PopupCompletion = true;
            Completion.InlineCompletion = true;
            //Completion.InlineSelection = true; // requires 2.12
            Completion.PopupSingleMatch = false;
        }
Example #7
0
        public LicenseEntry()
            : base(true)
        {
            license_model = new ListStore (typeof (string));
            Model = license_model;
            EntryTextColumn = 0;

            EntryCompletion c = new EntryCompletion ();
            c.Model = license_model;
            c.TextColumn = EntryTextColumn;
            c.PopupCompletion = true;
            c.InlineCompletion = true;
            c.InlineSelection = true;
            c.PopupSingleMatch = false;
            Entry.Completion = c;

            foreach (string license_uri in ServiceManager.DbConnection.QueryEnumerable<string> (
                "SELECT DISTINCT LicenseUri FROM CoreTracks ORDER BY LicenseUri")) {
                if (!String.IsNullOrEmpty (license_uri)) {
                    license_model.AppendValues (license_uri);
                }
            }
        }
Example #8
0
        protected EditTagsWindow(Builder builder, IntPtr handle, BooruImage image) : base(handle)
        {
            builder.Autoconnect(this);

            var           db   = image.db;
            List <string> tags = db.GetAllTags();

            tags.Sort();

            if (completion == null)
            {
                var completionStore = new Gtk.ListStore(typeof(string));
                foreach (var tag in tags)
                {
                    completionStore.AppendValues(tag);
                    completionStore.AppendValues("-" + tag);
                }

                completion                  = new Gtk.EntryCompletion();
                completion.Model            = completionStore;
                completion.TextColumn       = 0;
                completion.MinimumKeyLength = 3;
            }

            TagEntry.Completion = completion;

            this.image            = image;
            this.imageView        = new ImageViewWidget();
            this.imageView.Drawn += (System.Object o, Gtk.DrawnArgs args) => {
                BooruImageWidget.ImageViewTagsOverlay(args.Cr, this.image, this.imageView);
            };
            this.ImageViewBox.PackStart(this.imageView, true, true, 2);
            this.imageView.Anim = image.Anim;

            this.Maximize();
        }
        public bool LogicEntryCompletionMatchFunc(EntryCompletion completion, string key, TreeIter iter)
        {
            if (Completing)
                return false;

            // If this is the fist comparison for this key, convert the key (which is the entire search string)
            // into just the part that is relevant to completing this tag name.
            if (key != last_key) {
                last_key = key;

                int pos = entry.Position - 1;
                if (key == null || key.Length == 0 || pos < 0 || pos > key.Length - 1)
                    transformed_key = String.Empty;
                else if (key [pos] == '(' || key [pos] == ')' || key [pos] == ',')
                    transformed_key = String.Empty;
                else {
                    int start = 0;
                    for (int i = entry.Position - 1; i >= 0; i--) {
                        if (key [i] == ' ' || key [i] == ')' || key [i] == '(') {
                            //Console.WriteLine ("have start break char at {0}", i);
                            start = i + 1;
                            break;
                        }
                    }

                    int end = key.Length - 1;
                    for (int j = entry.Position - 1; j < key.Length; j++) {
                        if (key [j] == ' ' || key [j] == ')' || key [j] == '(') {
                            end = j - 1;
                            break;
                        }
                    }

                    //Console.WriteLine ("start = {0} end = {1}", start, end);

                    int len = end - start + 1;
                    if (len > 0 && start < last_key.Length)
                        transformed_key = last_key.Substring (start, end - start + 1);
                    else
                        transformed_key = String.Empty;
                }
                //Console.WriteLine ("transformed key {0} into {1}", key, transformed_key);
            }

            if (transformed_key == String.Empty)
                return false;

            string name = completion.Model.GetValue (iter, completion.TextColumn) as string;

            // Ignore null or names that are too short
            if (name == null || name.Length <= transformed_key.Length)
                return false;

            //Console.WriteLine ("entered = {0} compared to {1}", transformed_key, name);
            return (String.Compare (transformed_key, name.Substring(0, transformed_key.Length), true) == 0);
        }
Example #10
0
		private bool LocationItemCompletionMatch (EntryCompletion comp, string key, TreeIter iter) {
			Model.Item item = (Model.Item)comp.Model.GetValue(iter,0);
			if(item == null) return false;
			return item.MatchesKey(key);
		}
Example #11
0
		private bool ItemTabCompletionMatch (EntryCompletion comp, string key, TreeIter iter) {
			string name = ((ItemTag)comp.Model.GetValue(iter,0)).Name;
			return name.ToLower().Contains(key.Trim().ToLower());
		}
Example #12
0
 bool Completion_MatchFunc(EntryCompletion completion, string key, TreeIter iter)
 {
     var val = completion.Model.GetValue (iter, (int)columns.Street).ToString ().ToLower ();
     return Regex.IsMatch (val, String.Format ("\\b{0}.*", Regex.Escape (this.Text.ToLower ())));
 }
Example #13
0
        void InitializeEntryCompletion()
        {
            entryCompletion = new EntryCompletion();

            peopleComboBoxEntry.Entry.Completion = entryCompletion;
            entryCompletion.Model = peopleTreeStore;
            entryCompletion.TextColumn = 0;
            entryCompletion.InlineCompletion = true;
        }
Example #14
0
		private Gtk.Widget CreateContents ()
		{
			Gtk.HBox entryLine = new HBox (false, 4);

			Gtk.Label words = new Gtk.Label (Catalog.GetString ("Search terms:"));
			entryLine.PackStart (words, false, false, 3);

			history = new Gtk.ListStore (new Type[] { typeof (string) });

			Gtk.EntryCompletion comp = new Gtk.EntryCompletion ();
			comp.Model = history;
			comp.TextColumn = 0;
			
			entry = new Gtk.Entry ("");
			entry.Activated += new EventHandler (this.DoSearch);
			entry.Completion = comp;
			entryLine.PackStart (entry, true, true, 3);

			words = new Gtk.Label ("");
			entryLine.PackStart (words, false, false, 3);

			Gtk.ComboBox combo = FilterComboBox ();
			combo.Changed += new EventHandler (this.ChangeType);
			entryLine.PackStart (combo, false, false, 3);

			Gtk.HBox buttonContents = new HBox (false, 0);
			Gtk.Widget buttonImg = Beagle.Images.GetWidget ("icon-search.png");
			buttonContents.PackStart (buttonImg, false, false, 1);
			Gtk.Label buttonLabel = new Gtk.Label (Catalog.GetString ("Find"));
			buttonContents.PackStart (buttonLabel, false, false, 1);
			
			Gtk.Button button = new Gtk.Button ();
			button.Add (buttonContents);
			button.Clicked += new EventHandler (this.DoSearch);
			entryLine.PackStart (button, false, false, 3);
			
			Gtk.Button clearButton = new Gtk.Button ();
			clearButton.Label = "Clear";
			clearButton.Clicked += new EventHandler (this.ClearSearch);
			entryLine.PackStart (clearButton, false, false, 4);

			canvas = new TileCanvas ();
			canvas.Show ();

			HBox pager = new HBox ();
			page_label = new Label ();
			page_label.Show ();
			pager.PackStart (page_label, false, false, 3);

			forward_button = StockButton ("gtk-go-forward", 
						      Catalog.GetString ("Show More Results"));
			forward_button.Show ();
			forward_button.Clicked += new EventHandler (PageForwardHandler);
			pager.PackEnd (forward_button, false, false, 3);

			back_button = StockButton ("gtk-go-back",
						   Catalog.GetString ("Show Previous Results"));
			back_button.Show ();

			back_button.Clicked += new EventHandler (PageBackHandler);
			pager.PackEnd (back_button, false, false, 3);

			pager.Show ();

			VBox contents = new VBox (false, 3);
			contents.PackStart (entryLine, false, true, 3);
			contents.PackStart (canvas, true, true, 3);
			contents.PackStart (pager, false, false, 3);

			entryLine.ShowAll ();
			canvas.ShowAll ();

			return contents;
		}
Example #15
0
        private Gtk.Widget CreateContents()
        {
            Gtk.HBox entryLine = new HBox(false, 4);

            Gtk.Label words = new Gtk.Label(Catalog.GetString("Search terms:"));
            entryLine.PackStart(words, false, false, 3);

            history = new Gtk.ListStore(new Type[] { typeof(string) });

            Gtk.EntryCompletion comp = new Gtk.EntryCompletion();
            comp.Model      = history;
            comp.TextColumn = 0;

            entry            = new Gtk.Entry("");
            entry.Activated += new EventHandler(this.DoSearch);
            entry.Completion = comp;
            entryLine.PackStart(entry, true, true, 3);

            words = new Gtk.Label("");
            entryLine.PackStart(words, false, false, 3);

            Gtk.ComboBox combo = FilterComboBox();
            combo.Changed += new EventHandler(this.ChangeType);
            entryLine.PackStart(combo, false, false, 3);

            Gtk.HBox   buttonContents = new HBox(false, 0);
            Gtk.Widget buttonImg      = Beagle.Images.GetWidget("icon-search.png");
            buttonContents.PackStart(buttonImg, false, false, 1);
            Gtk.Label buttonLabel = new Gtk.Label(Catalog.GetString("Find"));
            buttonContents.PackStart(buttonLabel, false, false, 1);

            Gtk.Button button = new Gtk.Button();
            button.Add(buttonContents);
            button.Clicked += new EventHandler(this.DoSearch);
            entryLine.PackStart(button, false, false, 3);

            Gtk.Button clearButton = new Gtk.Button();
            clearButton.Label    = "Clear";
            clearButton.Clicked += new EventHandler(this.ClearSearch);
            entryLine.PackStart(clearButton, false, false, 4);

            canvas = new TileCanvas();
            canvas.Show();

            HBox pager = new HBox();

            page_label = new Label();
            page_label.Show();
            pager.PackStart(page_label, false, false, 3);

            forward_button = StockButton("gtk-go-forward",
                                         Catalog.GetString("Show More Results"));
            forward_button.Show();
            forward_button.Clicked += new EventHandler(PageForwardHandler);
            pager.PackEnd(forward_button, false, false, 3);

            back_button = StockButton("gtk-go-back",
                                      Catalog.GetString("Show Previous Results"));
            back_button.Show();

            back_button.Clicked += new EventHandler(PageBackHandler);
            pager.PackEnd(back_button, false, false, 3);

            pager.Show();

            VBox contents = new VBox(false, 3);

            contents.PackStart(entryLine, false, true, 3);
            contents.PackStart(canvas, true, true, 3);
            contents.PackStart(pager, false, false, 3);

            entryLine.ShowAll();
            canvas.ShowAll();

            return(contents);
        }
Example #16
0
		static void LoadHistory (string propertyName, ComboBoxEntry entry)
		{
			var ec = new EntryCompletion ();
/*			entry.Changed += delegate {
				if (!entry.Entry.HasFocus)
					entry.Entry.GrabFocus ();

			};*/


			entry.Entry.Completion = ec;
			var store = new ListStore (typeof(string));
			entry.Entry.Completion.Model = store;
			entry.Model = store;
			entry.Entry.ActivatesDefault = true;
			entry.TextColumn = 0;
			var history = PropertyService.Get<string> (propertyName);
			if (!string.IsNullOrEmpty (history)) {
				string[] items = history.Split (historySeparator);
				foreach (string item in items) {
					if (string.IsNullOrEmpty (item))
						continue;
					store.AppendValues (item);
				}
				entry.Entry.Text = items[0];
			}
		}
Example #17
0
    /* Constructor */
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build();
        entry4.Activated += new System.EventHandler(this.OnTextEntered);
        findEntry.Activated += new System.EventHandler(this.OnSearchActivated);
        glwidget1.CanFocus = true;

        entry4.ModifyBase(StateType.Normal, new Gdk.Color(25, 25, 50));
        entry4.ModifyBg(StateType.Normal, new Gdk.Color(25, 25, 50));
        entry4.ModifyFg(StateType.Normal, new Gdk.Color(25, 25, 50));

        entry4.ModifyText(StateType.Normal, new Gdk.Color(240, 240, 240));
        entry4.ModifyCursor(new Gdk.Color(0, 240, 0), new Gdk.Color(0, 0, 255));

        if(GraphicsContext.ShareContexts) {
            GLWidget.GraphicsContextInitialized += new System.EventHandler(this.OnGlwidgetInit);
            GLWidget.GraphicsContextShuttingDown += new System.EventHandler(this.OnWidgetShuttingDown);
        } else {
            glwidget1.Initialized += new System.EventHandler(this.OnGlwidgetInit);
            glwidget1.ShuttingDown += new System.EventHandler(this.OnWidgetShuttingDown);
        }

        completer.DirsOnly = true;
        completion = new EntryCompletion();
        entry4.Completion = completion;
        completion.TextColumn = 0;
        store = new ListStore(GType.String);
        completion.Model = store;
        completion.MinimumKeyLength = 1;
        glwidget1.GrabFocus();
    }
Example #18
0
        public bool LogicEntryCompletionMatchFunc(EntryCompletion completion, string key, TreeIter iter)
        {
            if (Completing)
                return false;

            key = key == null ? null : key.Normalize(NormalizationForm.FormC);
            string name = completion.Model.GetValue (iter, completion.TextColumn) as string;
            int pos = entry.Position - 1;
            return completion_logic.MatchFunc (name, key, pos);
        }
Example #19
0
 bool Completion_MatchFunc(EntryCompletion completion, string key, TreeIter iter)
 {
     var val = (string)completion.Model.GetValue (iter, 0);
     return Regex.IsMatch (val, String.Format ("{0}", Regex.Escape (this.Text)), RegexOptions.IgnoreCase);
 }