[gedit/wip/spell-cleanup: 1/2] spell: refactor set_inline_checker_from_metadata()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/spell-cleanup: 1/2] spell: refactor set_inline_checker_from_metadata()
- Date: Thu, 7 Jan 2016 18:21:53 +0000 (UTC)
commit 3f9558976415e7ed43951a579cb9295bb55ecb24
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Jan 7 19:09:30 2016 +0100
spell: refactor set_inline_checker_from_metadata()
- Better function name.
- Do not depend on ViewData.
plugins/spell/gedit-spell-plugin.c | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/plugins/spell/gedit-spell-plugin.c b/plugins/spell/gedit-spell-plugin.c
index 4c733dd..ee223b0 100644
--- a/plugins/spell/gedit-spell-plugin.c
+++ b/plugins/spell/gedit-spell-plugin.c
@@ -405,34 +405,37 @@ update_ui (GeditSpellPlugin *plugin)
}
static void
-set_inline_checker_from_metadata (ViewData *data)
+setup_inline_checker_from_metadata (GeditSpellPlugin *plugin,
+ GeditView *view)
{
- GeditSpellPlugin *plugin = data->plugin;
- gboolean active = FALSE;
- gchar *active_str;
+ GeditDocument *doc;
+ gboolean enabled = FALSE;
+ gchar *enabled_str;
GspellInlineCheckerText *inline_checker;
GeditView *active_view;
- active_str = gedit_document_get_metadata (data->doc, GEDIT_METADATA_ATTRIBUTE_SPELL_ENABLED);
- if (active_str != NULL)
+ 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)
{
- active = g_str_equal (active_str, SPELL_ENABLED_STR);
- g_free (active_str);
+ enabled = g_str_equal (enabled_str, SPELL_ENABLED_STR);
+ g_free (enabled_str);
}
- inline_checker = gspell_text_view_get_inline_checker (GTK_TEXT_VIEW (data->view));
- gspell_inline_checker_text_set_enabled (inline_checker, active);
+ inline_checker = gspell_text_view_get_inline_checker (GTK_TEXT_VIEW (view));
+ gspell_inline_checker_text_set_enabled (inline_checker, enabled);
/* In case that the view is the active one we mark the spell action */
active_view = gedit_window_get_active_view (plugin->priv->window);
- if (active_view == data->view)
+ if (active_view == view)
{
GAction *action;
action = g_action_map_lookup_action (G_ACTION_MAP (plugin->priv->window),
"inline-spell-checker");
- g_action_change_state (action, g_variant_new_boolean (active));
+ g_action_change_state (action, g_variant_new_boolean (enabled));
}
}
@@ -458,7 +461,7 @@ on_document_loaded (GeditDocument *doc,
}
}
- set_inline_checker_from_metadata (data);
+ setup_inline_checker_from_metadata (data->plugin, data->view);
}
static void
@@ -513,7 +516,7 @@ view_data_new (GeditSpellPlugin *plugin,
G_CALLBACK (on_document_saved),
data);
- set_inline_checker_from_metadata (data);
+ setup_inline_checker_from_metadata (plugin, view);
return data;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]