[gnome-boxes] Add KeysInputPopover
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Add KeysInputPopover
- Date: Fri, 12 Dec 2014 18:42:10 +0000 (UTC)
commit b47cf6bdb8330cc97006677d282e90a1506146f8
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Dec 12 18:27:57 2014 +0000
Add KeysInputPopover
This popover is meant to allow users to easily send key combos to guest
that would normally be captured by host/client system. The supported
combos are kept limited to not clutter the UI. Currently supported
comboxes are:
* Ctrl+Alt+Backspace
* Ctrl+Alt+F1
* Ctrl+Alt+F2
* Ctrl+Alt+F7
The point of supporting these 3 specific FN combos is to allow user to
easily switch to/from console VT from/to graphics one on X-running
guests. Once they are on a console VT, they can then use Alt+FN combo to
get to other VTs but we don't provide a combo for that since its not
expected to be the most typical use case.
https://bugzilla.gnome.org/show_bug.cgi?id=725303
src/Makefile.am | 1 +
src/keys-input-popover.vala | 72 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index fbddc61..bc9524d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -110,6 +110,7 @@ gnome_boxes_SOURCES = \
i-properties-provider.vala \
installer-media.vala \
installed-media.vala \
+ keys-input-popover.vala \
libvirt-system-media.vala \
iso-extractor.vala \
libvirt-broker.vala \
diff --git a/src/keys-input-popover.vala b/src/keys-input-popover.vala
new file mode 100644
index 0000000..132fa81
--- /dev/null
+++ b/src/keys-input-popover.vala
@@ -0,0 +1,72 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+private class Boxes.KeysInputPopover: Gtk.Popover {
+ private const GLib.ActionEntry[] action_entries = {
+ {"ctrl+alt+backspace", ctrl_alt_backspace_activated},
+
+ {"ctrl+alt+f1", ctrl_alt_fn_activated},
+ {"ctrl+alt+f2", ctrl_alt_fn_activated},
+ {"ctrl+alt+f7", ctrl_alt_fn_activated},
+ };
+
+ private AppWindow window;
+ private GLib.SimpleActionGroup action_group;
+
+ public KeysInputPopover (AppWindow window) {
+ this.window = window;
+
+ action_group = new GLib.SimpleActionGroup ();
+ action_group.add_action_entries (action_entries, this);
+ this.insert_action_group ("key", action_group);
+
+ var menu = new GLib.Menu ();
+
+ menu.append (_("Ctrl + Alt + Backspace"), "key.ctrl+alt+backspace");
+
+ // New section
+ var section = new GLib.Menu ();
+ section.append (_("Ctrl + Alt + F1"), "key.ctrl+alt+f1");
+ section.append (_("Ctrl + Alt + F2"), "key.ctrl+alt+f2");
+ section.append (_("Ctrl + Alt + F7"), "key.ctrl+alt+f7");
+ menu.append_section (null, section);
+
+ bind_model (menu, null);
+
+ var a11y = get_accessible ();
+ a11y.role = Atk.Role.POPUP_MENU;
+ // Translators: Accessibility name for context menu with a set of keyboard combos (that would
normally be
+ // intercepted by host/client, to send to the box.
+ a11y.name = _("Send key combinations");
+ }
+
+ private void ctrl_alt_backspace_activated () {
+ uint[] keyvals = { Gdk.Key.Control_L, Gdk.Key.Alt_L, Gdk.Key.BackSpace };
+
+ send_keys (keyvals);
+ }
+
+ private void ctrl_alt_fn_activated (GLib.SimpleAction action) {
+ uint[] keyvals = { Gdk.Key.Control_L, Gdk.Key.Alt_L, 0 };
+
+ if (action.name[action.name.length - 1] == '1')
+ keyvals[2] = Gdk.Key.F1;
+ else if (action.name[action.name.length - 1] == '2')
+ keyvals[2] = Gdk.Key.F2;
+ else if (action.name[action.name.length - 1] == '7')
+ keyvals[2] = Gdk.Key.F7;
+ else {
+ warn_if_reached ();
+
+ return;
+ }
+
+ send_keys (keyvals);
+ }
+
+ private void send_keys (uint[] keyvals) {
+ var machine = window.current_item as Machine;
+ return_if_fail (machine != null && machine.display != null);
+
+ machine.display.send_keys (keyvals);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]