From 92cb174b2850e371dc75b63085a516ecac0495f2 Mon Sep 17 00:00:00 2001 From: Sudhanshu Tiwari Date: Thu, 27 Feb 2025 20:25:02 +0530 Subject: [PATCH 1/7] src: Add blueprint for Shortcuts Window demo --- src/Shortcuts Window/main.blp | 153 ++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 src/Shortcuts Window/main.blp diff --git a/src/Shortcuts Window/main.blp b/src/Shortcuts Window/main.blp new file mode 100644 index 00000000..6f5666c0 --- /dev/null +++ b/src/Shortcuts Window/main.blp @@ -0,0 +1,153 @@ +using Gtk 4.0; +using Adw 1; + +Adw.StatusPage { + title: _("Shortcuts Window"); + description: _("A window showing the application's keyboard shortcuts"); + + Box { + spacing: 50; + halign: center; + orientation: vertical; + + Button button { + label: _("Open"); + + styles [ + "suggested-action", + "pill", + ] + } + + LinkButton { + label: _("API Reference"); + uri: "https://docs.gtk.org/gtk4/class.ShortcutsWindow.html"; + } + } +} + +Gtk.ShortcutsWindow shortcuts_window { + hide-on-close: true; + + Gtk.ShortcutsSection { + section-name: _("Shortcuts"); + max-height: 18; + + Gtk.ShortcutsGroup { + title: _("Application"); + + Gtk.ShortcutsShortcut { + accelerator: "Return"; + title: _("Run Code"); + } + + Gtk.ShortcutsShortcut { + accelerator: "Return"; + title: _("Format"); + } + + Gtk.ShortcutsShortcut { + accelerator: "N"; + title: _("New Project"); + } + + Gtk.ShortcutsShortcut { + accelerator: "O"; + title: _("Open Project"); + } + + Gtk.ShortcutsShortcut { + accelerator: "O"; + title: _("Open Library"); + } + + Gtk.ShortcutsShortcut { + accelerator: "I"; + title: _("Inspector"); + } + + Gtk.ShortcutsShortcut { + accelerator: "W"; + title: _("Close Window"); + } + + Gtk.ShortcutsShortcut { + accelerator: "M"; + title: _("Reveal in Files"); + } + + Gtk.ShortcutsShortcut { + accelerator: "question"; + title: _("Keyboard Shortcuts"); + } + + Gtk.ShortcutsShortcut { + accelerator: "Q"; + title: _("Quit"); + } + } + + Gtk.ShortcutsGroup { + title: _("Editor"); + + Gtk.ShortcutsShortcut { + accelerator: "X"; + title: _("Cut"); + } + + Gtk.ShortcutsShortcut { + accelerator: "C"; + title: _("Copy"); + } + + Gtk.ShortcutsShortcut { + accelerator: "V"; + title: _("Paste"); + } + + Gtk.ShortcutsShortcut { + accelerator: "F"; + title: _("Find"); + } + + Gtk.ShortcutsShortcut { + accelerator: "Z"; + title: _("Undo"); + } + + Gtk.ShortcutsShortcut { + accelerator: "space"; + title: _("Show code suggestions"); + } + + Gtk.ShortcutsShortcut { + accelerator: "Z"; + title: _("Redo"); + } + } + + Gtk.ShortcutsGroup { + title: _("Console"); + + Gtk.ShortcutsShortcut { + accelerator: "K"; + title: _("Toggle Console"); + } + + Gtk.ShortcutsShortcut { + accelerator: "C"; + title: _("Copy"); + } + + Gtk.ShortcutsShortcut { + accelerator: "A"; + title: _("Select All"); + } + + Gtk.ShortcutsShortcut { + accelerator: "K"; + title: _("Clear"); + } + } + } +} From a088d84ab9f0a85725a2b5716b0f5eb544edbbdb Mon Sep 17 00:00:00 2001 From: Sudhanshu Tiwari Date: Thu, 27 Feb 2025 20:29:56 +0530 Subject: [PATCH 2/7] src: Add json file for Shortcuts Window demo --- src/Shortcuts Window/main.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/Shortcuts Window/main.json diff --git a/src/Shortcuts Window/main.json b/src/Shortcuts Window/main.json new file mode 100644 index 00000000..b6235522 --- /dev/null +++ b/src/Shortcuts Window/main.json @@ -0,0 +1,6 @@ +{ + "category": "user_interface", + "description": "A window showing the application's keyboard shortcuts", + "panels": ["ui", "preview"], + "autorun": true +} \ No newline at end of file From ec81a226b9e9a5fa5f8543fde8788b33a10a5300 Mon Sep 17 00:00:00 2001 From: Sudhanshu Tiwari Date: Thu, 27 Feb 2025 20:58:43 +0530 Subject: [PATCH 3/7] src: Add code for Shortcuts Window demo --- src/Shortcuts Window/code.rs | 10 ++++++++++ src/Shortcuts Window/main.js | 6 ++++++ src/Shortcuts Window/main.py | 8 ++++++++ src/Shortcuts Window/main.vala | 10 ++++++++++ 4 files changed, 34 insertions(+) create mode 100644 src/Shortcuts Window/code.rs create mode 100644 src/Shortcuts Window/main.js create mode 100644 src/Shortcuts Window/main.py create mode 100644 src/Shortcuts Window/main.vala diff --git a/src/Shortcuts Window/code.rs b/src/Shortcuts Window/code.rs new file mode 100644 index 00000000..ab2c85b2 --- /dev/null +++ b/src/Shortcuts Window/code.rs @@ -0,0 +1,10 @@ +use crate::workbench; +use gtk::prelude::*; + +pub fn main() { + let shortcuts_window: gtk::ShortcutsWindow = + workbench::builder().object("shortcuts_window").unwrap(); + let button: gtk::Button = workbench::builder().object("button").unwrap(); + + button.connect_clicked(move |_| shortcuts_window.present()); +} \ No newline at end of file diff --git a/src/Shortcuts Window/main.js b/src/Shortcuts Window/main.js new file mode 100644 index 00000000..5a2bc4da --- /dev/null +++ b/src/Shortcuts Window/main.js @@ -0,0 +1,6 @@ +const shortcuts_window = workbench.builder.get_object("shortcuts_window"); +const button = workbench.builder.get_object("button"); + +button.connect("clicked", () => { + shortcuts_window.present(); +}); diff --git a/src/Shortcuts Window/main.py b/src/Shortcuts Window/main.py new file mode 100644 index 00000000..7c36c2a8 --- /dev/null +++ b/src/Shortcuts Window/main.py @@ -0,0 +1,8 @@ +import workbench + +shortcuts_window = workbench.builder.get_object("shortcuts_window") +button = workbench.builder.get_object("button") + +button.connect("clicked", lambda *_: shortcuts_window.present()) + + diff --git a/src/Shortcuts Window/main.vala b/src/Shortcuts Window/main.vala new file mode 100644 index 00000000..8bd21b8f --- /dev/null +++ b/src/Shortcuts Window/main.vala @@ -0,0 +1,10 @@ +#! /usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 + +public void main() { + var shortcuts_window = (Gtk.ShortcutsWindow) workbench.builder.get_object("shortcuts_window"); + var button = (Gtk.Button) workbench.builder.get_object("button"); + + button.clicked.connect(() => { + shortcuts_window.present(); + }); +} From 51b996c956b9d690d62a41510eb1aef5cf894ba2 Mon Sep 17 00:00:00 2001 From: Sudhanshu Tiwari Date: Sun, 2 Mar 2025 00:57:52 +0530 Subject: [PATCH 4/7] src: Improve formatting for main.py in Shortcuts Window --- src/Shortcuts Window/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Shortcuts Window/main.py b/src/Shortcuts Window/main.py index 7c36c2a8..122b0f26 100644 --- a/src/Shortcuts Window/main.py +++ b/src/Shortcuts Window/main.py @@ -4,5 +4,3 @@ button = workbench.builder.get_object("button") button.connect("clicked", lambda *_: shortcuts_window.present()) - - From d493cdce2b41d73a88e1f1e5d5448a766d19f90a Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sat, 8 Mar 2025 14:17:09 +0100 Subject: [PATCH 5/7] add hig --- src/Shortcuts Window/main.blp | 15 ++++++++++++--- src/Shortcuts Window/tsconfig.json | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/Shortcuts Window/tsconfig.json diff --git a/src/Shortcuts Window/main.blp b/src/Shortcuts Window/main.blp index 6f5666c0..74da3e00 100644 --- a/src/Shortcuts Window/main.blp +++ b/src/Shortcuts Window/main.blp @@ -19,9 +19,18 @@ Adw.StatusPage { ] } - LinkButton { - label: _("API Reference"); - uri: "https://docs.gtk.org/gtk4/class.ShortcutsWindow.html"; + Box { + orientation: vertical; + + LinkButton { + label: _("API Reference"); + uri: "https://docs.gtk.org/gtk4/class.ShortcutsWindow.html"; + } + + LinkButton { + label: _("Human Interface Guidelines"); + uri: "https://developer.gnome.org/hig/reference/keyboard.html"; + } } } } diff --git a/src/Shortcuts Window/tsconfig.json b/src/Shortcuts Window/tsconfig.json new file mode 100644 index 00000000..0279a931 --- /dev/null +++ b/src/Shortcuts Window/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "Bundler", + // TODO: should probably be fixed to ES2023, or whatever standard is + // currently supported by the latest GJS + "target": "ESNext", + "outDir": "compiled_javascript", + "baseUrl": ".", + "paths": { + "*": ["*", "/app/share/re.sonny.Workbench/langs/typescript/gi-types/*"] + }, + "skipLibCheck": true + }, + "include": [ + "main.ts", + "/app/share/re.sonny.Workbench/langs/typescript/types/ambient.d.ts", + "/app/share/re.sonny.Workbench/langs/typescript/gi-types/gi.d.ts" + ] +} From f7ad175aed67c441b8dd91ef2fe49992ab243e0b Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sat, 8 Mar 2025 14:18:03 +0100 Subject: [PATCH 6/7] f --- src/Shortcuts Window/tsconfig.json | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 src/Shortcuts Window/tsconfig.json diff --git a/src/Shortcuts Window/tsconfig.json b/src/Shortcuts Window/tsconfig.json deleted file mode 100644 index 0279a931..00000000 --- a/src/Shortcuts Window/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler", - // TODO: should probably be fixed to ES2023, or whatever standard is - // currently supported by the latest GJS - "target": "ESNext", - "outDir": "compiled_javascript", - "baseUrl": ".", - "paths": { - "*": ["*", "/app/share/re.sonny.Workbench/langs/typescript/gi-types/*"] - }, - "skipLibCheck": true - }, - "include": [ - "main.ts", - "/app/share/re.sonny.Workbench/langs/typescript/types/ambient.d.ts", - "/app/share/re.sonny.Workbench/langs/typescript/gi-types/gi.d.ts" - ] -} From c4b2881be907d183af9d13a142abd5a3012b3ed4 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sat, 8 Mar 2025 14:21:47 +0100 Subject: [PATCH 7/7] replace ctrl with primary --- src/Shortcuts Window/code.rs | 2 +- src/Shortcuts Window/main.blp | 42 +++++++++++++++++------------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Shortcuts Window/code.rs b/src/Shortcuts Window/code.rs index ab2c85b2..242ddd1e 100644 --- a/src/Shortcuts Window/code.rs +++ b/src/Shortcuts Window/code.rs @@ -7,4 +7,4 @@ pub fn main() { let button: gtk::Button = workbench::builder().object("button").unwrap(); button.connect_clicked(move |_| shortcuts_window.present()); -} \ No newline at end of file +} diff --git a/src/Shortcuts Window/main.blp b/src/Shortcuts Window/main.blp index 74da3e00..30c17fbc 100644 --- a/src/Shortcuts Window/main.blp +++ b/src/Shortcuts Window/main.blp @@ -46,52 +46,52 @@ Gtk.ShortcutsWindow shortcuts_window { title: _("Application"); Gtk.ShortcutsShortcut { - accelerator: "Return"; + accelerator: "Return"; title: _("Run Code"); } Gtk.ShortcutsShortcut { - accelerator: "Return"; + accelerator: "Return"; title: _("Format"); } Gtk.ShortcutsShortcut { - accelerator: "N"; + accelerator: "N"; title: _("New Project"); } Gtk.ShortcutsShortcut { - accelerator: "O"; + accelerator: "O"; title: _("Open Project"); } Gtk.ShortcutsShortcut { - accelerator: "O"; + accelerator: "O"; title: _("Open Library"); } Gtk.ShortcutsShortcut { - accelerator: "I"; + accelerator: "I"; title: _("Inspector"); } Gtk.ShortcutsShortcut { - accelerator: "W"; + accelerator: "W"; title: _("Close Window"); } Gtk.ShortcutsShortcut { - accelerator: "M"; + accelerator: "M"; title: _("Reveal in Files"); } Gtk.ShortcutsShortcut { - accelerator: "question"; + accelerator: "question"; title: _("Keyboard Shortcuts"); } Gtk.ShortcutsShortcut { - accelerator: "Q"; + accelerator: "Q"; title: _("Quit"); } } @@ -100,37 +100,37 @@ Gtk.ShortcutsWindow shortcuts_window { title: _("Editor"); Gtk.ShortcutsShortcut { - accelerator: "X"; + accelerator: "X"; title: _("Cut"); } Gtk.ShortcutsShortcut { - accelerator: "C"; + accelerator: "C"; title: _("Copy"); } Gtk.ShortcutsShortcut { - accelerator: "V"; + accelerator: "V"; title: _("Paste"); } Gtk.ShortcutsShortcut { - accelerator: "F"; + accelerator: "F"; title: _("Find"); } Gtk.ShortcutsShortcut { - accelerator: "Z"; + accelerator: "Z"; title: _("Undo"); } Gtk.ShortcutsShortcut { - accelerator: "space"; + accelerator: "space"; title: _("Show code suggestions"); } Gtk.ShortcutsShortcut { - accelerator: "Z"; + accelerator: "Z"; title: _("Redo"); } } @@ -139,22 +139,22 @@ Gtk.ShortcutsWindow shortcuts_window { title: _("Console"); Gtk.ShortcutsShortcut { - accelerator: "K"; + accelerator: "K"; title: _("Toggle Console"); } Gtk.ShortcutsShortcut { - accelerator: "C"; + accelerator: "C"; title: _("Copy"); } Gtk.ShortcutsShortcut { - accelerator: "A"; + accelerator: "A"; title: _("Select All"); } Gtk.ShortcutsShortcut { - accelerator: "K"; + accelerator: "K"; title: _("Clear"); } }