[gnome-builder/wip/slaf/spellcheck-sidebar: 15/33] spellchecker: update spellchecker actions



commit 4a67c87f9c2f6384676d8ea1e0f6b0ce4b1e3950
Author: Sébastien Lafargue <slafargue gnome org>
Date:   Thu Jan 5 19:31:52 2017 +0100

    spellchecker: update spellchecker actions

 data/keybindings/default.css             |    2 +-
 data/keybindings/vim.css                 |    2 +-
 libide/editor/ide-editor-frame-actions.c |   33 +++++++----------------------
 libide/editor/ide-editor-spell-widget.c  |    4 ++-
 4 files changed, 13 insertions(+), 28 deletions(-)
---
diff --git a/data/keybindings/default.css b/data/keybindings/default.css
index d38814d..c064ef8 100644
--- a/data/keybindings/default.css
+++ b/data/keybindings/default.css
@@ -8,7 +8,7 @@
                   "clear-count" ()
                   "clear-snippets" ()
                   "hide-completion" () };
-  bind "<shift>F7" { "action" ("frame", "spellcheck", "1") };
+  bind "<shift>F7" { "action" ("frame", "show-spellcheck", "1") };
   bind "<ctrl>f" { "action" ("frame", "find", "3") };
   bind "<ctrl>h" { "action" ("frame", "find-replace", "3") };
   bind "<ctrl>o" { "action" ("win", "open-with-dialog", "") };
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index ba433d0..3698653 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -179,7 +179,7 @@
   bind "question" { "action" ("frame", "find", "2") };
 
   /* start spell checking */
-  bind "<shift>F7" { "action" ("frame", "spellcheck", "1") };
+  bind "<shift>F7" { "action" ("frame", "show-spellcheck", "1") };
   /* start search */
   bind "slash" { "action" ("frame", "find", "3") };
   bind "KP_Divide" { "action" ("frame", "find", "3") };
diff --git a/libide/editor/ide-editor-frame-actions.c b/libide/editor/ide-editor-frame-actions.c
index fd2a166..8ac7ec3 100644
--- a/libide/editor/ide-editor-frame-actions.c
+++ b/libide/editor/ide-editor-frame-actions.c
@@ -32,25 +32,20 @@ ide_editor_frame_actions_spellcheck (GSimpleAction *action,
   IdeEditorFrame *self = user_data;
   IdeWorkbench *workbench;
   IdePerspective *editor;
+  gboolean state;
 
   g_assert (IDE_IS_EDITOR_FRAME (self));
 
+  state = !!g_variant_get_int32 (variant);
+  if (state == TRUE)
+    {
   if (IDE_IS_SOURCE_VIEW (self->source_view) &&
       NULL != (workbench = ide_widget_get_workbench (GTK_WIDGET (self))) &&
       NULL != (editor = ide_workbench_get_perspective_by_name (workbench, "editor")))
     ide_editor_perspective_show_spellchecker (IDE_EDITOR_PERSPECTIVE (editor), self->source_view);
-}
-
-static void
-ide_editor_frame_actions_exit_spell (GSimpleAction *action,
-                                     GVariant      *state,
-                                     gpointer       user_data)
-{
-  IdeEditorFrame *self = user_data;
-
-  g_assert (IDE_IS_EDITOR_FRAME (self));
-
-  gtk_widget_grab_focus (GTK_WIDGET (self->source_view));
+    }
+  else
+    gtk_widget_grab_focus (GTK_WIDGET (self->source_view));
 }
 
 static void
@@ -446,7 +441,7 @@ static const GActionEntry IdeEditorFrameActions[] = {
   { "next-search-result", ide_editor_frame_actions_next_search_result },
   { "previous-search-result", ide_editor_frame_actions_previous_search_result },
   { "replace-confirm", ide_editor_frame_actions_replace_confirm, "as" },
-  { "spellcheck", ide_editor_frame_actions_spellcheck, "i" },
+  { "show-spellcheck", ide_editor_frame_actions_spellcheck, "i" },
 };
 
 static const GActionEntry IdeEditorFrameSearchActions[] = {
@@ -462,10 +457,6 @@ static const GActionEntry IdeEditorFrameSearchActions[] = {
   { "replace-all", ide_editor_frame_actions_replace_all },
 };
 
-static const GActionEntry IdeEditorFrameSpellActions[] = {
-  { "exit-spell", ide_editor_frame_actions_exit_spell },
-};
-
 void
 ide_editor_frame_actions_init (IdeEditorFrame *self)
 {
@@ -493,13 +484,5 @@ ide_editor_frame_actions_init (IdeEditorFrame *self)
   g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
 
   gtk_widget_insert_action_group (GTK_WIDGET (self->search_frame), "search-entry", G_ACTION_GROUP (group));
-
-  g_object_unref (group);
-
-  group = g_simple_action_group_new ();
-  g_action_map_add_action_entries (G_ACTION_MAP (group), IdeEditorFrameSpellActions,
-                                   G_N_ELEMENTS (IdeEditorFrameSpellActions), self);
-
-  //gtk_widget_insert_action_group (GTK_WIDGET (self->spell_revealer), "spell-entry", G_ACTION_GROUP 
(group));
   g_object_unref (group);
 }
diff --git a/libide/editor/ide-editor-spell-widget.c b/libide/editor/ide-editor-spell-widget.c
index 5a50c9c..7372a84 100644
--- a/libide/editor/ide-editor-spell-widget.c
+++ b/libide/editor/ide-editor-spell-widget.c
@@ -446,7 +446,9 @@ ide_editor_spell_widget__key_press_event_cb (IdeEditorSpellWidget *self,
   switch (event->keyval)
     {
     case GDK_KEY_Escape:
-      ide_widget_action (GTK_WIDGET (self), "spell-entry", "exit-spell", NULL);
+      ide_widget_action (GTK_WIDGET (self->view),
+                         "frame", "show-spellcheck",
+                         g_variant_new_int32 (0));
       return GDK_EVENT_STOP;
 
     default:


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