[gedit/wip/spell-checking: 2/2] spell-checker: remove the set-language signal, use notify instead
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/spell-checking: 2/2] spell-checker: remove the set-language signal, use notify instead
- Date: Fri, 24 Jul 2015 06:20:31 +0000 (UTC)
commit 1ebae80723702f59e1d51eccf7d8f77b8ecee1d5
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Jul 24 08:09:47 2015 +0200
spell-checker: remove the set-language signal, use notify instead
The "language" property and "set-language" signal were redundant.
plugins/spell/gedit-automatic-spell-checker.c | 10 +++++-----
plugins/spell/gedit-spell-checker.c | 17 +----------------
plugins/spell/gedit-spell-checker.h | 3 ---
plugins/spell/gedit-spell-plugin.c | 17 ++++++++++-------
4 files changed, 16 insertions(+), 31 deletions(-)
---
diff --git a/plugins/spell/gedit-automatic-spell-checker.c b/plugins/spell/gedit-automatic-spell-checker.c
index 6207024..e2c0317 100644
--- a/plugins/spell/gedit-automatic-spell-checker.c
+++ b/plugins/spell/gedit-automatic-spell-checker.c
@@ -714,9 +714,9 @@ clear_session_cb (GeditSpellChecker *checker,
}
static void
-set_language_cb (GeditSpellChecker *checker,
- const GeditSpellCheckerLanguage *lang,
- GeditAutomaticSpellChecker *spell)
+language_notify_cb (GeditSpellChecker *checker,
+ GParamSpec *pspec,
+ GeditAutomaticSpellChecker *spell)
{
gedit_automatic_spell_checker_recheck_all (spell);
}
@@ -910,8 +910,8 @@ set_spell_checker (GeditAutomaticSpellChecker *spell,
0);
g_signal_connect_object (spell->spell_checker,
- "set_language",
- G_CALLBACK (set_language_cb),
+ "notify::language",
+ G_CALLBACK (language_notify_cb),
spell,
0);
}
diff --git a/plugins/spell/gedit-spell-checker.c b/plugins/spell/gedit-spell-checker.c
index eae3429..abe13b6 100644
--- a/plugins/spell/gedit-spell-checker.c
+++ b/plugins/spell/gedit-spell-checker.c
@@ -50,7 +50,6 @@ enum
{
SIGNAL_ADD_WORD_TO_PERSONAL,
SIGNAL_ADD_WORD_TO_SESSION,
- SIGNAL_SET_LANGUAGE,
SIGNAL_CLEAR_SESSION,
LAST_SIGNAL
};
@@ -153,16 +152,6 @@ gedit_spell_checker_class_init (GeditSpellCheckerClass *klass)
1,
G_TYPE_STRING);
- signals[SIGNAL_SET_LANGUAGE] =
- g_signal_new ("set-language",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GeditSpellCheckerClass, set_language),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
-
signals[SIGNAL_CLEAR_SESSION] =
g_signal_new ("clear-session",
G_OBJECT_CLASS_TYPE (object_class),
@@ -292,11 +281,7 @@ gedit_spell_checker_set_language (GeditSpellChecker *spell,
ret = lazy_init (spell, language);
- if (ret)
- {
- g_signal_emit (G_OBJECT (spell), signals[SIGNAL_SET_LANGUAGE], 0, language);
- }
- else
+ if (!ret)
{
g_warning ("Spell checker plugin: cannot use language %s.",
gedit_spell_checker_language_to_string (language));
diff --git a/plugins/spell/gedit-spell-checker.h b/plugins/spell/gedit-spell-checker.h
index fe7b912..572dfe3 100644
--- a/plugins/spell/gedit-spell-checker.h
+++ b/plugins/spell/gedit-spell-checker.h
@@ -47,9 +47,6 @@ struct _GeditSpellCheckerClass
void (*add_word_to_session) (GeditSpellChecker *spell,
const gchar *word);
- void (*set_language) (GeditSpellChecker *spell,
- const GeditSpellCheckerLanguage *lang);
-
void (*clear_session) (GeditSpellChecker *spell);
};
diff --git a/plugins/spell/gedit-spell-plugin.c b/plugins/spell/gedit-spell-plugin.c
index 2b24c3d..5537c05 100644
--- a/plugins/spell/gedit-spell-plugin.c
+++ b/plugins/spell/gedit-spell-plugin.c
@@ -234,13 +234,16 @@ gedit_spell_plugin_get_property (GObject *object,
}
static void
-set_spell_language_cb (GeditSpellChecker *checker,
- const GeditSpellCheckerLanguage *lang,
- GeditDocument *doc)
+language_notify_cb (GeditSpellChecker *checker,
+ GParamSpec *pspec,
+ GeditDocument *doc)
{
+ const GeditSpellCheckerLanguage *lang;
const gchar *key;
g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
+
+ lang = gedit_spell_checker_get_language (checker);
g_return_if_fail (lang != NULL);
key = gedit_spell_checker_language_to_key (lang);
@@ -268,9 +271,9 @@ set_language_from_metadata (GeditSpellChecker *checker,
if (lang != NULL)
{
- g_signal_handlers_block_by_func (checker, set_spell_language_cb, doc);
+ g_signal_handlers_block_by_func (checker, language_notify_cb, doc);
gedit_spell_checker_set_language (checker, lang);
- g_signal_handlers_unblock_by_func (checker, set_spell_language_cb, doc);
+ g_signal_handlers_unblock_by_func (checker, language_notify_cb, doc);
}
}
@@ -298,8 +301,8 @@ get_spell_checker_from_document (GeditDocument *doc)
g_object_unref);
g_signal_connect (checker,
- "set_language",
- G_CALLBACK (set_spell_language_cb),
+ "notify::language",
+ G_CALLBACK (language_notify_cb),
doc);
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]