Bug Summary

File:plugins/spell/lapiz-spell-checker-dialog.c
Warning:line 416, column 25
Use of memory after it is freed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name lapiz-spell-checker-dialog.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/plugins/spell -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../.. -I /usr/include/libxml2 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/local/include/ctksourceview-4 -I /usr/local/include/libbean-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/enchant-2 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/plugins/spell -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-07-114829-33852-1 -x c lapiz-spell-checker-dialog.c
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * lapiz-spell-checker-dialog.c
4 * This file is part of lapiz
5 *
6 * Copyright (C) 2002 Paolo Maggi
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24/*
25 * Modified by the lapiz Team, 2002. See the AUTHORS file for a
26 * list of people on the lapiz Team.
27 * See the ChangeLog files for a list of changes.
28 */
29
30#ifdef HAVE_CONFIG_H1
31#include <config.h>
32#endif
33
34#include <string.h>
35#include <glib/gi18n.h>
36#include <ctk/ctk.h>
37#include <lapiz/lapiz-utils.h>
38#include "lapiz-spell-checker-dialog.h"
39#include "lapiz-spell-marshal.h"
40
41struct _LapizSpellCheckerDialog
42{
43 CtkWindow parent_instance;
44
45 LapizSpellChecker *spell_checker;
46
47 gchar *misspelled_word;
48
49 CtkWidget *misspelled_word_label;
50 CtkWidget *word_entry;
51 CtkWidget *check_word_button;
52 CtkWidget *ignore_button;
53 CtkWidget *ignore_all_button;
54 CtkWidget *change_button;
55 CtkWidget *change_all_button;
56 CtkWidget *add_word_button;
57 CtkWidget *close_button;
58 CtkWidget *suggestions_list;
59 CtkWidget *language_label;
60
61 CtkTreeModel *suggestions_list_model;
62};
63
64enum
65{
66 IGNORE,
67 IGNORE_ALL,
68 CHANGE,
69 CHANGE_ALL,
70 ADD_WORD_TO_PERSONAL,
71 LAST_SIGNAL
72};
73
74enum
75{
76 COLUMN_SUGGESTIONS,
77 NUM_COLUMNS
78};
79
80static void update_suggestions_list_model (LapizSpellCheckerDialog *dlg,
81 GSList *suggestions);
82
83static void word_entry_changed_handler (CtkEditable *editable,
84 LapizSpellCheckerDialog *dlg);
85static void close_button_clicked_handler (CtkButton *button,
86 LapizSpellCheckerDialog *dlg);
87static void suggestions_list_selection_changed_handler (CtkTreeSelection *selection,
88 LapizSpellCheckerDialog *dlg);
89static void check_word_button_clicked_handler (CtkButton *button,
90 LapizSpellCheckerDialog *dlg);
91static void add_word_button_clicked_handler (CtkButton *button,
92 LapizSpellCheckerDialog *dlg);
93static void ignore_button_clicked_handler (CtkButton *button,
94 LapizSpellCheckerDialog *dlg);
95static void ignore_all_button_clicked_handler (CtkButton *button,
96 LapizSpellCheckerDialog *dlg);
97static void change_button_clicked_handler (CtkButton *button,
98 LapizSpellCheckerDialog *dlg);
99static void change_all_button_clicked_handler (CtkButton *button,
100 LapizSpellCheckerDialog *dlg);
101static void suggestions_list_row_activated_handler (CtkTreeView *view,
102 CtkTreePath *path,
103 CtkTreeViewColumn *column,
104 LapizSpellCheckerDialog *dlg);
105
106
107static guint signals [LAST_SIGNAL] = { 0 };
108
109G_DEFINE_TYPE(LapizSpellCheckerDialog, lapiz_spell_checker_dialog, CTK_TYPE_WINDOW)static void lapiz_spell_checker_dialog_init (LapizSpellCheckerDialog
*self); static void lapiz_spell_checker_dialog_class_init (LapizSpellCheckerDialogClass
*klass); static GType lapiz_spell_checker_dialog_get_type_once
(void); static gpointer lapiz_spell_checker_dialog_parent_class
= ((void*)0); static gint LapizSpellCheckerDialog_private_offset
; static void lapiz_spell_checker_dialog_class_intern_init (gpointer
klass) { lapiz_spell_checker_dialog_parent_class = g_type_class_peek_parent
(klass); if (LapizSpellCheckerDialog_private_offset != 0) g_type_class_adjust_private_offset
(klass, &LapizSpellCheckerDialog_private_offset); lapiz_spell_checker_dialog_class_init
((LapizSpellCheckerDialogClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer lapiz_spell_checker_dialog_get_instance_private
(LapizSpellCheckerDialog *self) { return (((gpointer) ((guint8
*) (self) + (glong) (LapizSpellCheckerDialog_private_offset))
)); } GType lapiz_spell_checker_dialog_get_type (void) { static
GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); (void) (0 ? (gpointer) * (
&static_g_define_type_id) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= lapiz_spell_checker_dialog_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); 0 ? (void
) (*(&static_g_define_type_id) = (g_define_type_id)) : (void
) 0; g_once_init_leave_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType lapiz_spell_checker_dialog_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ctk_window_get_type ()), g_intern_static_string ("LapizSpellCheckerDialog"
), sizeof (LapizSpellCheckerDialogClass), (GClassInitFunc)(void
(*)(void)) lapiz_spell_checker_dialog_class_intern_init, sizeof
(LapizSpellCheckerDialog), (GInstanceInitFunc)(void (*)(void
)) lapiz_spell_checker_dialog_init, (GTypeFlags) 0); { {{};} }
return g_define_type_id; }
110
111static void
112lapiz_spell_checker_dialog_dispose (GObject *object)
113{
114 LapizSpellCheckerDialog *dlg = LAPIZ_SPELL_CHECKER_DIALOG (object)((((LapizSpellCheckerDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((object)), ((lapiz_spell_checker_dialog_get_type
()))))))
;
115
116 if (dlg->spell_checker != NULL((void*)0))
117 {
118 g_object_unref (dlg->spell_checker);
119 dlg->spell_checker = NULL((void*)0);
120 }
121
122 if (dlg->misspelled_word != NULL((void*)0))
123 {
124 g_free (dlg->misspelled_word);
125 dlg->misspelled_word = NULL((void*)0);
126 }
127
128 G_OBJECT_CLASS (lapiz_spell_checker_dialog_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((lapiz_spell_checker_dialog_parent_class)), (((GType) ((20
) << (2))))))))
->dispose (object);
129}
130
131static void
132lapiz_spell_checker_dialog_class_init (LapizSpellCheckerDialogClass * klass)
133{
134 GObjectClass *object_class;
135
136 object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
137
138 object_class->dispose = lapiz_spell_checker_dialog_dispose;
139
140 signals[IGNORE] =
141 g_signal_new ("ignore",
142 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
143 G_SIGNAL_RUN_LAST,
144 G_STRUCT_OFFSET (LapizSpellCheckerDialogClass, ignore)((glong) __builtin_offsetof(LapizSpellCheckerDialogClass, ignore
))
,
145 NULL((void*)0), NULL((void*)0),
146 lapiz_marshal_VOID__STRINGg_cclosure_marshal_VOID__STRING,
147 G_TYPE_NONE((GType) ((1) << (2))),
148 1,
149 G_TYPE_STRING((GType) ((16) << (2))));
150
151 signals[IGNORE_ALL] =
152 g_signal_new ("ignore_all",
153 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
154 G_SIGNAL_RUN_LAST,
155 G_STRUCT_OFFSET (LapizSpellCheckerDialogClass, ignore_all)((glong) __builtin_offsetof(LapizSpellCheckerDialogClass, ignore_all
))
,
156 NULL((void*)0), NULL((void*)0),
157 lapiz_marshal_VOID__STRINGg_cclosure_marshal_VOID__STRING,
158 G_TYPE_NONE((GType) ((1) << (2))),
159 1,
160 G_TYPE_STRING((GType) ((16) << (2))));
161
162 signals[CHANGE] =
163 g_signal_new ("change",
164 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
165 G_SIGNAL_RUN_LAST,
166 G_STRUCT_OFFSET (LapizSpellCheckerDialogClass, change)((glong) __builtin_offsetof(LapizSpellCheckerDialogClass, change
))
,
167 NULL((void*)0), NULL((void*)0),
168 lapiz_marshal_VOID__STRING_STRING,
169 G_TYPE_NONE((GType) ((1) << (2))),
170 2,
171 G_TYPE_STRING((GType) ((16) << (2))),
172 G_TYPE_STRING((GType) ((16) << (2))));
173
174 signals[CHANGE_ALL] =
175 g_signal_new ("change_all",
176 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
177 G_SIGNAL_RUN_LAST,
178 G_STRUCT_OFFSET (LapizSpellCheckerDialogClass, change_all)((glong) __builtin_offsetof(LapizSpellCheckerDialogClass, change_all
))
,
179 NULL((void*)0), NULL((void*)0),
180 lapiz_marshal_VOID__STRING_STRING,
181 G_TYPE_NONE((GType) ((1) << (2))),
182 2,
183 G_TYPE_STRING((GType) ((16) << (2))),
184 G_TYPE_STRING((GType) ((16) << (2))));
185
186 signals[ADD_WORD_TO_PERSONAL] =
187 g_signal_new ("add_word_to_personal",
188 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
189 G_SIGNAL_RUN_LAST,
190 G_STRUCT_OFFSET (LapizSpellCheckerDialogClass, add_word_to_personal)((glong) __builtin_offsetof(LapizSpellCheckerDialogClass, add_word_to_personal
))
,
191 NULL((void*)0), NULL((void*)0),
192 lapiz_marshal_VOID__STRINGg_cclosure_marshal_VOID__STRING,
193 G_TYPE_NONE((GType) ((1) << (2))),
194 1,
195 G_TYPE_STRING((GType) ((16) << (2))));
196}
197
198static void
199create_dialog (LapizSpellCheckerDialog *dlg,
200 const gchar *data_dir)
201{
202 CtkWidget *error_widget;
203 CtkWidget *content;
204 CtkTreeViewColumn *column;
205 CtkCellRenderer *cell;
206 CtkTreeSelection *selection;
207 gchar *root_objects[] = {
208 "content",
209 "check_word_image",
210 "add_word_image",
211 "ignore_image",
212 "change_image",
213 "ignore_all_image",
214 "change_all_image",
215 NULL((void*)0)
216 };
217 gboolean ret;
218 gchar *ui_file;
219
220 g_return_if_fail (dlg != NULL)do { if ((dlg != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dlg != NULL"); return
; } } while (0)
;
221
222 dlg->spell_checker = NULL((void*)0);
223 dlg->misspelled_word = NULL((void*)0);
224
225 ui_file = g_build_filename (data_dir, "spell-checker.ui", NULL((void*)0));
226 ret = lapiz_utils_get_ui_objects (ui_file,
227 root_objects,
228 &error_widget,
229
230 "content", &content,
231 "misspelled_word_label", &dlg->misspelled_word_label,
232 "word_entry", &dlg->word_entry,
233 "check_word_button", &dlg->check_word_button,
234 "ignore_button", &dlg->ignore_button,
235 "ignore_all_button", &dlg->ignore_all_button,
236 "change_button", &dlg->change_button,
237 "change_all_button", &dlg->change_all_button,
238 "add_word_button", &dlg->add_word_button,
239 "close_button", &dlg->close_button,
240 "suggestions_list", &dlg->suggestions_list,
241 "language_label", &dlg->language_label,
242 NULL((void*)0));
243 g_free (ui_file);
244
245 if (!ret)
246 {
247 ctk_widget_show (error_widget);
248
249 ctk_box_pack_start (CTK_BOX (ctk_dialog_get_content_area (CTK_DIALOG (dlg)))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dlg)), ((ctk_dialog_get_type ())))))))))
, ((ctk_box_get_type ()))))))
,
250 error_widget, TRUE(!(0)), TRUE(!(0)), 0);
251
252 return;
253 }
254
255 ctk_label_set_label (CTK_LABEL (dlg->misspelled_word_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->misspelled_word_label)), ((ctk_label_get_type ()
))))))
, "");
256 ctk_widget_set_sensitive (dlg->word_entry, FALSE(0));
257 ctk_widget_set_sensitive (dlg->check_word_button, FALSE(0));
258 ctk_widget_set_sensitive (dlg->ignore_button, FALSE(0));
259 ctk_widget_set_sensitive (dlg->ignore_all_button, FALSE(0));
260 ctk_widget_set_sensitive (dlg->change_button, FALSE(0));
261 ctk_widget_set_sensitive (dlg->change_all_button, FALSE(0));
262 ctk_widget_set_sensitive (dlg->add_word_button, FALSE(0));
263
264 ctk_label_set_label (CTK_LABEL (dlg->language_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->language_label)), ((ctk_label_get_type ()))))))
, "");
265
266 ctk_container_add (CTK_CONTAINER (dlg)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((ctk_container_get_type ()))))))
, content);
267 g_object_unref (content);
268
269 ctk_window_set_resizable (CTK_WINDOW (dlg)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((ctk_window_get_type ()))))))
, FALSE(0));
270 ctk_window_set_title (CTK_WINDOW (dlg)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((ctk_window_get_type ()))))))
, _("Check Spelling")gettext ("Check Spelling"));
271
272 /* Suggestion list */
273 dlg->suggestions_list_model = CTK_TREE_MODEL (((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_list_store_new (NUM_COLUMNS, ((GType) ((16) <<
(2)))))), ((ctk_tree_model_get_type ()))))))
274 ctk_list_store_new (NUM_COLUMNS, G_TYPE_STRING))((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_list_store_new (NUM_COLUMNS, ((GType) ((16) <<
(2)))))), ((ctk_tree_model_get_type ()))))))
;
275
276 ctk_tree_view_set_model (CTK_TREE_VIEW (dlg->suggestions_list)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->suggestions_list)), ((ctk_tree_view_get_type ())
)))))
,
277 dlg->suggestions_list_model);
278
279 /* Add the suggestions column */
280 cell = ctk_cell_renderer_text_new ();
281 column = ctk_tree_view_column_new_with_attributes (_("Suggestions")gettext ("Suggestions"), cell,
282 "text", COLUMN_SUGGESTIONS, NULL((void*)0));
283
284 ctk_tree_view_append_column (CTK_TREE_VIEW (dlg->suggestions_list)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->suggestions_list)), ((ctk_tree_view_get_type ())
)))))
, column);
285
286 ctk_tree_view_set_search_column (CTK_TREE_VIEW (dlg->suggestions_list)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->suggestions_list)), ((ctk_tree_view_get_type ())
)))))
,
287 COLUMN_SUGGESTIONS);
288
289 selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (dlg->suggestions_list)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->suggestions_list)), ((ctk_tree_view_get_type ())
)))))
);
290
291 ctk_tree_selection_set_mode (selection, CTK_SELECTION_SINGLE);
292
293 /* Set default button */
294 ctk_widget_set_can_default (dlg->change_button, TRUE(!(0)));
295 ctk_widget_grab_default (dlg->change_button);
296
297 ctk_entry_set_activates_default (CTK_ENTRY (dlg->word_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->word_entry)), ((ctk_entry_get_type ()))))))
, TRUE(!(0)));
298
299 ctk_button_set_image (CTK_BUTTON (dlg->close_button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->close_button)), ((ctk_button_get_type ()))))))
,
300 ctk_image_new_from_icon_name ("window-close", CTK_ICON_SIZE_BUTTON));
301
302 /* Connect signals */
303 g_signal_connect (dlg->word_entry, "changed",g_signal_connect_data ((dlg->word_entry), ("changed"), (((
GCallback) (word_entry_changed_handler))), (dlg), ((void*)0),
(GConnectFlags) 0)
304 G_CALLBACK (word_entry_changed_handler), dlg)g_signal_connect_data ((dlg->word_entry), ("changed"), (((
GCallback) (word_entry_changed_handler))), (dlg), ((void*)0),
(GConnectFlags) 0)
;
305 g_signal_connect (dlg->close_button, "clicked",g_signal_connect_data ((dlg->close_button), ("clicked"), (
((GCallback) (close_button_clicked_handler))), (dlg), ((void*
)0), (GConnectFlags) 0)
306 G_CALLBACK (close_button_clicked_handler), dlg)g_signal_connect_data ((dlg->close_button), ("clicked"), (
((GCallback) (close_button_clicked_handler))), (dlg), ((void*
)0), (GConnectFlags) 0)
;
307 g_signal_connect (selection, "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback
) (suggestions_list_selection_changed_handler))), (dlg), ((void
*)0), (GConnectFlags) 0)
308 G_CALLBACK (suggestions_list_selection_changed_handler),g_signal_connect_data ((selection), ("changed"), (((GCallback
) (suggestions_list_selection_changed_handler))), (dlg), ((void
*)0), (GConnectFlags) 0)
309 dlg)g_signal_connect_data ((selection), ("changed"), (((GCallback
) (suggestions_list_selection_changed_handler))), (dlg), ((void
*)0), (GConnectFlags) 0)
;
310 g_signal_connect (dlg->check_word_button, "clicked",g_signal_connect_data ((dlg->check_word_button), ("clicked"
), (((GCallback) (check_word_button_clicked_handler))), (dlg)
, ((void*)0), (GConnectFlags) 0)
311 G_CALLBACK (check_word_button_clicked_handler), dlg)g_signal_connect_data ((dlg->check_word_button), ("clicked"
), (((GCallback) (check_word_button_clicked_handler))), (dlg)
, ((void*)0), (GConnectFlags) 0)
;
312 g_signal_connect (dlg->add_word_button, "clicked",g_signal_connect_data ((dlg->add_word_button), ("clicked")
, (((GCallback) (add_word_button_clicked_handler))), (dlg), (
(void*)0), (GConnectFlags) 0)
313 G_CALLBACK (add_word_button_clicked_handler), dlg)g_signal_connect_data ((dlg->add_word_button), ("clicked")
, (((GCallback) (add_word_button_clicked_handler))), (dlg), (
(void*)0), (GConnectFlags) 0)
;
314 g_signal_connect (dlg->ignore_button, "clicked",g_signal_connect_data ((dlg->ignore_button), ("clicked"), (
((GCallback) (ignore_button_clicked_handler))), (dlg), ((void
*)0), (GConnectFlags) 0)
315 G_CALLBACK (ignore_button_clicked_handler), dlg)g_signal_connect_data ((dlg->ignore_button), ("clicked"), (
((GCallback) (ignore_button_clicked_handler))), (dlg), ((void
*)0), (GConnectFlags) 0)
;
316 g_signal_connect (dlg->ignore_all_button, "clicked",g_signal_connect_data ((dlg->ignore_all_button), ("clicked"
), (((GCallback) (ignore_all_button_clicked_handler))), (dlg)
, ((void*)0), (GConnectFlags) 0)
317 G_CALLBACK (ignore_all_button_clicked_handler), dlg)g_signal_connect_data ((dlg->ignore_all_button), ("clicked"
), (((GCallback) (ignore_all_button_clicked_handler))), (dlg)
, ((void*)0), (GConnectFlags) 0)
;
318 g_signal_connect (dlg->change_button, "clicked",g_signal_connect_data ((dlg->change_button), ("clicked"), (
((GCallback) (change_button_clicked_handler))), (dlg), ((void
*)0), (GConnectFlags) 0)
319 G_CALLBACK (change_button_clicked_handler), dlg)g_signal_connect_data ((dlg->change_button), ("clicked"), (
((GCallback) (change_button_clicked_handler))), (dlg), ((void
*)0), (GConnectFlags) 0)
;
320 g_signal_connect (dlg->change_all_button, "clicked",g_signal_connect_data ((dlg->change_all_button), ("clicked"
), (((GCallback) (change_all_button_clicked_handler))), (dlg)
, ((void*)0), (GConnectFlags) 0)
321 G_CALLBACK (change_all_button_clicked_handler), dlg)g_signal_connect_data ((dlg->change_all_button), ("clicked"
), (((GCallback) (change_all_button_clicked_handler))), (dlg)
, ((void*)0), (GConnectFlags) 0)
;
322 g_signal_connect (dlg->suggestions_list, "row-activated",g_signal_connect_data ((dlg->suggestions_list), ("row-activated"
), (((GCallback) (suggestions_list_row_activated_handler))), (
dlg), ((void*)0), (GConnectFlags) 0)
323 G_CALLBACK (suggestions_list_row_activated_handler), dlg)g_signal_connect_data ((dlg->suggestions_list), ("row-activated"
), (((GCallback) (suggestions_list_row_activated_handler))), (
dlg), ((void*)0), (GConnectFlags) 0)
;
324}
325
326static void
327lapiz_spell_checker_dialog_init (LapizSpellCheckerDialog *dlg G_GNUC_UNUSED__attribute__ ((__unused__)))
328{
329}
330
331CtkWidget *
332lapiz_spell_checker_dialog_new (const gchar *data_dir)
333{
334 LapizSpellCheckerDialog *dlg;
335
336 dlg = LAPIZ_SPELL_CHECKER_DIALOG (((((LapizSpellCheckerDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((g_object_new ((lapiz_spell_checker_dialog_get_type
()), ((void*)0)))), ((lapiz_spell_checker_dialog_get_type ()
))))))
337 g_object_new (LAPIZ_TYPE_SPELL_CHECKER_DIALOG, NULL))((((LapizSpellCheckerDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((g_object_new ((lapiz_spell_checker_dialog_get_type
()), ((void*)0)))), ((lapiz_spell_checker_dialog_get_type ()
))))))
;
338
339 g_return_val_if_fail (dlg != NULL, NULL)do { if ((dlg != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dlg != NULL"); return
(((void*)0)); } } while (0)
;
340
341 create_dialog (dlg, data_dir);
342
343 return CTK_WIDGET (dlg)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((ctk_widget_get_type ()))))))
;
344}
345
346CtkWidget *
347lapiz_spell_checker_dialog_new_from_spell_checker (LapizSpellChecker *spell,
348 const gchar *data_dir)
349{
350 LapizSpellCheckerDialog *dlg;
351
352 g_return_val_if_fail (spell != NULL, NULL)do { if ((spell != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "spell != NULL");
return (((void*)0)); } } while (0)
;
1
Assuming 'spell' is not equal to null
2
Taking true branch
3
Loop condition is false. Exiting loop
353
354 dlg = LAPIZ_SPELL_CHECKER_DIALOG (((((LapizSpellCheckerDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((g_object_new ((lapiz_spell_checker_dialog_get_type
()), ((void*)0)))), ((lapiz_spell_checker_dialog_get_type ()
))))))
355 g_object_new (LAPIZ_TYPE_SPELL_CHECKER_DIALOG, NULL))((((LapizSpellCheckerDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((g_object_new ((lapiz_spell_checker_dialog_get_type
()), ((void*)0)))), ((lapiz_spell_checker_dialog_get_type ()
))))))
;
356
357 g_return_val_if_fail (dlg != NULL, NULL)do { if ((dlg != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dlg != NULL"); return
(((void*)0)); } } while (0)
;
4
Assuming 'dlg' is not equal to null
5
Taking true branch
6
Loop condition is false. Exiting loop
358
359 create_dialog (dlg, data_dir);
360
361 lapiz_spell_checker_dialog_set_spell_checker (dlg, spell);
7
Calling 'lapiz_spell_checker_dialog_set_spell_checker'
362
363 return CTK_WIDGET (dlg)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((ctk_widget_get_type ()))))))
;
364}
365
366void
367lapiz_spell_checker_dialog_set_spell_checker (LapizSpellCheckerDialog *dlg, LapizSpellChecker *spell)
368{
369 const LapizSpellCheckerLanguage* language;
370 const gchar *lang;
371 gchar *tmp;
372
373 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
8
Taking false branch
9
Assuming field 'g_class' is null
10
Assuming the condition is true
11
Taking true branch
12
Loop condition is false. Exiting loop
374 g_return_if_fail (spell != NULL)do { if ((spell != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "spell != NULL");
return; } } while (0)
;
13
Taking true branch
14
Loop condition is false. Exiting loop
375
376 if (dlg->spell_checker != NULL((void*)0))
15
Assuming field 'spell_checker' is equal to NULL
16
Taking false branch
377 g_object_unref (dlg->spell_checker);
378
379 dlg->spell_checker = spell;
380 g_object_ref (dlg->spell_checker)((__typeof__ (dlg->spell_checker)) (g_object_ref) (dlg->
spell_checker))
;
381
382 language = lapiz_spell_checker_get_language (dlg->spell_checker);
383
384 lang = lapiz_spell_checker_language_to_string (language);
385 tmp = g_strdup_printf("<b>%s</b>", lang);
386
387 ctk_label_set_label (CTK_LABEL (dlg->language_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->language_label)), ((ctk_label_get_type ()))))))
, tmp);
388 g_free (tmp);
389
390 if (dlg->misspelled_word != NULL((void*)0))
17
Assuming field 'misspelled_word' is not equal to NULL
18
Taking true branch
391 lapiz_spell_checker_dialog_set_misspelled_word (dlg, dlg->misspelled_word, -1);
19
Calling 'lapiz_spell_checker_dialog_set_misspelled_word'
392 else
393 ctk_list_store_clear (CTK_LIST_STORE (dlg->suggestions_list_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->suggestions_list_model)), ((ctk_list_store_get_type
()))))))
);
394
395 /* TODO: reset all widgets */
396}
397
398void
399lapiz_spell_checker_dialog_set_misspelled_word (LapizSpellCheckerDialog *dlg,
400 const gchar *word,
401 gint len G_GNUC_UNUSED__attribute__ ((__unused__)))
402{
403 gchar *tmp;
404 GSList *sug;
405
406 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
20
Taking false branch
21
Assuming the condition is true
22
Taking true branch
23
Loop condition is false. Exiting loop
407 g_return_if_fail (word != NULL)do { if ((word != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "word != NULL"); return
; } } while (0)
;
24
Taking true branch
25
Loop condition is false. Exiting loop
408
409 g_return_if_fail (dlg->spell_checker != NULL)do { if ((dlg->spell_checker != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dlg->spell_checker != NULL"
); return; } } while (0)
;
26
Taking true branch
27
Loop condition is false. Exiting loop
410 g_return_if_fail (!lapiz_spell_checker_check_word (dlg->spell_checker, word, -1))do { if ((!lapiz_spell_checker_check_word (dlg->spell_checker
, word, -1))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "!lapiz_spell_checker_check_word (dlg->spell_checker, word, -1)"
); return; } } while (0)
;
28
Assuming the condition is true
29
Taking true branch
30
Loop condition is false. Exiting loop
411
412 /* build_suggestions_list */
413 if (dlg->misspelled_word
30.1
Field 'misspelled_word' is not equal to NULL
!= NULL((void*)0))
31
Taking true branch
414 g_free (dlg->misspelled_word);
32
Memory is released
415
416 dlg->misspelled_word = g_strdup (word)g_strdup_inline (word);
33
Use of memory after it is freed
417
418 tmp = g_strdup_printf("<b>%s</b>", word);
419 ctk_label_set_label (CTK_LABEL (dlg->misspelled_word_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->misspelled_word_label)), ((ctk_label_get_type ()
))))))
, tmp);
420 g_free (tmp);
421
422 sug = lapiz_spell_checker_get_suggestions (dlg->spell_checker,
423 dlg->misspelled_word,
424 -1);
425
426 update_suggestions_list_model (dlg, sug);
427
428 /* free the suggestion list */
429 g_slist_foreach (sug, (GFunc)g_free, NULL((void*)0));
430 g_slist_free (sug);
431
432 ctk_widget_set_sensitive (dlg->ignore_button, TRUE(!(0)));
433 ctk_widget_set_sensitive (dlg->ignore_all_button, TRUE(!(0)));
434 ctk_widget_set_sensitive (dlg->add_word_button, TRUE(!(0)));
435}
436
437static void
438update_suggestions_list_model (LapizSpellCheckerDialog *dlg, GSList *suggestions)
439{
440 CtkListStore *store;
441 CtkTreeIter iter;
442 CtkTreeSelection *sel;
443
444 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
445 g_return_if_fail (CTK_IS_LIST_STORE (dlg->suggestions_list_model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg->suggestions_list_model)); GType __t = ((ctk_list_store_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "CTK_IS_LIST_STORE (dlg->suggestions_list_model)"
); return; } } while (0)
;
446
447 store = CTK_LIST_STORE (dlg->suggestions_list_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->suggestions_list_model)), ((ctk_list_store_get_type
()))))))
;
448 ctk_list_store_clear (store);
449
450 ctk_widget_set_sensitive (dlg->word_entry, TRUE(!(0)));
451
452 if (suggestions == NULL((void*)0))
453 {
454 ctk_list_store_append (store, &iter);
455 ctk_list_store_set (store, &iter,
456 /* Translators: Displayed in the "Check Spelling" dialog if there are no suggestions
457 * for the current misspelled word */
458 COLUMN_SUGGESTIONS, _("(no suggested words)")gettext ("(no suggested words)"),
459 -1);
460
461 ctk_entry_set_text (CTK_ENTRY (dlg->word_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->word_entry)), ((ctk_entry_get_type ()))))))
, "");
462
463 ctk_widget_set_sensitive (dlg->suggestions_list, FALSE(0));
464
465 return;
466 }
467
468 ctk_widget_set_sensitive (dlg->suggestions_list, TRUE(!(0)));
469
470 ctk_entry_set_text (CTK_ENTRY (dlg->word_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->word_entry)), ((ctk_entry_get_type ()))))))
, (gchar*)suggestions->data);
471
472 while (suggestions != NULL((void*)0))
473 {
474 ctk_list_store_append (store, &iter);
475 ctk_list_store_set (store, &iter,
476 COLUMN_SUGGESTIONS, (gchar*)suggestions->data,
477 -1);
478
479 suggestions = g_slist_next (suggestions)((suggestions) ? (((GSList *)(suggestions))->next) : ((void
*)0))
;
480 }
481
482 sel = ctk_tree_view_get_selection (CTK_TREE_VIEW (dlg->suggestions_list)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->suggestions_list)), ((ctk_tree_view_get_type ())
)))))
);
483 ctk_tree_model_get_iter_first (dlg->suggestions_list_model, &iter);
484 ctk_tree_selection_select_iter (sel, &iter);
485}
486
487static void
488word_entry_changed_handler (CtkEditable *editable G_GNUC_UNUSED__attribute__ ((__unused__)),
489 LapizSpellCheckerDialog *dlg)
490{
491 const gchar *text;
492
493 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
494
495 text = ctk_entry_get_text (CTK_ENTRY (dlg->word_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->word_entry)), ((ctk_entry_get_type ()))))))
);
496
497 if (g_utf8_strlen (text, -1) > 0)
498 {
499 ctk_widget_set_sensitive (dlg->check_word_button, TRUE(!(0)));
500 ctk_widget_set_sensitive (dlg->change_button, TRUE(!(0)));
501 ctk_widget_set_sensitive (dlg->change_all_button, TRUE(!(0)));
502 }
503 else
504 {
505 ctk_widget_set_sensitive (dlg->check_word_button, FALSE(0));
506 ctk_widget_set_sensitive (dlg->change_button, FALSE(0));
507 ctk_widget_set_sensitive (dlg->change_all_button, FALSE(0));
508 }
509}
510
511static void
512close_button_clicked_handler (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__)),
513 LapizSpellCheckerDialog *dlg)
514{
515 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
516
517 ctk_widget_destroy (CTK_WIDGET (dlg)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((ctk_widget_get_type ()))))))
);
518}
519
520static void
521suggestions_list_selection_changed_handler (CtkTreeSelection *selection,
522 LapizSpellCheckerDialog *dlg)
523{
524 CtkTreeIter iter;
525 GValue value = {0, };
526 const gchar *text;
527
528 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
529
530 if (! ctk_tree_selection_get_selected (selection, NULL((void*)0), &iter))
531 return;
532
533 ctk_tree_model_get_value (dlg->suggestions_list_model, &iter,
534 COLUMN_SUGGESTIONS,
535 &value);
536
537 text = g_value_get_string (&value);
538
539 ctk_entry_set_text (CTK_ENTRY (dlg->word_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->word_entry)), ((ctk_entry_get_type ()))))))
, text);
540
541 g_value_unset (&value);
542}
543
544static void
545check_word_button_clicked_handler (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__)),
546 LapizSpellCheckerDialog *dlg)
547{
548 const gchar *word;
549 gssize len;
550
551 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
552
553 word = ctk_entry_get_text (CTK_ENTRY (dlg->word_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->word_entry)), ((ctk_entry_get_type ()))))))
);
554 len = strlen (word);
555 g_return_if_fail (len > 0)do { if ((len > 0)) { } else { g_return_if_fail_warning ((
(gchar*) 0), ((const char*) (__func__)), "len > 0"); return
; } } while (0)
;
556
557 if (lapiz_spell_checker_check_word (dlg->spell_checker, word, len))
558 {
559 CtkListStore *store;
560 CtkTreeIter iter;
561
562 store = CTK_LIST_STORE (dlg->suggestions_list_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->suggestions_list_model)), ((ctk_list_store_get_type
()))))))
;
563 ctk_list_store_clear (store);
564
565 ctk_list_store_append (store, &iter);
566 ctk_list_store_set (store, &iter,
567 /* Translators: Displayed in the "Check Spelling" dialog if the current word isn't misspelled */
568 COLUMN_SUGGESTIONS, _("(correct spelling)")gettext ("(correct spelling)"),
569 -1);
570
571 ctk_widget_set_sensitive (dlg->suggestions_list, FALSE(0));
572 }
573 else
574 {
575 GSList *sug;
576
577 sug = lapiz_spell_checker_get_suggestions (dlg->spell_checker,
578 word,
579 len);
580
581 update_suggestions_list_model (dlg, sug);
582
583 /* free the suggestion list */
584 g_slist_foreach (sug, (GFunc)g_free, NULL((void*)0));
585 g_slist_free (sug);
586 }
587}
588
589static void
590add_word_button_clicked_handler (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__)),
591 LapizSpellCheckerDialog *dlg)
592{
593 gchar *word;
594
595 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
596 g_return_if_fail (dlg->misspelled_word != NULL)do { if ((dlg->misspelled_word != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dlg->misspelled_word != NULL"
); return; } } while (0)
;
597
598 lapiz_spell_checker_add_word_to_personal (dlg->spell_checker,
599 dlg->misspelled_word,
600 -1);
601
602 word = g_strdup (dlg->misspelled_word)g_strdup_inline (dlg->misspelled_word);
603
604 g_signal_emit (G_OBJECT (dlg)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), (((GType) ((20) << (2))))))))
, signals [ADD_WORD_TO_PERSONAL], 0, word);
605
606 g_free (word);
607}
608
609static void
610ignore_button_clicked_handler (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__)),
611 LapizSpellCheckerDialog *dlg)
612{
613 gchar *word;
614
615 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
616 g_return_if_fail (dlg->misspelled_word != NULL)do { if ((dlg->misspelled_word != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dlg->misspelled_word != NULL"
); return; } } while (0)
;
617
618 word = g_strdup (dlg->misspelled_word)g_strdup_inline (dlg->misspelled_word);
619
620 g_signal_emit (G_OBJECT (dlg)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), (((GType) ((20) << (2))))))))
, signals [IGNORE], 0, word);
621
622 g_free (word);
623}
624
625static void
626ignore_all_button_clicked_handler (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__)),
627 LapizSpellCheckerDialog *dlg)
628{
629 gchar *word;
630
631 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
632 g_return_if_fail (dlg->misspelled_word != NULL)do { if ((dlg->misspelled_word != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dlg->misspelled_word != NULL"
); return; } } while (0)
;
633
634 lapiz_spell_checker_add_word_to_session (dlg->spell_checker,
635 dlg->misspelled_word,
636 -1);
637
638 word = g_strdup (dlg->misspelled_word)g_strdup_inline (dlg->misspelled_word);
639
640 g_signal_emit (G_OBJECT (dlg)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), (((GType) ((20) << (2))))))))
, signals [IGNORE_ALL], 0, word);
641
642 g_free (word);
643}
644
645static void
646change_button_clicked_handler (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__)),
647 LapizSpellCheckerDialog *dlg)
648{
649 const gchar *entry_text;
650 gchar *change;
651 gchar *word;
652
653 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
654 g_return_if_fail (dlg->misspelled_word != NULL)do { if ((dlg->misspelled_word != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dlg->misspelled_word != NULL"
); return; } } while (0)
;
655
656 entry_text = ctk_entry_get_text (CTK_ENTRY (dlg->word_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->word_entry)), ((ctk_entry_get_type ()))))))
);
657 g_return_if_fail (entry_text != NULL)do { if ((entry_text != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "entry_text != NULL"
); return; } } while (0)
;
658 g_return_if_fail (*entry_text != '\0')do { if ((*entry_text != '\0')) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "*entry_text != '\\0'"
); return; } } while (0)
;
659 change = g_strdup (entry_text)g_strdup_inline (entry_text);
660
661 lapiz_spell_checker_set_correction (dlg->spell_checker,
662 dlg->misspelled_word, -1,
663 change, -1);
664
665 word = g_strdup (dlg->misspelled_word)g_strdup_inline (dlg->misspelled_word);
666
667 g_signal_emit (G_OBJECT (dlg)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), (((GType) ((20) << (2))))))))
, signals [CHANGE], 0, word, change);
668
669 g_free (word);
670 g_free (change);
671}
672
673/* double click on one of the suggestions is like clicking on "change" */
674static void
675suggestions_list_row_activated_handler (CtkTreeView *view G_GNUC_UNUSED__attribute__ ((__unused__)),
676 CtkTreePath *path G_GNUC_UNUSED__attribute__ ((__unused__)),
677 CtkTreeViewColumn *column G_GNUC_UNUSED__attribute__ ((__unused__)),
678 LapizSpellCheckerDialog *dlg)
679{
680 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
681
682 change_button_clicked_handler (CTK_BUTTON (dlg->change_button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->change_button)), ((ctk_button_get_type ()))))))
, dlg);
683}
684
685static void
686change_all_button_clicked_handler (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__)),
687 LapizSpellCheckerDialog *dlg)
688{
689 const gchar *entry_text;
690 gchar *change;
691 gchar *word;
692
693 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
694 g_return_if_fail (dlg->misspelled_word != NULL)do { if ((dlg->misspelled_word != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "dlg->misspelled_word != NULL"
); return; } } while (0)
;
695
696 entry_text = ctk_entry_get_text (CTK_ENTRY (dlg->word_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->word_entry)), ((ctk_entry_get_type ()))))))
);
697 g_return_if_fail (entry_text != NULL)do { if ((entry_text != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "entry_text != NULL"
); return; } } while (0)
;
698 g_return_if_fail (*entry_text != '\0')do { if ((*entry_text != '\0')) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "*entry_text != '\\0'"
); return; } } while (0)
;
699 change = g_strdup (entry_text)g_strdup_inline (entry_text);
700
701 lapiz_spell_checker_set_correction (dlg->spell_checker,
702 dlg->misspelled_word, -1,
703 change, -1);
704
705 word = g_strdup (dlg->misspelled_word)g_strdup_inline (dlg->misspelled_word);
706
707 g_signal_emit (G_OBJECT (dlg)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), (((GType) ((20) << (2))))))))
, signals [CHANGE_ALL], 0, word, change);
708
709 g_free (word);
710 g_free (change);
711}
712
713void
714lapiz_spell_checker_dialog_set_completed (LapizSpellCheckerDialog *dlg)
715{
716 gchar *tmp;
717
718 g_return_if_fail (LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((dlg)); GType __t = ((lapiz_spell_checker_dialog_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "LAPIZ_IS_SPELL_CHECKER_DIALOG (dlg)"
); return; } } while (0)
;
719
720 tmp = g_strdup_printf("<b>%s</b>", _("Completed spell checking")gettext ("Completed spell checking"));
721 ctk_label_set_label (CTK_LABEL (dlg->misspelled_word_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->misspelled_word_label)), ((ctk_label_get_type ()
))))))
,
722 tmp);
723 g_free (tmp);
724
725 ctk_list_store_clear (CTK_LIST_STORE (dlg->suggestions_list_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->suggestions_list_model)), ((ctk_list_store_get_type
()))))))
);
726 ctk_entry_set_text (CTK_ENTRY (dlg->word_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg->word_entry)), ((ctk_entry_get_type ()))))))
, "");
727
728 ctk_widget_set_sensitive (dlg->word_entry, FALSE(0));
729 ctk_widget_set_sensitive (dlg->check_word_button, FALSE(0));
730 ctk_widget_set_sensitive (dlg->ignore_button, FALSE(0));
731 ctk_widget_set_sensitive (dlg->ignore_all_button, FALSE(0));
732 ctk_widget_set_sensitive (dlg->change_button, FALSE(0));
733 ctk_widget_set_sensitive (dlg->change_all_button, FALSE(0));
734 ctk_widget_set_sensitive (dlg->add_word_button, FALSE(0));
735 ctk_widget_set_sensitive (dlg->suggestions_list, FALSE(0));
736}
737