class TestProvider : Gtk.SourceCompletionProvider, Object { Gdk.Pixbuf icon; public string name; public int priority; List proposals; construct { Gdk.Pixbuf icon = this.get_icon (); this.proposals = new List (); this.proposals.prepend (new Gtk.SourceCompletionItem ("Proposal 3", "Proposal 3", null, null)); this.proposals.prepend (new Gtk.SourceCompletionItem ("Proposal 2", "Proposal 2", null, null)); this.proposals.prepend (new Gtk.SourceCompletionItem ("Proposal 1", "Proposal 1", null, null)); } public unowned string get_name () { return this.name; } public int get_priority () { return this.priority; } public bool match (Gtk.SourceCompletionContext context) { return true; } public void populate (Gtk.SourceCompletionContext context) { context.add_proposals (this, this.proposals, true); } public unowned Gdk.Pixbuf get_icon () { if (this.icon == null) { Gtk.IconTheme theme = Gtk.IconTheme.get_default (); this.icon = theme.load_icon (Gtk.STOCK_DIALOG_INFO, 16, 0); } return this.icon; } public bool activate_proposal (Gtk.SourceCompletionProposal proposal, Gtk.TextIter iter) { return true; } public Gtk.SourceCompletionActivation get_activation () { return Gtk.SourceCompletionActivation.INTERACTIVE | Gtk.SourceCompletionActivation.USER_REQUESTED; } public unowned Gtk.Widget get_info_widget (Gtk.SourceCompletionProposal proposal) { return null; } public int get_interactive_delay () { return -1; } public bool get_start_iter (Gtk.SourceCompletionContext context, Gtk.SourceCompletionProposal proposal, Gtk.TextIter iter) { return false; } public void update_info (Gtk.SourceCompletionProposal proposal, Gtk.SourceCompletionInfo info) { } } Gtk.SourceView view; Gtk.SourceCompletion comp; void destroy_cb (Gtk.Object object) { Gtk.main_quit (); } void remember_toggled_cb (Gtk.ToggleButton button) { comp.remember_info_visibility = button.get_active (); } void select_on_show_toggled_cb (Gtk.ToggleButton button) { comp.select_on_show = button.get_active (); } void show_headers_toggled_cb (Gtk.ToggleButton button) { comp.show_headers = button.get_active (); } void toggle_active_property (Object source, Object dest, string name) { bool val; source.get (name, out val); dest.set ("active", val); } void show_icons_toggled_cb (Gtk.ToggleButton button) { comp.show_icons = button.get_active (); } Gtk.Window create_window () { Gtk.Window window; Gtk.VBox vbox; Gtk.HBox hbox; Gtk.CheckButton remember; Gtk.CheckButton select_on_show; Gtk.CheckButton show_headers; Gtk.CheckButton show_icons; Gtk.SourceCompletion completion; window = new Gtk.Window (); window.resize (600, 400); vbox = new Gtk.VBox (false, 1); hbox = new Gtk.HBox (false, 1); view = new Gtk.SourceView (); Gtk.ScrolledWindow scroll = new Gtk.ScrolledWindow (null, null); scroll.add (view); remember = new Gtk.CheckButton.with_label ("Remember info visibility"); select_on_show = new Gtk.CheckButton.with_label ("Select first on show"); show_headers = new Gtk.CheckButton.with_label ("Show headers"); show_icons = new Gtk.CheckButton.with_label ("Show icons"); completion = view.get_completion (); toggle_active_property (completion, remember, "remember-info-visibility"); toggle_active_property (completion, select_on_show, "select-on-show"); toggle_active_property (completion, show_headers, "show-headers"); toggle_active_property (completion, show_icons, "show-icons"); hbox.pack_start (remember, false, false, 0); hbox.pack_start (select_on_show, false, false, 0); hbox.pack_start (show_headers, false, false, 0); hbox.pack_start (show_icons, false, false, 0); vbox.pack_start (scroll, true, true, 0); vbox.pack_end (hbox, false, false, 0); window.add (vbox); window.destroy.connect (destroy_cb); remember.toggled.connect (remember_toggled_cb); select_on_show.toggled.connect (select_on_show_toggled_cb); show_headers.toggled.connect (show_headers_toggled_cb); show_icons.toggled.connect (show_icons_toggled_cb); return window; } void create_completion () { //Gtk.SourceCompletionWords prov_words; comp = view.get_completion (); /*prov_words = new Gtk.SourceCompletionWords (null, null); prov_words.register (view.get_buffer ()); comp.add_provider (prov_words); prov_words.priority = 10;*/ TestProvider tp = new TestProvider (); tp.priority = 1; tp.name = "Test Provider 1"; comp.add_provider (tp); tp = new TestProvider (); tp.priority = 5; tp.name = "Test Provider 5"; comp.add_provider (tp); } void main (string[] args) { Gtk.Window window; Gtk.init (ref args); window = create_window (); create_completion (); window.show_all (); Gtk.main (); }