[gspell] checker: rename signals



commit b751b64406c34416c257545a894bb0d88a58d702
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Dec 10 15:16:16 2015 +0100

    checker: rename signals
    
    There was a GI warning because the methods add_word_*() are not the same
    as the signals. For the signals, it is not user-friendly to have the
    word_length paramaters, it's more convenient to have the string already
    nul-terminated. But for the methods it's better to have the word_length
    parameters. Passing -1 is not complicated, but allocating a new string
    is not convenient.
    
    The signal names are also better like that, because when the signal is
    emitted, the action is already done. The action cannot be stopped. It's
    just to inform about the event. Otherwise the action would need to be
    executed in the object method handler for the signal.

 gspell/gspell-checker.c            |   40 ++++++++++++++++++------------------
 gspell/gspell-checker.h            |    6 ++--
 gspell/gspell-inline-checker-gtv.c |   22 +++++++++---------
 3 files changed, 34 insertions(+), 34 deletions(-)
---
diff --git a/gspell/gspell-checker.c b/gspell/gspell-checker.c
index 74d46cf..3ade6f4 100644
--- a/gspell/gspell-checker.c
+++ b/gspell/gspell-checker.c
@@ -60,9 +60,9 @@ enum
 
 enum
 {
-       SIGNAL_ADD_WORD_TO_PERSONAL,
-       SIGNAL_ADD_WORD_TO_SESSION,
-       SIGNAL_CLEAR_SESSION,
+       SIGNAL_WORD_ADDED_TO_PERSONAL,
+       SIGNAL_WORD_ADDED_TO_SESSION,
+       SIGNAL_SESSION_CLEARED,
        LAST_SIGNAL
 };
 
@@ -193,51 +193,51 @@ gspell_checker_class_init (GspellCheckerClass *klass)
                                                             G_PARAM_STATIC_STRINGS));
 
        /**
-        * GspellChecker::add-word-to-personal:
+        * GspellChecker::word-added-to-personal:
         * @spell_checker: the #GspellChecker.
         * @word: the added word.
         *
         * Emitted when a word is added to the personal dictionary.
         */
