GNOME Bugzilla – Bug 454796
Completion popup for gtksourceview
Last modified: 2007-08-12 20:03:10 UTC
I am developed a popup to gtksourceview. It supports add new data providers, add custom events, raise completion by code, automatically or when the users press control+return. It is a generic popup without any provider. The application developer may add the provider that he wants (autocompletion, snippets provider, symbols provider etc.)
I upload the patch. Really is a gzip with the new files and with come diff of files modified. I try to upload a gedit plugin example using the completion support and you can see the easy of use this popup and develop new providers.
Created attachment 91407 [details] completion data
Created attachment 91408 [details] completion data header
Created attachment 91410 [details] the principal popup
Created attachment 91411 [details] the principal popup (header)
Created attachment 91412 [details] the completion data provider
Created attachment 91413 [details] the completion data provider (header)
Created attachment 91414 [details] Utils used by completion objects
Created attachment 91415 [details] Utils used by completion objects (header)
Created attachment 91416 [details] [review] gtksourceview.c patch
Created attachment 91417 [details] [review] gtksourceview.h patch
Created attachment 91418 [details] [review] Makefile.am patch
Created attachment 91455 [details] completion data
Created attachment 91456 [details] completion data header
Created attachment 91457 [details] the principal popup
Created attachment 91458 [details] the completion data provider (header)
Created attachment 91459 [details] the completion data provider
Created attachment 91460 [details] the completion data provider (header)
Created attachment 91461 [details] Utils used by completion objects
Created attachment 91462 [details] Utils used by completion objects (header)
Created attachment 91463 [details] [review] gtksourceview.c patch
Created attachment 91464 [details] [review] gtksourceview.h patch
Created attachment 91465 [details] [review] Makefile.am patch
.- I have changed the objects names from gtk-source-view-completion... to gtk-source-completion. .- I have added the license in all files .- I have cleaned some vala and gob code .- I have removed some spanish comments .- I have formatted some functions to gnome style If you think that there are something wrong, make me know please.
Could you please give us more info about this patch? I only read the gtksource-completion-data.h file. Here my comments: - it seems there is no way to prioritize items - GtkSourceCompletionData is a GObject, so there is no need to a special free function - I don't thinks GtkSourceCompletionData should be a GObject, probably a boxed type is enough - It would be nice to be able to add additional info to a completion item, like for example a "help" message, like in Eclipse. - I don't think using a GdkPixbuf for the icon is a good idea, there should be a way to use stock icons to promote consistency.
I have create a wiki page on http://live.gnome.org/GtkSourceView/GtkSourceCompletion where I explain a bit GtkSourceCompletion. I will write more about. - Completion cannot prioritize data. I was waitting to talk with gtksourceview developers and take a solution for it. i think we can add an int field priority and order the items, or add an int field and prioritize the providers. - If GtkSourceCompletionData isn't a GObject, you cannot override it. Perhaps we can create a boxed type but we need add some more functions to data provider to manage the data content. - I will add to completion a "preview" but I need to talk you you about how you want to do it. Perhaps a tooltip near the item or a GtkSourceView on the right of data list shown the preview of the selected item etc... - I think GdkPixbuf is good because a program like openldev or anjuta can change the default icons. We can add a new method to support stock icons. If you want, we can talk about it on IRC and we can write some changes and I modify the code.
I have changed some things: - Added a priority property to GtkSourceCompletionData - GtkSourceCompletionPopup sort all items by priority - I have removed gtk_source_completion_popup_add_event - I have changed gtk_source_completion_popup_register_provider. Now you must pass a parameter with the event name. When an event occurs, the popup only call the providers registered for this event. If you have some another change, make me know.
Created attachment 92617 [details] gtksourcecompletion.c
Created attachment 92618 [details] gtksourcecompletion.h
Created attachment 92619 [details] gtksourcecompletion-events.c
Created attachment 92620 [details] gtksourcecompletion-events.h
Created attachment 92621 [details] gtksourcecompletion-provider.c
Created attachment 92622 [details] gtksourcecompletion-provider.h
Created attachment 92623 [details] gtksourcecompletion-utils.c
Created attachment 92624 [details] gtksourcecompletion-utils.h
Created attachment 92625 [details] [review] gtksourceview.diff
Hi all again, I have refactored the code and cleaned some issues: 1.- GtkSourceCompletionData: now is GtkSourceCompletionItem and it isn't a GObject, only a boxed type. 2.- Events are in a separate file called gtksourcecompletion-events.c. There are two implemented events: user request event and autocompletion event. 3.- GtkSourceCompletionPopup is now GtkSourceCompletion 4.- Renamed some variables.
Created attachment 92626 [details] completiontest.tar.gz (gedit plugin)
I have attached a gedit plugin using the completion mechanism. with only a few lines, we can create a provider and activate the completion support. This plugin is very simple, only shows constant data in user request event and use the priority feature. It use autocompletion event too, showing some lines with the actual word.
I have created a new library: gtksourcecompletion. Perhaps we add this functionality to gtksourceview in a future. Now, you can download the completion support at http://tools.assembla.com/gtkdevtools. There are two packages, the gtksourcecompletion library and a gedit plugin using it. The plugin complete words wrotten in the document. The code is very changed (but not the api) and we have a lot of new features. Regards, Chuchi