Commit 371a2ff6 authored by Christian Hergert's avatar Christian Hergert

sourceview: start plumbing some controller callbacks

parent e108757d
......@@ -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") };
......
......@@ -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),
......
......@@ -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',
......
/* 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
/* 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);
}
......@@ -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);
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment