gedit-spell-plugin.c 16.2 KB
Newer Older
Paolo Borelli's avatar
Paolo Borelli committed
1 2
/*
 * gedit-spell-plugin.c
3 4
 *
 * Copyright (C) 2002-2005 Paolo Maggi
5
 * Copyright (C) 2015-2016 Sébastien Wilmet
Paolo Borelli's avatar
Paolo Borelli committed
6 7 8 9 10
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
11
 *
Paolo Borelli's avatar
Paolo Borelli committed
12 13 14 15 16 17
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Paolo Borelli's avatar
Paolo Borelli committed
19 20 21 22 23 24
 */

#include "gedit-spell-plugin.h"

#include <glib/gi18n.h>
#include <gedit/gedit-debug.h>
25
#include <gedit/gedit-app.h>
26 27
#include <gedit/gedit-window.h>
#include <gedit/gedit-window-activatable.h>
28
#include <gspell/gspell.h>
Paolo Borelli's avatar
Paolo Borelli committed
29

30
#include "gedit-spell-app-activatable.h"
Paolo Borelli's avatar
Paolo Borelli committed
31

32
#ifdef G_OS_WIN32
33
#define GEDIT_METADATA_ATTRIBUTE_SPELL_LANGUAGE "spell-language"
34
#define GEDIT_METADATA_ATTRIBUTE_SPELL_ENABLED  "spell-enabled"
35 36
#else
#define GEDIT_METADATA_ATTRIBUTE_SPELL_LANGUAGE "metadata::gedit-spell-language"
37
#define GEDIT_METADATA_ATTRIBUTE_SPELL_ENABLED  "metadata::gedit-spell-enabled"
38 39
#endif

40 41
#define SPELL_ENABLED_STR "1"

42 43 44
static void gedit_window_activatable_iface_init (GeditWindowActivatableInterface *iface);

struct _GeditSpellPluginPrivate
Paolo Borelli's avatar
Paolo Borelli committed
45
{
46
	GeditWindow *window;
47 48
};

49 50 51 52 53 54
enum
{
	PROP_0,
	PROP_WINDOW
};

55 56 57 58 59 60 61 62
G_DEFINE_DYNAMIC_TYPE_EXTENDED (GeditSpellPlugin,
				gedit_spell_plugin,
				PEAS_TYPE_EXTENSION_BASE,
				0,
				G_IMPLEMENT_INTERFACE_DYNAMIC (GEDIT_TYPE_WINDOW_ACTIVATABLE,
							       gedit_window_activatable_iface_init)
				G_ADD_PRIVATE_DYNAMIC (GeditSpellPlugin))

Paolo Borelli's avatar
Paolo Borelli committed
63 64 65 66
static void
gedit_spell_plugin_init (GeditSpellPlugin *plugin)
{
	gedit_debug_message (DEBUG_PLUGINS, "GeditSpellPlugin initializing");
67

68
	plugin->priv = gedit_spell_plugin_get_instance_private (plugin);
Paolo Borelli's avatar
Paolo Borelli committed
69 70 71
}

static void
72
gedit_spell_plugin_dispose (GObject *object)
Paolo Borelli's avatar
Paolo Borelli committed
73
{
74
	GeditSpellPlugin *plugin = GEDIT_SPELL_PLUGIN (object);
Paolo Borelli's avatar
Paolo Borelli committed
75

76 77
	gedit_debug_message (DEBUG_PLUGINS, "GeditSpellPlugin disposing");

78
	g_clear_object (&plugin->priv->window);
79

80
	G_OBJECT_CLASS (gedit_spell_plugin_parent_class)->dispose (object);
Paolo Borelli's avatar
Paolo Borelli committed
81 82
}

83 84
static void
gedit_spell_plugin_set_property (GObject      *object,
85 86 87
				 guint         prop_id,
				 const GValue *value,
				 GParamSpec   *pspec)
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
{
	GeditSpellPlugin *plugin = GEDIT_SPELL_PLUGIN (object);

	switch (prop_id)
	{
		case PROP_WINDOW:
			plugin->priv->window = GEDIT_WINDOW (g_value_dup_object (value));
			break;

		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
			break;
	}
}