-       signals[SIGNAL_ADD_WORD_TO_PERSONAL] =
-               g_signal_new ("add-word-to-personal",
+       signals[SIGNAL_WORD_ADDED_TO_PERSONAL] =
+               g_signal_new ("word-added-to-personal",
                              G_OBJECT_CLASS_TYPE (object_class),
                              G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (GspellCheckerClass, add_word_to_personal),
+                             G_STRUCT_OFFSET (GspellCheckerClass, word_added_to_personal),
                              NULL, NULL, NULL,
                              G_TYPE_NONE,
                              1,
                              G_TYPE_STRING);
 
        /**
-        * GspellChecker::add-word-to-session:
+        * GspellChecker::word-added-to-session:
         * @spell_checker: the #GspellChecker.
         * @word: the added word.
         *
         * Emitted when a word is added to the session dictionary. The session
         * dictionary is lost when the application exits.
         */
-       signals[SIGNAL_ADD_WORD_TO_SESSION] =
-               g_signal_new ("add-word-to-session",
+       signals[SIGNAL_WORD_ADDED_TO_SESSION] =
+               g_signal_new ("word-added-to-session",
                              G_OBJECT_CLASS_TYPE (object_class),
                              G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (GspellCheckerClass, add_word_to_session),
+                             G_STRUCT_OFFSET (GspellCheckerClass, word_added_to_session),
                              NULL, NULL, NULL,
                              G_TYPE_NONE,
                              1,
                              G_TYPE_STRING);
 
        /**
-        * GspellChecker::clear-session:
+        * GspellChecker::session-cleared:
         * @spell_checker: the #GspellChecker.
         *
         * Emitted when the session dictionary is cleared.
         */
-       signals[SIGNAL_CLEAR_SESSION] =
-               g_signal_new ("clear-session",
+       signals[SIGNAL_SESSION_CLEARED] =
+               g_signal_new ("session-cleared",
                              G_OBJECT_CLASS_TYPE (object_class),
                              G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (GspellCheckerClass, clear_session),
+                             G_STRUCT_OFFSET (GspellCheckerClass, session_cleared),
                              NULL, NULL, NULL,
                              G_TYPE_NONE,
                              0);
@@ -560,7 +560,7 @@ gspell_checker_add_word_to_personal (GspellChecker *checker,
        if (word_length == -1)
        {
                g_signal_emit (G_OBJECT (checker),
-                              signals[SIGNAL_ADD_WORD_TO_PERSONAL], 0,
+                              signals[SIGNAL_WORD_ADDED_TO_PERSONAL], 0,
                               word);
        }
        else
@@ -568,7 +568,7 @@ gspell_checker_add_word_to_personal (GspellChecker *checker,
                gchar *nul_terminated_word = g_strndup (word, word_length);
 
                g_signal_emit (G_OBJECT (checker),
-                              signals[SIGNAL_ADD_WORD_TO_PERSONAL], 0,
+                              signals[SIGNAL_WORD_ADDED_TO_PERSONAL], 0,
                               nul_terminated_word);
 
                g_free (nul_terminated_word);
@@ -604,7 +604,7 @@ gspell_checker_add_word_to_session (GspellChecker *checker,
        if (word_length == -1)
        {
                g_signal_emit (G_OBJECT (checker),
-                              signals[SIGNAL_ADD_WORD_TO_SESSION], 0,
+                              signals[SIGNAL_WORD_ADDED_TO_SESSION], 0,
                               word);
        }
        else
@@ -612,7 +612,7 @@ gspell_checker_add_word_to_session (GspellChecker *checker,
                gchar *nul_terminated_word = g_strndup (word, word_length);
 
                g_signal_emit (G_OBJECT (checker),
-                              signals[SIGNAL_ADD_WORD_TO_SESSION], 0,
+                              signals[SIGNAL_WORD_ADDED_TO_SESSION], 0,
                               nul_terminated_word);
 
                g_free (nul_terminated_word);
@@ -642,7 +642,7 @@ gspell_checker_clear_session (GspellChecker *checker)
 
        init_dictionary (checker);
 
-       g_signal_emit (G_OBJECT (checker), signals[SIGNAL_CLEAR_SESSION], 0);
+       g_signal_emit (G_OBJECT (checker), signals[SIGNAL_SESSION_CLEARED], 0);
 }
 
 /**
diff --git a/gspell/gspell-checker.h b/gspell/gspell-checker.h
index 94a1886..c2720a2 100644
--- a/gspell/gspell-checker.h
+++ b/gspell/gspell-checker.h
@@ -63,13 +63,13 @@ struct _GspellCheckerClass
        GObjectClass parent_class;
 
        /* Signals */
-       void (* add_word_to_personal)   (GspellChecker *checker,
+       void (* word_added_to_personal) (GspellChecker *checker,
                                         const gchar   *word);
 
-       void (* add_word_to_session)    (GspellChecker *checker,
+       void (* word_added_to_session)  (GspellChecker *checker,
                                         const gchar   *word);
 
-       void (* clear_session)          (GspellChecker *checker);
+       void (* session_cleared)        (GspellChecker *checker);
 
        /* Padding for future expansion */
        gpointer padding[12];
diff --git a/gspell/gspell-inline-checker-gtv.c b/gspell/gspell-inline-checker-gtv.c
index 09ccfdf..e2e21da 100644
--- a/gspell/gspell-inline-checker-gtv.c
+++ b/gspell/gspell-inline-checker-gtv.c
@@ -747,16 +747,16 @@ remove_tag_to_word (GspellInlineCheckerGtv *spell,
 }
 
 static void
-add_word_cb (GspellChecker          *checker,
-            const gchar            *word,
-            GspellInlineCheckerGtv *spell)
+word_added_cb (GspellChecker          *checker,
+              const gchar            *word,
+              GspellInlineCheckerGtv *spell)
 {
        remove_tag_to_word (spell, word);
 }
 
 static void
-clear_session_cb (GspellChecker          *checker,
-                 GspellInlineCheckerGtv *spell)
+session_cleared_cb (GspellChecker          *checker,
+                   GspellInlineCheckerGtv *spell)
 {
        recheck_all (spell);
 }
@@ -948,20 +948,20 @@ set_spell_checker (GspellInlineCheckerGtv *spell,
        _gspell_checker_check_language_set (checker);
 
        g_signal_connect_object (spell->spell_checker,
-                                "add_word_to_session",
-                                G_CALLBACK (add_word_cb),
+                                "word-added-to-session",
+                                G_CALLBACK (word_added_cb),
                                 spell,
                                 0);
 
        g_signal_connect_object (spell->spell_checker,
-                                "add_word_to_personal",
-                                G_CALLBACK (add_word_cb),
+                                "word-added-to-personal",
+                                G_CALLBACK (word_added_cb),
                                 spell,
                                 0);
 
        g_signal_connect_object (spell->spell_checker,
-                                "clear_session",
-                                G_CALLBACK (clear_session_cb),
+                                "session-cleared",
+                                G_CALLBACK (session_cleared_cb),
                                 spell,
                                 0);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]