[gnome-builder] sourceview: start plumbing some controller callbacks



commit 371a2ff602b63ed7186ef7278777f641937ffdfd
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jun 27 19:41:00 2017 -0700

    sourceview: start plumbing some controller callbacks

 data/keybindings/default.css                  |    1 -
 libide/editor/ide-editor-view-shortcuts.c     |   72 +++++++++++++++++++++++++
 libide/meson.build                            |    2 +
 libide/sourceview/ide-source-view-private.h   |   27 +++++++++
 libide/sourceview/ide-source-view-shortcuts.c |   47 ++++++++++++++++
 libide/sourceview/ide-source-view.c           |    3 +
 6 files changed, 151 insertions(+), 1 deletions(-)
---
diff --git a/data/keybindings/default.css b/data/keybindings/default.css
index 32895e7..080d31a 100644
--- a/data/keybindings/default.css
+++ b/data/keybindings/default.css
@@ -10,7 +10,6 @@
                   "hide-completion" ()
                   "remove-cursors" () };
   bind "<shift>F7" { "action" ("frame", "show-spellcheck", "1") };
-  bind "<ctrl>f" { "action" ("frame", "find", "3") };
   bind "<ctrl><shift>e" { "add-cursor" (column) };
   bind "<ctrl><shift>d" { "add-cursor" (match) };
   bind "<ctrl>h" { "action" ("frame", "find-replace", "3") };
diff --git a/libide/editor/ide-editor-view-shortcuts.c b/libide/editor/ide-editor-view-shortcuts.c
index 49f9598..1e07455 100644
--- a/libide/editor/ide-editor-view-shortcuts.c
+++ b/libide/editor/ide-editor-view-shortcuts.c
@@ -19,17 +19,89 @@
 #include "config.h"
 
 #include <dazzle.h>
+#include <glib/gi18n.h>
 
 #include "ide-editor-private.h"
 
+#define I_(s) (g_intern_static_string(s))
+
 static DzlShortcutEntry editor_view_shortcuts[] = {
+  { "org.gnome.builder.editor-view.find",
+    "<Primary>f",
+    N_("Editor"),
+    N_("Find and replace"),
+    N_("Find") },
+
+  { "org.gnome.builder.editor-view.find-and-replace",
+    "<Primary>h",
+    N_("Editor"),
+    N_("Find and replace"),
+    N_("Find and replace") },
+
+  { "org.gnome.builder.editor-view.next-match",
+    "<Primary>g",
+    N_("Editor"),
+    N_("Find and replace"),
+    N_("Find the next match") },
+
+  { "org.gnome.builder.editor-view.prev-match",
+    "<Primary><Shift>g",
+    N_("Editor"),
+    N_("Find and replace"),
+    N_("Find the next match") },
+
+  { "org.gnome.builder.editor-view.clear-highlight",
+    "<Primary><Shift>k",
+    N_("Editor"),
+    N_("Find and replace"),
+    N_("Find the next match") },
 };
 