static void
gedit_spell_plugin_get_property (GObject    *object,
105 106 107
				 guint       prop_id,
				 GValue     *value,
				 GParamSpec *pspec)
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
{
	GeditSpellPlugin *plugin = GEDIT_SPELL_PLUGIN (object);

	switch (prop_id)
	{
		case PROP_WINDOW:
			g_value_set_object (value, plugin->priv->window);
			break;

		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
			break;
	}
}

123
static void
124 125 126
language_notify_cb (GspellChecker *checker,
		    GParamSpec    *pspec,
		    GeditDocument *doc)
Paolo Borelli's avatar
Paolo Borelli committed
127
{
128
	const GspellLanguage *lang;
129
	const gchar *language_code;
130

Paolo Borelli's avatar
Paolo Borelli committed
131
	g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
132

133
	lang = gspell_checker_get_language (checker);
Paolo Borelli's avatar
Paolo Borelli committed
134 135
	g_return_if_fail (lang != NULL);

136 137
	language_code = gspell_language_get_code (lang);
	g_return_if_fail (language_code != NULL);
138

139
	gedit_document_set_metadata (doc,
140
				     GEDIT_METADATA_ATTRIBUTE_SPELL_LANGUAGE, language_code,
141
				     NULL);
Paolo Borelli's avatar
Paolo Borelli committed
142 143
}

144
static const GspellLanguage *
145
get_language_from_metadata (GeditDocument *doc)
146
{
147
	const GspellLanguage *lang = NULL;
148
	gchar *language_code = NULL;
149

150
	language_code = gedit_document_get_metadata (doc, GEDIT_METADATA_ATTRIBUTE_SPELL_LANGUAGE);
151

152
	if (language_code != NULL)
153
	{
154 155
		lang = gspell_language_lookup (language_code);
		g_free (language_code);
156 157
	}

158
	return lang;
159 160
}

161
static void
162 163 164
language_dialog_response_cb (GtkDialog *dialog,
			     gint       response_id,
			     gpointer   user_data)
165
{
166 167 168
	if (response_id == GTK_RESPONSE_HELP)
	{
		gedit_app_show_help (GEDIT_APP (g_application_get_default ()),
169
				     GTK_WINDOW (dialog),
170 171 172 173 174
				     NULL,
				     "gedit-spellcheck");
		return;
	}

175
	gtk_widget_destroy (GTK_WIDGET (dialog));
176 177
}

Paolo Borelli's avatar
Paolo Borelli committed
178
static void
179
set_language_cb (GSimpleAction *action,
180 181
		 GVariant      *parameter,
		 gpointer       data)
Paolo Borelli's avatar
Paolo Borelli committed
182
{
183
	GeditSpellPlugin *plugin = GEDIT_SPELL_PLUGIN (data);
184
	GeditSpellPluginPrivate *priv;
Paolo Borelli's avatar
Paolo Borelli committed
185
	GeditDocument *doc;
186 187
	GspellChecker *checker;
	const GspellLanguage *lang;
188
	GtkWidget *dialog;
189
	GtkWindowGroup *window_group;
Paolo Borelli's avatar
Paolo Borelli committed
190 191 192

	gedit_debug (DEBUG_PLUGINS);

193 194 195
	priv = plugin->priv;

	doc = gedit_window_get_active_document (priv->window);
Paolo Borelli's avatar
Paolo Borelli committed
196 197
	g_return_if_fail (doc != NULL);

198
	checker = gspell_text_buffer_get_spell_checker (GTK_TEXT_BUFFER (doc));
199
	g_return_if_fail (checker != NULL);
Paolo Borelli's avatar
Paolo Borelli committed
200

201 202
	lang = gspell_checker_get_language (checker);

203 204 205 206
	dialog = gspell_language_chooser_dialog_new (GTK_WINDOW (priv->window),
						     lang,
						     GTK_DIALOG_MODAL |
						     GTK_DIALOG_DESTROY_WITH_PARENT);
207

208 209 210
	g_object_bind_property (dialog, "language",
				checker, "language",
				G_BINDING_DEFAULT);
211

212
	window_group = gedit_window_get_group (priv->window);
213

214
	gtk_window_group_add_window (window_group, GTK_WINDOW (dialog));
215

216
	gtk_dialog_add_button (GTK_DIALOG (dialog),
217 218 219
			       _("_Help"),
			       GTK_RESPONSE_HELP);

220 221 222 223
	g_signal_connect (dialog,
			  "response",
			  G_CALLBACK (language_dialog_response_cb),
			  NULL);
224

225
	gtk_widget_show (dialog);
Paolo Borelli's avatar
Paolo Borelli committed
226 227 228
}

