[gedit: 5/6] spell-checker-dialog: replace 3 signals by a "goto-next" signal



commit 4e75b399d0dea08e97634564be1156805da10774
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Aug 1 16:17:10 2015 +0200

    spell-checker-dialog: replace 3 signals by a "goto-next" signal
    
    The action to do is always the same.

 plugins/spell/gedit-spell-checker-dialog.c |   54 ++++-----------------------
 plugins/spell/gedit-spell-checker-dialog.h |   24 ++++---------
 plugins/spell/gedit-spell-plugin.c         |   30 +--------------
 3 files changed, 17 insertions(+), 91 deletions(-)
---
diff --git a/plugins/spell/gedit-spell-checker-dialog.c b/plugins/spell/gedit-spell-checker-dialog.c
index 97ec3f1..8b3975d 100644
--- a/plugins/spell/gedit-spell-checker-dialog.c
+++ b/plugins/spell/gedit-spell-checker-dialog.c
@@ -49,11 +49,9 @@ enum
 
 enum
 {
-       SIGNAL_IGNORE,
-       SIGNAL_IGNORE_ALL,
        SIGNAL_CHANGE,
        SIGNAL_CHANGE_ALL,
-       SIGNAL_ADD_WORD_TO_PERSONAL,
+       SIGNAL_GOTO_NEXT,
        LAST_SIGNAL
 };
 
@@ -168,26 +166,6 @@ gedit_spell_checker_dialog_class_init (GeditSpellCheckerDialogClass *klass)
                                                              G_PARAM_CONSTRUCT_ONLY |
                                                              G_PARAM_STATIC_STRINGS));
 
-       signals[SIGNAL_IGNORE] =
-               g_signal_new ("ignore",
-                             G_OBJECT_CLASS_TYPE (object_class),
-                             G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (GeditSpellCheckerDialogClass, ignore),
-                             NULL, NULL, NULL,
-                             G_TYPE_NONE,
-                             1,
-                             G_TYPE_STRING);
-
-       signals[SIGNAL_IGNORE_ALL] =
-               g_signal_new ("ignore-all",
-                             G_OBJECT_CLASS_TYPE (object_class),
-                             G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (GeditSpellCheckerDialogClass, ignore_all),
-                             NULL, NULL, NULL,
-                             G_TYPE_NONE,
-                             1,
-                             G_TYPE_STRING);
-
        signals[SIGNAL_CHANGE] =
                g_signal_new ("change",
                              G_OBJECT_CLASS_TYPE (object_class),
@@ -210,15 +188,13 @@ gedit_spell_checker_dialog_class_init (GeditSpellCheckerDialogClass *klass)
                              G_TYPE_STRING,
                              G_TYPE_STRING);
 
