Commit 036df10e authored by Christian Hergert's avatar Christian Hergert

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.
parent 1ab7008c
......@@ -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')
......
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