[gitg/wip/albfan/history-panel-shorcuts: 30/31] Add shortcuts for history panels
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/albfan/history-panel-shorcuts: 30/31] Add shortcuts for history panels
- Date: Sat, 6 Jun 2020 00:18:25 +0000 (UTC)
commit 151b9521cfa0bfd87c1d9a0bd6cd95d23087caaf
Author: Alberto Fanjul <albertofanjul gmail com>
Date: Wed Feb 5 01:42:36 2020 +0100
Add shortcuts for history panels
gitg/history/gitg-history.vala | 17 +++++++++++++++++
libgitg-ext/gitg-ext-ui-element.vala | 11 +++++++++++
plugins/diff/gitg-diff.vala | 5 +++++
plugins/files/gitg-files.vala | 5 +++++
4 files changed, 38 insertions(+)
---
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index 38dfdd1e..8d063d06 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -552,6 +552,23 @@ namespace GitgHistory
});
}
+ public bool on_key_pressed (Gdk.EventKey event) {
+ var mmask = Gtk.accelerator_get_default_mod_mask();
+
+ if ((mmask & event.state) == Gdk.ModifierType.MOD1_MASK)
+ {
+ foreach(var element in d_panels.get_available_elements()) {
+ GitgExt.HistoryPanel panel = (GitgExt.HistoryPanel)element;
+ uint? key = panel.shortcut;
+ if (key != null && key == Gdk.keyval_to_lower(event.keyval)) {
+ panel.activate();
+ return true;
+ }
+ };
+ }
+ return false;
+ }
+
private void build_ui()
{
d_main = new Paned();
diff --git a/libgitg-ext/gitg-ext-ui-element.vala b/libgitg-ext/gitg-ext-ui-element.vala
index 8230172f..bdab4567 100644
--- a/libgitg-ext/gitg-ext-ui-element.vala
+++ b/libgitg-ext/gitg-ext-ui-element.vala
@@ -80,6 +80,17 @@ public interface UIElement : Object
owned get { return null; }
}
+ /**
+ * The ui element shortcut.
+ *
+ * If provided, the key to mix with Gdk.ModifierType.MOD1_MASK to enable
+ * this element
+ */
+ public virtual uint? shortcut
+ {
+ owned get { return null; }
+ }
+
/**
* Check whether the ui element is available in the current application state.
*
diff --git a/plugins/diff/gitg-diff.vala b/plugins/diff/gitg-diff.vala
index 51d18706..324780fb 100644
--- a/plugins/diff/gitg-diff.vala
+++ b/plugins/diff/gitg-diff.vala
@@ -32,6 +32,11 @@ namespace GitgDiff
private ulong d_selection_changed_id;
+ public virtual uint? shortcut
+ {
+ owned get { return Gdk.Key.d; }
+ }
+
protected override void constructed()
{
base.constructed();
diff --git a/plugins/files/gitg-files.vala b/plugins/files/gitg-files.vala
index 9adb63d2..b878fc7a 100644
--- a/plugins/files/gitg-files.vala
+++ b/plugins/files/gitg-files.vala
@@ -48,6 +48,11 @@ namespace GitgFiles
history.selection_changed.connect(on_selection_changed);
}
+ public virtual uint? shortcut
+ {
+ owned get { return Gdk.Key.f; }
+ }
+
public string id
{
owned get { return "/org/gnome/gitg/Panels/Files"; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]