-       signals[SIGNAL_ADD_WORD_TO_PERSONAL] =
-               g_signal_new ("add-word-to-personal",
+       signals[SIGNAL_GOTO_NEXT] =
+               g_signal_new ("goto-next",
                              G_OBJECT_CLASS_TYPE (object_class),
                              G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (GeditSpellCheckerDialogClass, add_word_to_personal),
+                             G_STRUCT_OFFSET (GeditSpellCheckerDialogClass, goto_next),
                              NULL, NULL, NULL,
-                             G_TYPE_NONE,
-                             1,
-                             G_TYPE_STRING);
+                             G_TYPE_NONE, 0);
 
        /* Bind class to template */
        gtk_widget_class_set_template_from_resource (widget_class,
@@ -387,45 +363,31 @@ static void
 add_word_button_clicked_handler (GtkButton               *button,
                                 GeditSpellCheckerDialog *dialog)
 {
-       gchar *word;
-
        g_return_if_fail (dialog->misspelled_word != NULL);
 
        gedit_spell_checker_add_word_to_personal (dialog->spell_checker,
                                                  dialog->misspelled_word);
 
-       word = g_strdup (dialog->misspelled_word);
-       g_signal_emit (G_OBJECT (dialog), signals[SIGNAL_ADD_WORD_TO_PERSONAL], 0, word);
-       g_free (word);
+       g_signal_emit (G_OBJECT (dialog), signals[SIGNAL_GOTO_NEXT], 0);
 }
 
 static void
 ignore_button_clicked_handler (GtkButton               *button,
                               GeditSpellCheckerDialog *dialog)
 {
-       gchar *word;
-
-       g_return_if_fail (dialog->misspelled_word != NULL);
-
-       word = g_strdup (dialog->misspelled_word);
-       g_signal_emit (G_OBJECT (dialog), signals[SIGNAL_IGNORE], 0, word);
-       g_free (word);
+       g_signal_emit (G_OBJECT (dialog), signals[SIGNAL_GOTO_NEXT], 0);
 }
 
 static void
 ignore_all_button_clicked_handler (GtkButton               *button,
                                   GeditSpellCheckerDialog *dialog)
 {
-       gchar *word;
-
        g_return_if_fail (dialog->misspelled_word != NULL);
 
        gedit_spell_checker_add_word_to_session (dialog->spell_checker,
                                                 dialog->misspelled_word);
 
-       word = g_strdup (dialog->misspelled_word);
-       g_signal_emit (G_OBJECT (dialog), signals[SIGNAL_IGNORE_ALL], 0, word);
-       g_free (word);
+       g_signal_emit (G_OBJECT (dialog), signals[SIGNAL_GOTO_NEXT], 0);
 }
 
 static void
diff --git a/plugins/spell/gedit-spell-checker-dialog.h b/plugins/spell/gedit-spell-checker-dialog.h
index 6810fe5..f6e5c46 100644
--- a/plugins/spell/gedit-spell-checker-dialog.h
+++ b/plugins/spell/gedit-spell-checker-dialog.h
@@ -41,25 +41,15 @@ struct _GeditSpellCheckerDialogClass
        GtkDialogClass parent_class;
 
        /* Signals */
-       void    (* ignore)                      (GeditSpellCheckerDialog *dialog,
-                                                const gchar             *word);
+       void    (* change)              (GeditSpellCheckerDialog *dialog,
+                                        const gchar             *word,
+                                        const gchar             *change_to);
 
-       void    (* ignore_all)                  (GeditSpellCheckerDialog *dialog,
-                                                const gchar             *word);
+       void    (* change_all)          (GeditSpellCheckerDialog *dialog,
+                                        const gchar             *word,
+                                        const gchar             *change_to);
 
-       void    (* change)                      (GeditSpellCheckerDialog *dialog,
-                                                const gchar             *word,
-                                                const gchar             *change_to);
-
-       void    (* change_all)                  (GeditSpellCheckerDialog *dialog,
-                                                const gchar             *word,
-                                                const gchar             *change_to);
-
-       void    (* add_word_to_personal)        (GeditSpellCheckerDialog *dialog,
-                                                const gchar             *word);
-
-       /* Keybinding signal */
-       void    (* close)                       (GeditSpellCheckerDialog *dialog);
+       void    (* goto_next)           (GeditSpellCheckerDialog *dialog);
 };
 
 GType          gedit_spell_checker_dialog_get_type                     (void) G_GNUC_CONST;
diff --git a/plugins/spell/gedit-spell-plugin.c b/plugins/spell/gedit-spell-plugin.c
index 2a2655f..db82aec 100644
--- a/plugins/spell/gedit-spell-plugin.c
+++ b/plugins/spell/gedit-spell-plugin.c
@@ -669,14 +669,6 @@ goto_next_misspelled_word (GeditSpellCheckerDialog *dialog,
 }
 
 static void
-ignore_cb (GeditSpellCheckerDialog *dialog,
-          const gchar             *word,
-          GeditView               *view)
-{
-       goto_next_misspelled_word (dialog, view);
-}
-
-static void
 change_cb (GeditSpellCheckerDialog *dialog,
           const gchar             *word,
           const gchar             *change_to,
@@ -777,14 +769,6 @@ change_all_cb (GeditSpellCheckerDialog *dialog,
 }
 
 static void
-add_word_cb (GeditSpellCheckerDialog *dialog,
-            const gchar             *word,
-            GeditView               *view)
-{
-       goto_next_misspelled_word (dialog, view);
-}
-
-static void
 language_dialog_response (GtkDialog         *dialog,
                          gint               response_id,
                          GeditSpellChecker *checker)
@@ -927,16 +911,6 @@ spell_cb (GSimpleAction *action,
        gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
 
        g_signal_connect (dialog,
-                         "ignore",
-                         G_CALLBACK (ignore_cb),
-                         view);
-
-       g_signal_connect (dialog,
-                         "ignore-all",
-                         G_CALLBACK (ignore_cb),
-                         view);
-
-       g_signal_connect (dialog,
                          "change",
                          G_CALLBACK (change_cb),
                          view);
@@ -947,8 +921,8 @@ spell_cb (GSimpleAction *action,
                          view);
 
        g_signal_connect (dialog,
-                         "add-word-to-personal",
-                         G_CALLBACK (add_word_cb),
+                         "goto-next",
+                         G_CALLBACK (goto_next_misspelled_word),
                          view);
 
        gedit_spell_checker_dialog_set_misspelled_word (GEDIT_SPELL_CHECKER_DIALOG (dialog), word);



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