From 5fa129ca53e33fa5dc90f65e4ddaf77beb1d5b10 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 2 Jul 2025 20:34:35 +0100 Subject: [PATCH 1/5] Fix accelerator --- src/MainWindow.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 10e02af36..05a51b6f1 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -207,6 +207,7 @@ namespace Scratch { action_accelerators.set (ACTION_FIND_PREVIOUS, "g"); action_accelerators.set (ACTION_FIND_GLOBAL + "::", "f"); action_accelerators.set (ACTION_OPEN, "o"); + action_accelerators.set (ACTION_OPEN_FOLDER + "::", "o"); action_accelerators.set (ACTION_OPEN_FOLDER, "o"); action_accelerators.set (ACTION_REVERT, "o"); action_accelerators.set (ACTION_SAVE, "s"); From e70384f19f9a0d8d06585426a4acf6f97d0994f3 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 2 Jul 2025 20:34:49 +0100 Subject: [PATCH 2/5] Fix accel clash --- src/MainWindow.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 05a51b6f1..5c5b53a96 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -208,8 +208,7 @@ namespace Scratch { action_accelerators.set (ACTION_FIND_GLOBAL + "::", "f"); action_accelerators.set (ACTION_OPEN, "o"); action_accelerators.set (ACTION_OPEN_FOLDER + "::", "o"); - action_accelerators.set (ACTION_OPEN_FOLDER, "o"); - action_accelerators.set (ACTION_REVERT, "o"); + action_accelerators.set (ACTION_REVERT, "r"); action_accelerators.set (ACTION_SAVE, "s"); action_accelerators.set (ACTION_SAVE_AS, "s"); action_accelerators.set (ACTION_GO_TO, "i"); From 3e9e34817976960d08bdff1eaffd959260425543 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 2 Jul 2025 22:20:13 +0100 Subject: [PATCH 3/5] Show accel --- src/MainWindow.vala | 3 ++- src/Widgets/ChooseProjectButton.vala | 1 + src/Widgets/PopoverMenuItem.vala | 23 +++++++++++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 5c5b53a96..76a96c3f8 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -76,6 +76,7 @@ namespace Scratch { public const string ACTION_FIND_GLOBAL = "action-find-global"; public const string ACTION_OPEN = "action-open"; public const string ACTION_OPEN_FOLDER = "action-open-folder"; + public const string ACTION_OPEN_FOLDER_ACCEL = "o"; public const string ACTION_COLLAPSE_ALL_FOLDERS = "action-collapse-all-folders"; public const string ACTION_ORDER_FOLDERS = "action-order-folders"; public const string ACTION_GO_TO = "action-go-to"; @@ -207,7 +208,7 @@ namespace Scratch { action_accelerators.set (ACTION_FIND_PREVIOUS, "g"); action_accelerators.set (ACTION_FIND_GLOBAL + "::", "f"); action_accelerators.set (ACTION_OPEN, "o"); - action_accelerators.set (ACTION_OPEN_FOLDER + "::", "o"); + action_accelerators.set (ACTION_OPEN_FOLDER + "::", ACTION_OPEN_FOLDER_ACCEL); action_accelerators.set (ACTION_REVERT, "r"); action_accelerators.set (ACTION_SAVE, "s"); action_accelerators.set (ACTION_SAVE_AS, "s"); diff --git a/src/Widgets/ChooseProjectButton.vala b/src/Widgets/ChooseProjectButton.vala index 3b035c5b2..b7b8f00fa 100644 --- a/src/Widgets/ChooseProjectButton.vala +++ b/src/Widgets/ChooseProjectButton.vala @@ -75,6 +75,7 @@ public class Code.ChooseProjectButton : Gtk.MenuButton { action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_OPEN_FOLDER, action_target = new Variant.string (""), icon_name = "folder-open-symbolic", + accel_string = Scratch.MainWindow.ACTION_OPEN_FOLDER_ACCEL }; var clone_button = new PopoverMenuItem (_("Clone Git Repository…")) { diff --git a/src/Widgets/PopoverMenuItem.vala b/src/Widgets/PopoverMenuItem.vala index 72461986f..4b121f745 100644 --- a/src/Widgets/PopoverMenuItem.vala +++ b/src/Widgets/PopoverMenuItem.vala @@ -12,7 +12,18 @@ public class Code.PopoverMenuItem : Gtk.Button { /** * The icon name for the button */ - public string icon_name { get; set; } + private Gtk.Image image; + public string icon_name { + set { + image.icon_name = value; + } + } + private Granite.AccelLabel accel_label; + public string accel_string { + set { + accel_label.accel_string = value; + } + } public PopoverMenuItem (string text) { Object (text: text); @@ -23,13 +34,12 @@ public class Code.PopoverMenuItem : Gtk.Button { } construct { - var image = new Gtk.Image (); - - var label = new Granite.AccelLabel (text); + image = new Gtk.Image (); + accel_label = new Granite.AccelLabel (text); var box = new Gtk.Box (HORIZONTAL, 6); box.add (image); - box.add (label); + box.add (accel_label); child = box; @@ -41,8 +51,5 @@ public class Code.PopoverMenuItem : Gtk.Button { popover.popdown (); } }); - - bind_property ("action-name", label, "action-name"); - bind_property ("icon-name", image, "icon-name"); } } From af536bd5e1628ad6d47a8dbccbe32c9f4e949f8f Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 3 Jul 2025 01:35:55 +0100 Subject: [PATCH 4/5] lint --- src/Widgets/PopoverMenuItem.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/PopoverMenuItem.vala b/src/Widgets/PopoverMenuItem.vala index 4b121f745..6e746f8b5 100644 --- a/src/Widgets/PopoverMenuItem.vala +++ b/src/Widgets/PopoverMenuItem.vala @@ -13,7 +13,7 @@ public class Code.PopoverMenuItem : Gtk.Button { * The icon name for the button */ private Gtk.Image image; - public string icon_name { + public string icon_name { set { image.icon_name = value; } From f23376fd7ca2b8fe63000bde8c12f1cedf61a615 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 3 Jul 2025 01:43:41 +0100 Subject: [PATCH 5/5] Suppress compile warning --- src/Widgets/PopoverMenuItem.vala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Widgets/PopoverMenuItem.vala b/src/Widgets/PopoverMenuItem.vala index 6e746f8b5..65d43e7e2 100644 --- a/src/Widgets/PopoverMenuItem.vala +++ b/src/Widgets/PopoverMenuItem.vala @@ -12,10 +12,10 @@ public class Code.PopoverMenuItem : Gtk.Button { /** * The icon name for the button */ - private Gtk.Image image; + private Gtk.Image gtk_image; public string icon_name { set { - image.icon_name = value; + gtk_image.icon_name = value; } } private Granite.AccelLabel accel_label; @@ -34,11 +34,11 @@ public class Code.PopoverMenuItem : Gtk.Button { } construct { - image = new Gtk.Image (); + gtk_image = new Gtk.Image (); accel_label = new Granite.AccelLabel (text); var box = new Gtk.Box (HORIZONTAL, 6); - box.add (image); + box.add (gtk_image); box.add (accel_label); child = box;