static void
229 230 231
check_spell_cb (GSimpleAction *action,
		GVariant      *parameter,
		gpointer       data)
Paolo Borelli's avatar
Paolo Borelli committed
232
{
233
	GeditSpellPlugin *plugin = GEDIT_SPELL_PLUGIN (data);
234
	GeditSpellPluginPrivate *priv;
Paolo Borelli's avatar
Paolo Borelli committed
235
	GeditView *view;
236
	GspellNavigator *navigator;
237
	GtkWidget *dialog;
Paolo Borelli's avatar
Paolo Borelli committed
238 239 240

	gedit_debug (DEBUG_PLUGINS);

241 242 243
	priv = plugin->priv;

	view = gedit_window_get_active_view (priv->window);
Paolo Borelli's avatar
Paolo Borelli committed
244 245
	g_return_if_fail (view != NULL);

246
	navigator = gspell_navigator_gtv_new (GTK_TEXT_VIEW (view));
247
	dialog = gspell_checker_dialog_new (GTK_WINDOW (priv->window), navigator);
248
	g_object_unref (navigator);
249

250 251
	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
	gtk_widget_show (dialog);
Paolo Borelli's avatar
Paolo Borelli committed
252 253
}

254
static void
255 256 257
inline_checker_activate_cb (GSimpleAction *action,
			    GVariant      *parameter,
			    gpointer       data)
258
{
259 260
	GeditSpellPlugin *plugin = GEDIT_SPELL_PLUGIN (data);
	GeditSpellPluginPrivate *priv = plugin->priv;
261
	GVariant *state;
262
	gboolean active;
263
	GeditView *view;
264 265 266

	gedit_debug (DEBUG_PLUGINS);

267 268 269
	state = g_action_get_state (G_ACTION (action));
	g_return_if_fail (state != NULL);

270
	active = g_variant_get_boolean (state);
271
	g_variant_unref (state);
272

273 274 275
	/* We must toggle ourself the value. */
	active = !active;
	g_action_change_state (G_ACTION (action), g_variant_new_boolean (active));
276

277
	view = gedit_window_get_active_view (priv->window);
278 279 280
	if (view != NULL)
	{
		GeditDocument *doc;
281

282
		doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
283

284 285 286 287 288 289
		/* Set metadata in the "activate" handler, not in "change-state"
		 * because "change-state" is called every time the state
		 * changes, not specifically when the user has changed the state
		 * herself. For example "change-state" is called to initialize
		 * the sate to the default value specified in the GActionEntry.
		 */
290 291
		gedit_document_set_metadata (doc,
					     GEDIT_METADATA_ATTRIBUTE_SPELL_ENABLED,
292
					     active ? SPELL_ENABLED_STR : NULL,
293 294 295 296 297
					     NULL);
	}
}

static void
298 299 300
inline_checker_change_state_cb (GSimpleAction *action,
				GVariant      *state,
				gpointer       data)
301 302 303 304 305 306 307 308 309
{
	GeditSpellPlugin *plugin = GEDIT_SPELL_PLUGIN (data);
	GeditSpellPluginPrivate *priv = plugin->priv;
	GeditView *view;
	gboolean active;

	gedit_debug (DEBUG_PLUGINS);

	active = g_variant_get_boolean (state);
310

311
	gedit_debug_message (DEBUG_PLUGINS, active ? "Inline Checker activated" : "Inline Checker deactivated");
312 313 314 315

	view = gedit_window_get_active_view (priv->window);
	if (view != NULL)
	{
316 317 318 319 320
		GspellInlineCheckerText *inline_checker;

		inline_checker = gspell_text_view_get_inline_checker (GTK_TEXT_VIEW (view));
		gspell_inline_checker_text_set_enabled (inline_checker, active);

321 322
		g_simple_action_set_state (action, g_variant_new_boolean (active));
	}
323 324
}

