| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include "config.h" |
| 21 |
|
| 22 |
#include <glib/gi18n.h> |
| 23 |
|
| 24 |
#include <gtksourceview/gtksource-enumtypes.h> |
| 25 |
#include <gtksourceview/gtksourcebuffer.h> |
| 26 |
#include <gtksourceview/gtksourcecompletion.h> |
| 27 |
#include <gtksourceview/gtksourcecompletioncell.h> |
| 28 |
#include <gtksourceview/gtksourcecompletioncontext.h> |
| 29 |
#include <gtksourceview/gtksourceiter-private.h> |
| 30 |
#include <gtksourceview/gtksourcelanguage.h> |
| 31 |
#include <gtksourceview/gtksourcesnippet.h> |
| 32 |
#include <gtksourceview/gtksourcesnippetmanager.h> |
| 33 |
#include <gtksourceview/gtksourceview.h> |
| 34 |
|
| 35 |
#include "gtksourcecompletionsnippets.h" |
| 36 |
#include "gtksourcecompletionsnippetsproposal-private.h" |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
typedef struct |
| 49 |
{ |
| 50 |
char *word; |
| 51 |
int minimum_word_size; |
| 52 |
guint filter_all : 1; |
| 53 |
} FilterData; |
| 54 |
|
| 55 |
static void |
| 56 |
filter_data_finalize (FilterData *fd) |
| 57 |
{ |
| 58 |
g_clear_pointer (&fd->word, g_free); |
| 59 |
} |
| 60 |
|
| 61 |
static void |
| 62 |
filter_data_release (FilterData *fd) |
| 63 |
{ |
| 64 |
g_atomic_rc_box_release_full (fd, (GDestroyNotify)filter_data_finalize); |
| 65 |
} |
| 66 |
|
| 67 |
struct _GtkSourceSnippetResults |
| 68 |
{ |
| 69 |
GObject parent_instance; |
| 70 |
GListModel *snippets; |
| 71 |
}; |
| 72 |
|
| 73 |
static void list_model_iface_init (GListModelInterface *iface); |
| 74 |
|
| 75 |
#define GTK_SOURCE_TYPE_SNIPPET_RESULTS (gtk_source_snippet_results_get_type()) |
| 76 |
G_DECLARE_FINAL_TYPE (GtkSourceSnippetResults, gtk_source_snippet_results, GTK_SOURCE, SNIPPET_RESULTS, GObject) |
| 77 |
G_DEFINE_TYPE_WITH_CODE (GtkSourceSnippetResults, gtk_source_snippet_results, G_TYPE_OBJECT, |
| 78 |
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init)) |
| 79 |
|
| 80 |
static GType |
| 81 |
gtk_source_snippet_results_get_item_type (GListModel *model) |
| 82 |
{ |
| 83 |
return GTK_SOURCE_TYPE_COMPLETION_PROPOSAL; |
| 84 |
} |
| 85 |
|
| 86 |
static guint |
| 87 |
gtk_source_snippet_results_get_n_items (GListModel *model) |
| 88 |
{ |
| 89 |
GtkSourceSnippetResults *self = (GtkSourceSnippetResults *)model; |
| 90 |
|
| 91 |
if (self->snippets != NULL) |
| 92 |
{ |
| 93 |
return g_list_model_get_n_items (self->snippets); |
| 94 |
} |
| 95 |
|
| 96 |
return 0; |
| 97 |
} |
| 98 |
|
| 99 |
static gpointer |
| 100 |
gtk_source_snippet_results_get_item (GListModel *model, |
| 101 |
guint position) |
| 102 |
{ |
| 103 |
GtkSourceSnippetResults *self = (GtkSourceSnippetResults *)model; |
| 104 |
|
| 105 |
g_assert (!self->snippets || GTK_SOURCE_IS_SNIPPET_BUNDLE (self->snippets)); |
| 106 |
|
| 107 |
if (self->snippets != NULL) |
| 108 |
{ |
| 109 |
GtkSourceSnippetBundle *bundle = GTK_SOURCE_SNIPPET_BUNDLE (self->snippets); |
| 110 |
const GtkSourceSnippetInfo *info = _gtk_source_snippet_bundle_get_info (bundle, position); |
| 111 |
return gtk_source_completion_snippets_proposal_new (bundle, info); |
| 112 |
} |
| 113 |
|
| 114 |
return NULL; |
| 115 |
} |
| 116 |
|
| 117 |
static void |
| 118 |
list_model_iface_init (GListModelInterface *iface) |
| 119 |
{ |
| 120 |
iface->get_item_type = gtk_source_snippet_results_get_item_type; |
| 121 |
iface->get_n_items = gtk_source_snippet_results_get_n_items; |
| 122 |
iface->get_item = gtk_source_snippet_results_get_item; |
| 123 |
} |
| 124 |
|
| 125 |
static GListModel * |
| 126 |
gtk_source_snippet_results_new (GListModel *base_model) |
| 127 |
{ |
| 128 |
GtkSourceSnippetResults *self = g_object_new (GTK_SOURCE_TYPE_SNIPPET_RESULTS, NULL); |
| 129 |
g_set_object (&self->snippets, base_model); |
| 130 |
return G_LIST_MODEL (self); |
| 131 |
} |
| 132 |
|
| 133 |
static void |
| 134 |
gtk_source_snippet_results_finalize (GObject *object) |
| 135 |
{ |
| 136 |
GtkSourceSnippetResults *self = (GtkSourceSnippetResults *)object; |
| 137 |
|
| 138 |
g_clear_object (&self->snippets); |
| 139 |
|
| 140 |
G_OBJECT_CLASS (gtk_source_snippet_results_parent_class)->finalize (object); |
| 141 |
} |
| 142 |
|
| 143 |
static void |
| 144 |
gtk_source_snippet_results_class_init (GtkSourceSnippetResultsClass *klass) |
| 145 |
{ |
| 146 |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
| 147 |
|
| 148 |
object_class->finalize = gtk_source_snippet_results_finalize; |
| 149 |
} |
| 150 |
|
| 151 |
static void |
| 152 |
gtk_source_snippet_results_init (GtkSourceSnippetResults *self) |
| 153 |
{ |
| 154 |
} |
| 155 |
|
| 156 |
typedef struct |
| 157 |
{ |
| 158 |
FilterData *filter_data; |
| 159 |
char *title; |
| 160 |
int priority; |
| 161 |
} GtkSourceCompletionSnippetsPrivate; |
| 162 |
|
| 163 |
static void completion_provider_iface_init (GtkSourceCompletionProviderInterface *iface); |
| 164 |
|
| 165 |
G_DEFINE_TYPE_WITH_CODE (GtkSourceCompletionSnippets, gtk_source_completion_snippets, G_TYPE_OBJECT, |
| 166 |
G_ADD_PRIVATE (GtkSourceCompletionSnippets) |
| 167 |
G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER, completion_provider_iface_init)) |
| 168 |
|
| 169 |
enum { |
| 170 |
PROP_0, |
| 171 |
PROP_TITLE, |
| 172 |
PROP_PRIORITY, |
| 173 |
N_PROPS |
| 174 |
}; |
| 175 |
|
| 176 |
static GParamSpec *properties[N_PROPS]; |
| 177 |
|
| 178 |
static gboolean |
| 179 |
filter_snippet_func (gpointer item, |
| 180 |
gpointer user_data) |
| 181 |
{ |
| 182 |
GtkSourceCompletionSnippetsProposal *proposal = item; |
| 183 |
FilterData *fd = user_data; |
| 184 |
|
| 185 |
g_assert (GTK_SOURCE_IS_COMPLETION_SNIPPETS_PROPOSAL (proposal)); |
| 186 |
g_assert (fd != NULL); |
| 187 |
|
| 188 |
if (fd->filter_all) |
| 189 |
{ |
| 190 |
return FALSE; |
| 191 |
} |
| 192 |
|
| 193 |
if (proposal->info.trigger == NULL) |
| 194 |
{ |
| 195 |
return FALSE; |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
return strstr (proposal->info.trigger, fd->word) != NULL; |
| 204 |
} |
| 205 |
|
| 206 |
static GListModel * |
| 207 |
gtk_source_completion_snippets_populate (GtkSourceCompletionProvider *provider, |
| 208 |
GtkSourceCompletionContext *context, |
| 209 |
GError **error) |
| 210 |
{ |
| 211 |
GtkSourceCompletionSnippets *snippets = GTK_SOURCE_COMPLETION_SNIPPETS (provider); |
| 212 |
GtkSourceCompletionSnippetsPrivate *priv = gtk_source_completion_snippets_get_instance_private (snippets); |
| 213 |
GtkSourceCompletionActivation activation; |
| 214 |
GtkSourceSnippetManager *manager; |
| 215 |
GtkFilterListModel *filter_model; |
| 216 |
GtkSourceLanguage *language; |
| 217 |
GtkCustomFilter *filter; |
| 218 |
GtkSourceBuffer *buffer; |
| 219 |
const char *language_id = ""; |
| 220 |
GListModel *matches; |
| 221 |
GListModel *results; |
| 222 |
|
| 223 |
g_assert (GTK_SOURCE_IS_COMPLETION_SNIPPETS (snippets)); |
| 224 |
g_assert (GTK_SOURCE_IS_COMPLETION_CONTEXT (context)); |
| 225 |
|
| 226 |
buffer = gtk_source_completion_context_get_buffer (context); |
| 227 |
activation = gtk_source_completion_context_get_activation (context); |
| 228 |
manager = gtk_source_snippet_manager_get_default (); |
| 229 |
language = gtk_source_buffer_get_language (buffer); |
| 230 |
|
| 231 |
|
| 232 |
g_free (priv->filter_data->word); |
| 233 |
priv->filter_data->word = gtk_source_completion_context_get_word (context); |
| 234 |
|
| 235 |
priv->filter_data->filter_all = |
| 236 |
(priv->filter_data->word == NULL || |
| 237 |
(activation == GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE && |
| 238 |
g_utf8_strlen (priv->filter_data->word, -1) < (glong)priv->filter_data->minimum_word_size)); |
| 239 |
|
| 240 |
if (language != NULL) |
| 241 |
{ |
| 242 |
language_id = gtk_source_language_get_id (language); |
| 243 |
} |
| 244 |
|
| 245 |
matches = gtk_source_snippet_manager_list_matching (manager, NULL, language_id, NULL); |
| 246 |
results = gtk_source_snippet_results_new (matches); |
| 247 |
g_clear_object (&matches); |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
filter = gtk_custom_filter_new (filter_snippet_func, |
| 254 |
g_atomic_rc_box_acquire (priv->filter_data), |
| 255 |
(GDestroyNotify)filter_data_release); |
| 256 |
filter_model = gtk_filter_list_model_new (results, GTK_FILTER (filter)); |
| 257 |
gtk_filter_list_model_set_incremental (filter_model, TRUE); |
| 258 |
|
| 259 |
return G_LIST_MODEL (filter_model); |
| 260 |
} |
| 261 |
|
| 262 |
static gchar * |
| 263 |
gtk_source_completion_snippets_get_title (GtkSourceCompletionProvider *self) |
| 264 |
{ |
| 265 |
GtkSourceCompletionSnippets *snippets = GTK_SOURCE_COMPLETION_SNIPPETS (self); |
| 266 |
GtkSourceCompletionSnippetsPrivate *priv = gtk_source_completion_snippets_get_instance_private (snippets); |
| 267 |
|
| 268 |
return g_strdup (priv->title); |
| 269 |
} |
| 270 |
|
| 271 |
static gint |
| 272 |
gtk_source_completion_snippets_get_priority (GtkSourceCompletionProvider *provider, |
| 273 |
GtkSourceCompletionContext *context) |
| 274 |
{ |
| 275 |
GtkSourceCompletionSnippets *snippets = GTK_SOURCE_COMPLETION_SNIPPETS (provider); |
| 276 |
GtkSourceCompletionSnippetsPrivate *priv = gtk_source_completion_snippets_get_instance_private (snippets); |
| 277 |
|
| 278 |
return priv->priority; |
| 279 |
} |
| 280 |
|
| 281 |
static void |
| 282 |
gtk_source_completion_snippets_activate (GtkSourceCompletionProvider *provider, |
| 283 |
GtkSourceCompletionContext *context, |
| 284 |
GtkSourceCompletionProposal *proposal) |
| 285 |
{ |
| 286 |
GtkSourceCompletionSnippetsProposal *p = (GtkSourceCompletionSnippetsProposal *)proposal; |
| 287 |
GtkTextIter begin, end; |
| 288 |
|
| 289 |
g_assert (GTK_SOURCE_IS_COMPLETION_SNIPPETS (provider)); |
| 290 |
g_assert (GTK_SOURCE_IS_COMPLETION_CONTEXT (context)); |
| 291 |
g_assert (GTK_SOURCE_IS_COMPLETION_SNIPPETS_PROPOSAL (p)); |
| 292 |
|
| 293 |
if (gtk_source_completion_context_get_bounds (context, &begin, &end)) |
| 294 |
{ |
| 295 |
GtkTextBuffer *buffer = gtk_text_iter_get_buffer (&begin); |
| 296 |
GtkSourceView *view = gtk_source_completion_context_get_view (context); |
| 297 |
GtkSourceSnippet *snippet; |
| 298 |
|
| 299 |
snippet = gtk_source_completion_snippets_proposal_dup_snippet (p); |
| 300 |
|
| 301 |
gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (buffer)); |
| 302 |
gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &begin, &end); |
| 303 |
gtk_source_view_push_snippet (view, snippet, &begin); |
| 304 |
gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (buffer)); |
| 305 |
|
| 306 |
g_object_unref (snippet); |
| 307 |
} |
| 308 |
} |
| 309 |
|
| 310 |
static void |
| 311 |
gtk_source_completion_snippets_display (GtkSourceCompletionProvider *provider, |
| 312 |
GtkSourceCompletionContext *context, |
| 313 |
GtkSourceCompletionProposal *proposal, |
| 314 |
GtkSourceCompletionCell *cell) |
| 315 |
{ |
| 316 |
GtkSourceCompletionSnippetsProposal *p = (GtkSourceCompletionSnippetsProposal *)proposal; |
| 317 |
GtkSourceCompletionColumn column; |
| 318 |
|
| 319 |
g_assert (GTK_SOURCE_IS_COMPLETION_SNIPPETS (provider)); |
| 320 |
g_assert (GTK_SOURCE_IS_COMPLETION_CONTEXT (context)); |
| 321 |
g_assert (GTK_SOURCE_IS_COMPLETION_SNIPPETS_PROPOSAL (p)); |
| 322 |
g_assert (GTK_SOURCE_IS_COMPLETION_CELL (cell)); |
| 323 |
|
| 324 |
column = gtk_source_completion_cell_get_column (cell); |
| 325 |
|
| 326 |
if (column == GTK_SOURCE_COMPLETION_COLUMN_TYPED_TEXT) |
| 327 |
{ |
| 328 |
const char *trigger = p->info.trigger; |
| 329 |
char *word = gtk_source_completion_context_get_word (context); |
| 330 |
PangoAttrList *highlight = gtk_source_completion_fuzzy_highlight (trigger, word); |
| 331 |
|
| 332 |
gtk_source_completion_cell_set_text_with_attributes (cell, trigger, highlight); |
| 333 |
|
| 334 |
pango_attr_list_unref (highlight); |
| 335 |
g_free (word); |
| 336 |
} |
| 337 |
else if (column == GTK_SOURCE_COMPLETION_COLUMN_ICON) |
| 338 |
{ |
| 339 |
gtk_source_completion_cell_set_icon_name (cell, "completion-snippet-symbolic"); |
| 340 |
} |
| 341 |
else if (column == GTK_SOURCE_COMPLETION_COLUMN_COMMENT) |
| 342 |
{ |
| 343 |
gtk_source_completion_cell_set_text (cell, p->info.trigger); |
| 344 |
} |
| 345 |
else if (column == GTK_SOURCE_COMPLETION_COLUMN_DETAILS) |
| 346 |
{ |
| 347 |
gtk_source_completion_cell_set_text (cell, p->info.description); |
| 348 |
} |
| 349 |
else |
| 350 |
{ |
| 351 |
gtk_source_completion_cell_set_text (cell, NULL); |
| 352 |
} |
| 353 |
} |
| 354 |
|
| 355 |
static void |
| 356 |
gtk_source_completion_snippets_refilter (GtkSourceCompletionProvider *provider, |
| 357 |
GtkSourceCompletionContext *context, |
| 358 |
GListModel *model) |
| 359 |
{ |
| 360 |
GtkSourceCompletionSnippets *self = (GtkSourceCompletionSnippets *)provider; |
| 361 |
GtkSourceCompletionSnippetsPrivate *priv = gtk_source_completion_snippets_get_instance_private (self); |
| 362 |
GtkFilterChange change; |
| 363 |
GtkFilter *filter; |
| 364 |
char *old_word; |
| 365 |
char *word; |
| 366 |
|
| 367 |
g_assert (GTK_SOURCE_IS_COMPLETION_SNIPPETS (self)); |
| 368 |
g_assert (GTK_SOURCE_IS_COMPLETION_CONTEXT (context)); |
| 369 |
g_assert (GTK_IS_FILTER_LIST_MODEL (model)); |
| 370 |
|
| 371 |
word = gtk_source_completion_context_get_word (context); |
| 372 |
old_word = g_steal_pointer (&priv->filter_data->word); |
| 373 |
|
| 374 |
if (old_word && g_str_has_prefix (word, old_word)) |
| 375 |
change = GTK_FILTER_CHANGE_MORE_STRICT; |
| 376 |
else if (old_word && g_str_has_prefix (old_word, word)) |
| 377 |
change = GTK_FILTER_CHANGE_LESS_STRICT; |
| 378 |
else |
| 379 |
change = GTK_FILTER_CHANGE_DIFFERENT; |
| 380 |
|
| 381 |
if (priv->filter_data->filter_all) |
| 382 |
{ |
| 383 |
priv->filter_data->filter_all = FALSE; |
| 384 |
change = GTK_FILTER_CHANGE_LESS_STRICT; |
| 385 |
} |
| 386 |
|
| 387 |
priv->filter_data->word = word; |
| 388 |
|
| 389 |
filter = gtk_filter_list_model_get_filter (GTK_FILTER_LIST_MODEL (model)); |
| 390 |
gtk_filter_changed (filter, change); |
| 391 |
|
| 392 |
g_free (old_word); |
| 393 |
} |
| 394 |
|
| 395 |
|
| 396 |
static void |
| 397 |
completion_provider_iface_init (GtkSourceCompletionProviderInterface *iface) |
| 398 |
{ |
| 399 |
iface->get_title = gtk_source_completion_snippets_get_title; |
| 400 |
iface->get_priority = gtk_source_completion_snippets_get_priority; |
| 401 |
iface->populate = gtk_source_completion_snippets_populate; |
| 402 |
iface->activate = gtk_source_completion_snippets_activate; |
| 403 |
iface->display = gtk_source_completion_snippets_display; |
| 404 |
iface->refilter = gtk_source_completion_snippets_refilter; |
| 405 |
} |
| 406 |
|
| 407 |
static void |
| 408 |
gtk_source_completion_snippets_finalize (GObject *object) |
| 409 |
{ |
| 410 |
GtkSourceCompletionSnippets *provider = GTK_SOURCE_COMPLETION_SNIPPETS (object); |
| 411 |
GtkSourceCompletionSnippetsPrivate *priv = gtk_source_completion_snippets_get_instance_private (provider); |
| 412 |
|
| 413 |
g_clear_pointer (&priv->title, g_free); |
| 414 |
g_clear_pointer (&priv->filter_data, filter_data_release); |
| 415 |
|
| 416 |
G_OBJECT_CLASS (gtk_source_completion_snippets_parent_class)->finalize (object); |
| 417 |
} |
| 418 |
|
| 419 |
static void |
| 420 |
gtk_source_completion_snippets_get_property (GObject *object, |
| 421 |
guint prop_id, |
| 422 |
GValue *value, |
| 423 |
GParamSpec *pspec) |
| 424 |
{ |
| 425 |
GtkSourceCompletionSnippets *self = GTK_SOURCE_COMPLETION_SNIPPETS (object); |
| 426 |
GtkSourceCompletionSnippetsPrivate *priv = gtk_source_completion_snippets_get_instance_private (self); |
| 427 |
|
| 428 |
switch (prop_id) |
| 429 |
{ |
| 430 |
case PROP_TITLE: |
| 431 |
g_value_set_string (value, priv->title); |
| 432 |
break; |
| 433 |
|
| 434 |
case PROP_PRIORITY: |
| 435 |
g_value_set_int (value, priv->priority); |
| 436 |
break; |
| 437 |
|
| 438 |
default: |
| 439 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 440 |
break; |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
static void |
| 445 |
gtk_source_completion_snippets_set_property (GObject *object, |
| 446 |
guint prop_id, |
| 447 |
const GValue *value, |
| 448 |
GParamSpec *pspec) |
| 449 |
{ |
| 450 |
GtkSourceCompletionSnippets *self = GTK_SOURCE_COMPLETION_SNIPPETS (object); |
| 451 |
GtkSourceCompletionSnippetsPrivate *priv = gtk_source_completion_snippets_get_instance_private (self); |
| 452 |
|
| 453 |
switch (prop_id) |
| 454 |
{ |
| 455 |
case PROP_TITLE: |
| 456 |
g_free (priv->title); |
| 457 |
priv->title = g_value_dup_string (value); |
| 458 |
|
| 459 |
if (priv->title == NULL) |
| 460 |
{ |
| 461 |
priv->title = g_strdup (_("Snippets")); |
| 462 |
} |
| 463 |
break; |
| 464 |
|
| 465 |
case PROP_PRIORITY: |
| 466 |
priv->priority = g_value_get_int (value); |
| 467 |
break; |
| 468 |
|
| 469 |
default: |
| 470 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 471 |
break; |
| 472 |
} |
| 473 |
} |
| 474 |
|
| 475 |
static void |
| 476 |
gtk_source_completion_snippets_class_init (GtkSourceCompletionSnippetsClass *klass) |
| 477 |
{ |
| 478 |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
| 479 |
|
| 480 |
object_class->finalize = gtk_source_completion_snippets_finalize; |
| 481 |
object_class->get_property = gtk_source_completion_snippets_get_property; |
| 482 |
object_class->set_property = gtk_source_completion_snippets_set_property; |
| 483 |
|
| 484 |
properties[PROP_TITLE] = |
| 485 |
g_param_spec_string ("title", |
| 486 |
"Title", |
| 487 |
"The provider title", |
| 488 |
NULL, |
| 489 |
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); |
| 490 |
|
| 491 |
properties[PROP_PRIORITY] = |
| 492 |
g_param_spec_int ("priority", |
| 493 |
"Priority", |
| 494 |
"Provider priority", |
| 495 |
G_MININT, |
| 496 |
G_MAXINT, |
| 497 |
0, |
| 498 |
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); |
| 499 |
|
| 500 |
g_object_class_install_properties (object_class, N_PROPS, properties); |
| 501 |
} |
| 502 |
|
| 503 |
static void |
| 504 |
gtk_source_completion_snippets_init (GtkSourceCompletionSnippets *self) |
| 505 |
{ |
| 506 |
GtkSourceCompletionSnippetsPrivate *priv = gtk_source_completion_snippets_get_instance_private (self); |
| 507 |
|
| 508 |
priv->filter_data = g_atomic_rc_box_alloc0 (sizeof (FilterData)); |
| 509 |
priv->filter_data->minimum_word_size = 2; |
| 510 |
} |
| 511 |
|
| 512 |
GtkSourceCompletionSnippets * |
| 513 |
gtk_source_completion_snippets_new (void) |
| 514 |
{ |
| 515 |
return g_object_new (GTK_SOURCE_TYPE_COMPLETION_SNIPPETS, NULL); |
| 516 |
} |