[gnome-builder/wip/slaf/spellcheck-sidebar: 31/33] spellchecker: don't close the panel at spellchecking end
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/slaf/spellcheck-sidebar: 31/33] spellchecker: don't close the panel at spellchecking end
- Date: Wed, 11 Jan 2017 20:49:26 +0000 (UTC)
commit 012b24de881b2d481a9b2a46d816d897d6fc3e0b
Author: Sébastien Lafargue <slafargue gnome org>
Date: Wed Jan 11 19:27:36 2017 +0100
spellchecker: don't close the panel at spellchecking end
After the last word, we focus on the dict entry
with an empty text, so that you can still add words
to the personal dictionary.
libide/editor/ide-editor-spell-widget.c | 46 +++++++++++++++++++++++-------
1 files changed, 35 insertions(+), 11 deletions(-)
---
diff --git a/libide/editor/ide-editor-spell-widget.c b/libide/editor/ide-editor-spell-widget.c
index 5518c33..090941c 100644
--- a/libide/editor/ide-editor-spell-widget.c
+++ b/libide/editor/ide-editor-spell-widget.c
@@ -81,6 +81,8 @@ struct _IdeEditorSpellWidget
guint is_dict_checking_word : 1;
guint is_dict_check_word_invalid : 1;
guint is_dict_check_word_idle : 1;
+
+ guint spellchecking_status : 1;
};
G_DEFINE_TYPE (IdeEditorSpellWidget, ide_editor_spell_widget, GTK_TYPE_BIN)
@@ -236,8 +238,7 @@ jump_to_next_misspelled_word (IdeEditorSpellWidget *self)
g_autofree gchar *word = NULL;
g_autofree gchar *first_result = NULL;
GtkListBoxRow *row;
-
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
gboolean ret = FALSE;
g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));
@@ -259,11 +260,12 @@ jump_to_next_misspelled_word (IdeEditorSpellWidget *self)
{
if (error != NULL)
gtk_label_set_text (GTK_LABEL (self->placeholder), error->message);
- else
- {
- gtk_label_set_text (GTK_LABEL (self->placeholder), _("Completed spell checking"));
- update_global_sensiblility (self, FALSE);
- }
+
+ self->spellchecking_status = FALSE;
+
+ gtk_label_set_text (GTK_LABEL (self->placeholder), _("Completed spell checking"));
+ gtk_widget_grab_focus (self->dict_word_entry);
+ update_global_sensiblility (self, FALSE);
}
return ret;
@@ -362,7 +364,7 @@ ide_editor_spell_widget__word_entry_changed_cb (IdeEditorSpellWidget *self,
update_change_ignore_sensibility (self);
word = gtk_entry_get_text (self->word_entry);
- if (ide_str_empty0 (word))
+ if (ide_str_empty0 (word) && self->spellchecking_status == TRUE)
{
word = gtk_label_get_text (self->word_label);
gtk_entry_set_text (GTK_ENTRY (self->dict_word_entry), word);
@@ -968,6 +970,24 @@ ide_editor_spell_widget__dict__loaded_cb (IdeEditorSpellWidget *self,
}
static void
+ide_editor_spell_widget__word_label_notify_cb (IdeEditorSpellWidget *self,
+ GParamSpec *pspec,
+ GtkLabel *word_label)
+{
+ const gchar *text;
+
+ g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));
+ g_assert (GTK_IS_LABEL (word_label));
+
+ if (self->spellchecking_status == TRUE)
+ text = gtk_label_get_text (word_label);
+ else
+ text = "";
+
+ gtk_entry_set_text (GTK_ENTRY (self->dict_word_entry), text);
+}
+
+static void
ide_editor_spell_widget_constructed (GObject *object)
{
IdeEditorSpellWidget *self = (IdeEditorSpellWidget *)object;
@@ -978,6 +998,8 @@ ide_editor_spell_widget_constructed (GObject *object)
self->buffer = IDE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->view)));
ide_buffer_set_spell_checking (self->buffer, TRUE);
+ self->spellchecking_status = TRUE;
+
spell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (GTK_TEXT_BUFFER (self->buffer));
self->checker = gspell_text_buffer_get_spell_checker (spell_buffer);
ide_editor_spell_dict_set_checker (self->dict, self->checker);
@@ -1076,9 +1098,11 @@ ide_editor_spell_widget_constructed (GObject *object)
G_CALLBACK (ide_editor_spell_widget__dict__loaded_cb),
self);
- g_object_bind_property (self->word_label, "label",
- self->dict_word_entry, "text",
- G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+ g_signal_connect_object (self->word_label,
+ "notify::label",
+ G_CALLBACK (ide_editor_spell_widget__word_label_notify_cb),
+ self,
+ G_CONNECT_SWAPPED);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]