1 /* gbp-spell-widget-private.h
2  *
3  * Copyright 2016 Sebastien Lafargue <slafargue@gnome.org>
4  * Copyright 2017-2019 Christian Hergert <chergert@redhat.com>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  * SPDX-License-Identifier: GPL-3.0-or-later
20  */
21 
22 #pragma once
23 
24 #include <gspell/gspell.h>
25 #include <libide-editor.h>
26 
27 #include "gbp-spell-dict.h"
28 #include "gbp-spell-widget.h"
29 #include "gbp-spell-editor-addin.h"
30 #include "gbp-spell-editor-page-addin.h"
31 
32 G_BEGIN_DECLS
33 
34 typedef enum
35 {
36   CHECK_WORD_NONE,
37   CHECK_WORD_CHECKING,
38   CHECK_WORD_IDLE
39 } CheckWordState;
40 
41 struct _GbpSpellWidget
42 {
43   GtkBin                   parent_instance;
44 
45   /* Owned references */
46   IdeEditorPage           *editor;
47   GbpSpellEditorPageAddin *editor_page_addin;
48   DzlSignalGroup          *editor_page_addin_signals;
49   GPtrArray               *words_array;
50   GbpSpellDict            *dict;
51 
52   /* Borrowed references */
53   const GspellLanguage    *language;
54 
55   /* Template references */
56   GtkLabel                *word_label;
57   GtkLabel                *count_label;
58   GtkEntry                *word_entry;
59   GtkListBox              *suggestions_box;
60   GtkBox                  *count_box;
61   GtkWidget               *dict_word_entry;
62   GtkWidget               *dict_add_button;
63   GtkWidget               *dict_words_list;
64   GtkButton               *language_chooser_button;
65   GtkButton               *close_button;
66   GtkWidget               *placeholder;
67 
68   /* GSource identifiers */
69   guint                    check_word_timeout_id;
70   guint                    dict_check_word_timeout_id;
71 
72   guint                    current_word_count;
73   CheckWordState           check_word_state;
74   CheckWordState           dict_check_word_state;
75 
76   guint                    is_checking_word : 1;
77   guint                    is_check_word_invalid : 1;
78   guint                    is_check_word_idle : 1;
79   guint                    is_word_entry_valid : 1;
80 
81   guint                    is_dict_checking_word : 1;
82   guint                    is_dict_check_word_invalid : 1;
83   guint                    is_dict_check_word_idle : 1;
84 
85   guint                    spellchecking_status : 1;
86 };
87 
88 void       _gbp_spell_widget_init_actions   (GbpSpellWidget *self);
89 void       _gbp_spell_widget_update_actions (GbpSpellWidget *self);
90 gboolean   _gbp_spell_widget_move_next_word (GbpSpellWidget *self);
91 GtkWidget *_gbp_spell_widget_get_entry      (GbpSpellWidget *self);
92 void       _gbp_spell_widget_change         (GbpSpellWidget *self,
93                                              gboolean        change_all);
94 
95 void       _gbp_spell_editor_addin_begin    (GbpSpellEditorAddin *self,
96                                              IdeEditorPage       *view);
97 void       _gbp_spell_editor_addin_cancel   (GbpSpellEditorAddin *self,
98                                              IdeEditorPage       *view);
99 
100 G_END_DECLS
101