Paolo Borelli's avatar
Paolo Borelli committed
325
static void
326
update_ui (GeditSpellPlugin *plugin)
Paolo Borelli's avatar
Paolo Borelli committed
327
{
328
	GeditSpellPluginPrivate *priv;
329 330
	GeditTab *tab;
	GeditView *view = NULL;
331
	gboolean editable_view;
332 333
	GAction *check_spell_action;
	GAction *config_spell_action;
334
	GAction *inline_checker_action;
335

Paolo Borelli's avatar
Paolo Borelli committed
336 337
	gedit_debug (DEBUG_PLUGINS);

338 339
	priv = plugin->priv;

340 341 342 343 344
	tab = gedit_window_get_active_tab (priv->window);
	if (tab != NULL)
	{
		view = gedit_tab_get_view (tab);
	}
Paolo Borelli's avatar
Paolo Borelli committed
345

346 347
	editable_view = (view != NULL) && gtk_text_view_get_editable (GTK_TEXT_VIEW (view));

348
	check_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
349
	                                                 "check-spell");
350
	g_simple_action_set_enabled (G_SIMPLE_ACTION (check_spell_action),
351
				     editable_view);
352 353

	config_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
354
	                                                  "config-spell");
355
	g_simple_action_set_enabled (G_SIMPLE_ACTION (config_spell_action),
356
				     editable_view);
357

358
	inline_checker_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
359
							    "inline-spell-checker");
360
	g_simple_action_set_enabled (G_SIMPLE_ACTION (inline_checker_action),
361
				     editable_view);
362

363 364 365 366 367
	/* Update only on normal state to avoid garbage changes during e.g. file
	 * loading.
	 */
	if (tab != NULL &&
	    gedit_tab_get_state (tab) == GEDIT_TAB_STATE_NORMAL)
368
	{
369 370
		GspellInlineCheckerText *inline_checker;
		gboolean inline_checker_enabled;
371

372 373
		inline_checker = gspell_text_view_get_inline_checker (GTK_TEXT_VIEW (view));
		inline_checker_enabled = gspell_inline_checker_text_get_enabled (inline_checker);
374

375 376
		g_action_change_state (inline_checker_action,
				       g_variant_new_boolean (inline_checker_enabled));
377
	}
Paolo Borelli's avatar
Paolo Borelli committed
378 379
}

380
static void
381 382
setup_inline_checker_from_metadata (GeditSpellPlugin *plugin,
				    GeditView        *view)
383
{
384 385 386
	GeditDocument *doc;
	gboolean enabled = FALSE;
	gchar *enabled_str;
387
	GspellInlineCheckerText *inline_checker;
388
	GeditView *active_view;
389

390 391 392 393
	doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));

	enabled_str = gedit_document_get_metadata (doc, GEDIT_METADATA_ATTRIBUTE_SPELL_ENABLED);
	if (enabled_str != NULL)
394
	{
395 396
		enabled = g_str_equal (enabled_str, SPELL_ENABLED_STR);
		g_free (enabled_str);
397 398
	}

399 400
	inline_checker = gspell_text_view_get_inline_checker (GTK_TEXT_VIEW (view));
	gspell_inline_checker_text_set_enabled (inline_checker, enabled);
401

402 403
	/* In case that the view is the active one we mark the spell action */
	active_view = gedit_window_get_active_view (plugin->priv->window);
404

405
	if (active_view == view)
406
	{
407
		GAction *action;
408

409
		action = g_action_map_lookup_action (G_ACTION_MAP (plugin->priv->window),
410
		                                     "inline-spell-checker");
411
		g_action_change_state (action, g_variant_new_boolean (enabled));
412 413 414 415
	}
}

static void
416 417
on_document_loaded (GeditDocument    *doc,
		    GeditSpellPlugin *plugin)
