Re: gtk-app-devel-list Digest, Vol 81, Issue 20



It appears that GtkSourceCompletionWords provider grabs the words that exist in your text view and offers one of those as completion suggestion once you type a similar word. Correct me if I am wrong, but this is my experience with almost exact code as the one you are using. And the fact that GtkSourceCompletionWords is completely undocumented doesn't help either :)

Basically, this makes it unusable as a provider of a predefined list of works.

Regards,
 Miroslav

----- Original Message ----- From: "craigbakalian" <craigbakalian verizon net>
To: <gtk-app-devel-list gnome org>
Sent: Thursday, January 20, 2011 9:45 AM
Subject: Re: gtk-app-devel-list Digest, Vol 81, Issue 20


Hi,

I did some hacking into this.  If you want a simple form of completion
you can use the following implementation-

#include <gtksourceview/gtksourcecompletion.h>
#include <gtksourceview/gtksourcecompletioninfo.h>
#include <gtksourceview/gtksourcecompletionitem.h>
#include
<gtksourceview/completion-providers/words/gtksourcecompletionwords.h>

GtkSourceCompletionWords *prov_words;

comp = gtk_source_view_get_completion (GTK_SOURCE_VIEW (textview));

prov_words = gtk_source_completion_words_new (NULL, NULL);

gtk_source_completion_words_register (prov_words,
 gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)));

gtk_source_completion_add_provider (comp,
 GTK_SOURCE_COMPLETION_PROVIDER (prov_words)NULL);

I added more than needed #includes above for safety. You may want to
test the code and remove some of them. If you want to make a more
complex you have to build your own provider from scratch with a
structure, create it as an object and pass it into
gtk_source_completion_add_provider, because GtkSourceCompletionProvider
has no constructor, which is weird.

Craig Bakalian


On Wed, 2011-01-19 at 12:00 +0000, gtk-app-devel-list-request gnome org
wrote:
As far as I can see GtkSourceCompletion is not obsolete, it has just
become
part of the GtkSourceView library.
See here: http://library.gnome.org/devel/gtksourceview/stable/

I also started looking for the examples of its usage.
You can find an example in GtkSourceView code itself and in Anjuta
code.
But I agree, there is no good example out there.

Documentation is also quite terse, and it is not clear on what needs
to be
done
to have your custom implementation, passing your own word list for
example.
GtkSourceView provides sample completion provider named
gtksourcecompletionwords,
but it is undocumented, so it seems it will need effort to use this.

Regards,
  Miroslav

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

__________ Information from ESET NOD32 Antivirus, version of virus signature database 5801 (20110119) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]