+static void
+ide_editor_view_shortcuts_find (GtkWidget *widget,
+                                gpointer   user_data)
+{
+  IdeEditorView *self = user_data;
+
+  g_assert (IDE_IS_EDITOR_VIEW (self));
+
+  g_print ("TYPE: %s\n", G_OBJECT_TYPE_NAME (widget));
+}
+
 void
 _ide_editor_view_init_shortcuts (IdeEditorView *self)
 {
+  DzlShortcutController *controller;
+
   g_return_if_fail (IDE_IS_EDITOR_VIEW (self));
 
+  controller = dzl_shortcut_controller_find (GTK_WIDGET (self));
+
+  dzl_shortcut_controller_add_command_callback (controller,
+                                                I_("org.gnome.builder.editor-view.find"),
+                                                NULL,
+                                                ide_editor_view_shortcuts_find, self, NULL);
+
+  dzl_shortcut_controller_add_command_action (controller,
+                                              I_("org.gnome.builder.editor-view.find-and-replace"),
+                                              NULL,
+                                              I_("editor-view.find-and-replace"));
+
+  dzl_shortcut_controller_add_command_action (controller,
+                                              I_("org.gnome.builder.editor-view.next-match"),
+                                              NULL,
+                                              I_("editor-view.next-match"));
+
+  dzl_shortcut_controller_add_command_action (controller,
+                                              I_("org.gnome.builder.editor-view.prev-match"),
+                                              NULL,
+                                              I_("editor-view.prev-match"));
+
+  dzl_shortcut_controller_add_command_action (controller,
+                                              I_("org.gnome.builder.editor-view.clear-highlight"),
+                                              NULL,
+                                              I_("editor-view.clear-highlight"));
+
   dzl_shortcut_manager_add_shortcut_entries (NULL,
                                              editor_view_shortcuts,
                                              G_N_ELEMENTS (editor_view_shortcuts),
diff --git a/libide/meson.build b/libide/meson.build
index a70c32f..3eedb90 100644
--- a/libide/meson.build
+++ b/libide/meson.build
@@ -520,6 +520,8 @@ libide_sources = libide_generated_headers + libide_public_sources + [
   'sourceview/ide-source-view-capture.h',
   'sourceview/ide-source-view-movements.c',
   'sourceview/ide-source-view-movements.h',
+  'sourceview/ide-source-view-private.h',
+  'sourceview/ide-source-view-shortcuts.c',
   'sourceview/ide-text-iter.c',
   'sourceview/ide-text-iter.h',
   'sourceview/ide-text-util.c',
diff --git a/libide/sourceview/ide-source-view-private.h b/libide/sourceview/ide-source-view-private.h
new file mode 100644
index 0000000..51cb45c
--- /dev/null
+++ b/libide/sourceview/ide-source-view-private.h
@@ -0,0 +1,27 @@
+/* ide-source-view-private.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "ide-source-view.h"
+
+G_BEGIN_DECLS
+
+void _ide_source_view_init_shortcuts (IdeSourceView *self);
+
+G_END_DECLS
diff --git a/libide/sourceview/ide-source-view-shortcuts.c b/libide/sourceview/ide-source-view-shortcuts.c
new file mode 100644
index 0000000..0299969
--- /dev/null
+++ b/libide/sourceview/ide-source-view-shortcuts.c
@@ -0,0 +1,47 @@
+/* ide-source-view-shortcuts.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "ide-source-view-shortcuts"
+
+#include "config.h"
+
+#include <dazzle.h>
+
+#include "ide-source-view.h"
+
+static const DzlShortcutEntry source_view_shortcuts[] = {
+};
+
+void
+_ide_source_view_init_shortcuts (IdeSourceView *self)
+{
+  DzlShortcutController *controller;
+
+  g_assert (IDE_IS_SOURCE_VIEW (self));
+
+  controller = dzl_shortcut_controller_find (GTK_WIDGET (self));
+
+  dzl_shortcut_controller_add_command_signal (controller,
+                                              "org.gnome.builder.sourceview.reset",
+                                              "Escape", "reset", 0);
+
+  dzl_shortcut_manager_add_shortcut_entries (NULL,
+                                             source_view_shortcuts,
+                                             G_N_ELEMENTS (source_view_shortcuts),
+                                             GETTEXT_PACKAGE);
+}
diff --git a/libide/sourceview/ide-source-view.c b/libide/sourceview/ide-source-view.c
index 24cfad6..fdeaaa1 100644
--- a/libide/sourceview/ide-source-view.c
+++ b/libide/sourceview/ide-source-view.c
@@ -55,6 +55,7 @@
 #include "sourceview/ide-source-view-capture.h"
 #include "sourceview/ide-source-view-mode.h"
 #include "sourceview/ide-source-view-movements.h"
+#include "sourceview/ide-source-view-private.h"
 #include "sourceview/ide-source-view.h"
 #include "sourceview/ide-text-util.h"
 #include "sourceview/ide-cursor.h"
@@ -4571,6 +4572,8 @@ ide_source_view_constructed (GObject *object)
 
   G_OBJECT_CLASS (ide_source_view_parent_class)->constructed (object);
 
+  _ide_source_view_init_shortcuts (self);
+
   ide_source_view_real_set_mode (self, NULL, IDE_SOURCE_VIEW_MODE_TYPE_PERMANENT);
 
   /*


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