418
{
419
	GspellChecker *checker;
420 421
	GeditTab *tab;
	GeditView *view;
422

423
	checker = gspell_text_buffer_get_spell_checker (GTK_TEXT_BUFFER (doc));
424

425
	if (checker != NULL)
426
	{
427
		const GspellLanguage *lang;
428 429 430 431 432 433

		lang = get_language_from_metadata (doc);

		if (lang != NULL)
		{
			g_signal_handlers_block_by_func (checker, language_notify_cb, doc);
434
			gspell_checker_set_language (checker, lang);
435 436
			g_signal_handlers_unblock_by_func (checker, language_notify_cb, doc);
		}
437
	}
438

439 440 441
	tab = gedit_tab_get_from_document (doc);
	view = gedit_tab_get_view (tab);
	setup_inline_checker_from_metadata (plugin, view);
442 443
}

444
static void
445
on_document_saved (GeditDocument *doc,
446
		   gpointer       user_data)
447
{
448 449
	GeditTab *tab;
	GeditView *view;
450
	GspellChecker *checker;
451
	const gchar *language_code = NULL;
452 453
	GspellInlineCheckerText *inline_checker;
	gboolean inline_checker_enabled;
454 455

	/* Make sure to save the metadata here too */
456

457
	checker = gspell_text_buffer_get_spell_checker (GTK_TEXT_BUFFER (doc));
458

459
	if (checker != NULL)
460
	{
461
		language_code = gspell_language_get_code (gspell_checker_get_language (checker));
462 463
	}

464 465 466 467
	tab = gedit_tab_get_from_document (doc);
	view = gedit_tab_get_view (tab);

	inline_checker = gspell_text_view_get_inline_checker (GTK_TEXT_VIEW (view));
468
	inline_checker_enabled = gspell_inline_checker_text_get_enabled (inline_checker);
469

470 471
	gedit_document_set_metadata (doc,
	                             GEDIT_METADATA_ATTRIBUTE_SPELL_ENABLED,
472
				     inline_checker_enabled ? SPELL_ENABLED_STR : NULL,
473
	                             GEDIT_METADATA_ATTRIBUTE_SPELL_LANGUAGE,
474
	                             language_code,
475 476 477
	                             NULL);
}

478 479 480 481 482 483 484
static void
init_spell_checking_in_view (GeditSpellPlugin *plugin,
			     GeditView        *view)
{
	GeditDocument *doc;
	const GspellLanguage *lang;
	GspellChecker *checker;
485

486 487 488 489 490 491 492 493 494 495 496 497
	doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
	lang = get_language_from_metadata (doc);
	checker = gspell_checker_new (lang);

	g_signal_connect_object (checker,
				 "notify::language",
				 G_CALLBACK (language_notify_cb),
				 doc,
				 0);

	gspell_text_buffer_set_spell_checker (GTK_TEXT_BUFFER (doc), checker);
	g_object_unref (checker);
498

499 500 501 502 503 504 505 506 507 508 509 510 511
	g_signal_connect_object (doc,
				 "loaded",
				 G_CALLBACK (on_document_loaded),
				 plugin,
				 0);

	g_signal_connect_object (doc,
				 "saved",
				 G_CALLBACK (on_document_saved),
				 plugin,
				 0);

	setup_inline_checker_from_metadata (plugin, view);
512 513
}

514 515 516 517 518 519 520 521
static void
tab_added_cb (GeditWindow      *window,
	      GeditTab         *tab,
	      GeditSpellPlugin *plugin)
{
	init_spell_checking_in_view (plugin, gedit_tab_get_view (tab));
}

