-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add/implement word completion with gtk_source_completion and add conf…
…igurable setting to enable/disable word completion in settings->file load/save->word completion. Protect includes to insure building without gtksourceview.
- Loading branch information
David C. Rankin
committed
Jul 28, 2018
1 parent
c35211d
commit c3f9634
Showing
8 changed files
with
176 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
static const int stub; | ||
|
||
#if defined (WGTKSOURCEVIEW2) || defined (WGTKSOURCEVIEW3) || defined (WGTKSOURCEVIEW4) | ||
|
||
#include "gtk_completionsv.h" | ||
|
||
typedef struct _cmplprovider cmplprovider; | ||
typedef struct _cmplproviderClass cmplproviderClass; | ||
|
||
struct _cmplprovider | ||
{ | ||
GObject parent; | ||
|
||
GList *proposals; | ||
gint priority; | ||
gchar *name; | ||
|
||
GdkPixbuf *icon; | ||
}; | ||
|
||
struct _cmplproviderClass | ||
{ | ||
GObjectClass parent_class; | ||
}; | ||
|
||
static void cmpl_provider_iface_init (GtkSourceCompletionProviderIface *iface); | ||
|
||
G_DEFINE_TYPE_WITH_CODE (cmplprovider, cmpl_provider, G_TYPE_OBJECT, | ||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SOURCE_COMPLETION_PROVIDER, | ||
cmpl_provider_iface_init)) | ||
|
||
static gchar *cmpl_provider_get_name (GtkSourceCompletionProvider *provider) | ||
{ | ||
return g_strdup (((cmplprovider *)provider)->name); | ||
} | ||
|
||
static gint cmpl_provider_get_priority (GtkSourceCompletionProvider *provider) | ||
{ | ||
return ((cmplprovider *)provider)->priority; | ||
} | ||
|
||
static gboolean cmpl_provider_match (GtkSourceCompletionProvider *provider, | ||
GtkSourceCompletionContext *context) | ||
{ | ||
return TRUE; | ||
|
||
if (provider || context) {} | ||
} | ||
|
||
static void cmpl_provider_populate (GtkSourceCompletionProvider *provider, | ||
GtkSourceCompletionContext *context) | ||
{ | ||
gtk_source_completion_context_add_proposals (context, provider, | ||
((cmplprovider *)provider)->proposals, | ||
TRUE); | ||
} | ||
|
||
static void cmpl_provider_iface_init (GtkSourceCompletionProviderIface *iface) | ||
{ | ||
iface->get_name = cmpl_provider_get_name; | ||
|
||
iface->populate = cmpl_provider_populate; | ||
iface->match = cmpl_provider_match; | ||
iface->get_priority = cmpl_provider_get_priority; | ||
|
||
// iface->get_icon = cmpl_provider_get_icon; | ||
iface->get_icon = NULL; | ||
} | ||
|
||
static void cmpl_provider_class_init (cmplproviderClass *klass) | ||
{ | ||
if (klass) {} | ||
} | ||
|
||
static void cmpl_provider_init (cmplprovider *self) | ||
{ | ||
GList *proposals = NULL; | ||
self->proposals = proposals; | ||
} | ||
|
||
void create_completion (kwinst *app) | ||
{ | ||
GtkSourceCompletionWords *prov_words; | ||
|
||
app->completion = gtk_source_view_get_completion (GTK_SOURCE_VIEW (app->view)); | ||
|
||
prov_words = gtk_source_completion_words_new (NULL, NULL); | ||
|
||
gtk_source_completion_words_register (prov_words, | ||
gtk_text_view_get_buffer (GTK_TEXT_VIEW (app->view))); | ||
|
||
gtk_source_completion_add_provider (app->completion, | ||
GTK_SOURCE_COMPLETION_PROVIDER (prov_words), | ||
NULL); | ||
|
||
// g_object_set (prov_words, "priority", 10, NULL); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef __completionsv_h__ | ||
#define __completionsv_h__ 1 | ||
|
||
#if defined (WGTKSOURCEVIEW2) || defined (WGTKSOURCEVIEW3) || defined (WGTKSOURCEVIEW4) | ||
|
||
#include <gtksourceview/gtksourceview.h> | ||
#include <gtksourceview/gtksourcecompletion.h> | ||
#include <gtksourceview/gtksourcecompletioninfo.h> | ||
#include <gtksourceview/gtksourcecompletionitem.h> | ||
#include <gtksourceview/gtksourcelanguagemanager.h> | ||
#include <gtksourceview/completion-providers/words/gtksourcecompletionwords.h> | ||
|
||
#include "gtk_appdata.h" | ||
|
||
void create_completion (kwinst *app); | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters