[gnome-builder] html-preview: add shortcut for html preview
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] html-preview: add shortcut for html preview
- Date: Wed, 19 Jul 2017 22:28:46 +0000 (UTC)
commit 036df10e367cf46c169be83e72991e38388965ac
Author: Christian Hergert <chergert redhat com>
Date: Wed Jul 19 15:27:01 2017 -0700
html-preview: add shortcut for html preview
This adds an ctrl+alt+p shortcut like we used to have a long
time ago. However, due to a bug in the shortcut controller
dispatch in libdazzle, it does not current activate unless it
is set to global (which we do not want).
We'll have fixes coming to libdazzle shortly.
Additionally, it would be nice to register the command with
the shortcut manager so that we can get automated UI in the
shortcuts window, but we need to figure out how to do that
from Python first.
.../html-preview/html_preview_plugin/__init__.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/plugins/html-preview/html_preview_plugin/__init__.py
b/plugins/html-preview/html_preview_plugin/__init__.py
index bf69387..aea51e0 100644
--- a/plugins/html-preview/html_preview_plugin/__init__.py
+++ b/plugins/html-preview/html_preview_plugin/__init__.py
@@ -33,6 +33,7 @@ gi.require_version('Gtk', '3.0')
gi.require_version('Ide', '1.0')
gi.require_version('WebKit2', '4.0')
+from gi.repository import Dazzle
from gi.repository import GLib
from gi.repository import Gio
from gi.repository import Gtk
@@ -206,6 +207,13 @@ class HtmlPreviewAddin(GObject.Object, Ide.EditorViewAddin):
self.do_language_changed(language_id)
+ # Add a shortcut for activation inside the editor
+ controller = Dazzle.ShortcutController.find(view)
+ controller.add_command_action('org.gnome.builder.html-preview.preview',
+ '<Control><Alt>p',
+ Dazzle.ShortcutPhase.CAPTURE,
+ 'editor-view.preview-as-html')
+
def do_unload(self, view):
group = view.get_action_group('editor-view')
group.remove_action('preview-as-html')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]