Paolo Borelli's avatar
Paolo Borelli committed
522
static void
523
gedit_spell_plugin_activate (GeditWindowActivatable *activatable)
Paolo Borelli's avatar
Paolo Borelli committed
524
{
525
	GeditSpellPlugin *plugin;
526
	GeditSpellPluginPrivate *priv;
527
	GList *views, *l;
Paolo Borelli's avatar
Paolo Borelli committed
528

529 530
	const GActionEntry action_entries[] =
	{
531
		{ "check-spell", check_spell_cb },
532
		{ "config-spell", set_language_cb },
533 534 535 536 537
		{ "inline-spell-checker",
		  inline_checker_activate_cb,
		  NULL,
		  "false",
		  inline_checker_change_state_cb }
538 539
	};

Paolo Borelli's avatar
Paolo Borelli committed
540 541
	gedit_debug (DEBUG_PLUGINS);

542 543
	plugin = GEDIT_SPELL_PLUGIN (activatable);
	priv = plugin->priv;
Paolo Borelli's avatar
Paolo Borelli committed
544

545 546 547 548
	g_action_map_add_action_entries (G_ACTION_MAP (priv->window),
	                                 action_entries,
	                                 G_N_ELEMENTS (action_entries),
	                                 activatable);
Paolo Borelli's avatar
Paolo Borelli committed
549

550
	update_ui (plugin);
551

552
	views = gedit_window_get_views (priv->window);
553
	for (l = views; l != NULL; l = l->next)
554
	{
555
		init_spell_checking_in_view (plugin, GEDIT_VIEW (l->data));
556 557
	}

558 559 560 561
	g_signal_connect (priv->window,
			  "tab-added",
			  G_CALLBACK (tab_added_cb),
			  activatable);
Paolo Borelli's avatar
Paolo Borelli committed
562 563 564
}

static void
565
gedit_spell_plugin_deactivate (GeditWindowActivatable *activatable)
Paolo Borelli's avatar
Paolo Borelli committed
566
{
567
	GeditSpellPluginPrivate *priv;
Paolo Borelli's avatar
Paolo Borelli committed
568 569 570

	gedit_debug (DEBUG_PLUGINS);

571
	priv = GEDIT_SPELL_PLUGIN (activatable)->priv;
Paolo Borelli's avatar
Paolo Borelli committed
572

573 574 575
	g_action_map_remove_action (G_ACTION_MAP (priv->window), "check-spell");
	g_action_map_remove_action (G_ACTION_MAP (priv->window), "config-spell");
	g_action_map_remove_action (G_ACTION_MAP (priv->window), "inline-spell-checker");
576

577
	g_signal_handlers_disconnect_by_func (priv->window, tab_added_cb, activatable);
Paolo Borelli's avatar
Paolo Borelli committed
578 579 580
}

static void
581
gedit_spell_plugin_update_state (GeditWindowActivatable *activatable)
Paolo Borelli's avatar
Paolo Borelli committed
582 583 584
{
	gedit_debug (DEBUG_PLUGINS);

585
	update_ui (GEDIT_SPELL_PLUGIN (activatable));
Paolo Borelli's avatar
Paolo Borelli committed
586 587 588 589 590 591 592
}

static void
gedit_spell_plugin_class_init (GeditSpellPluginClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS (klass);

593
	object_class->dispose = gedit_spell_plugin_dispose;
594 595
	object_class->set_property = gedit_spell_plugin_set_property;
	object_class->get_property = gedit_spell_plugin_get_property;
Paolo Borelli's avatar
Paolo Borelli committed
596

597
	g_object_class_override_property (object_class, PROP_WINDOW, "window");
598 599 600 601 602
}

static void
gedit_spell_plugin_class_finalize (GeditSpellPluginClass *klass)
{
Paolo Borelli's avatar
Paolo Borelli committed
603
}
604 605 606 607 608 609 610 611 612 613 614 615 616

static void
gedit_window_activatable_iface_init (GeditWindowActivatableInterface *iface)
{
	iface->activate = gedit_spell_plugin_activate;
	iface->deactivate = gedit_spell_plugin_deactivate;
	iface->update_state = gedit_spell_plugin_update_state;
}

G_MODULE_EXPORT void
peas_register_types (PeasObjectModule *module)
{
	gedit_spell_plugin_register_type (G_TYPE_MODULE (module));
617
	gedit_spell_app_activatable_register (G_TYPE_MODULE (module));
618 619 620 621 622 623

	peas_object_module_register_extension_type (module,
						    GEDIT_TYPE_WINDOW_ACTIVATABLE,
						    GEDIT_TYPE_SPELL_PLUGIN);
}

Paolo Borelli's avatar
Paolo Borelli committed
624
/* ex:set ts=8 noet: */