Skip to content

Commit 1a3b8b3

Browse files
committed
Add terminal context menu
1 parent 32c94fe commit 1a3b8b3

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tracing = "0.1"
1616
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
1717
serde = { version = "1.0", features = ["derive"] }
1818
serde_json = "1.0.140"
19-
vte4 = "0.9"
19+
vte4 = { version = "0.9", features = ["v0_76"] }
2020

2121
[dependencies.adw]
2222
package = "libadwaita"

src/window.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,38 @@ impl DistroShelfWindow {
553553

554554
let terminal = vte4::Terminal::new();
555555

556+
// Create context menu actions
557+
let action_group = gio::SimpleActionGroup::new();
558+
559+
let copy_action = gio::SimpleAction::new("copy", None);
560+
copy_action.connect_activate(clone!(
561+
#[weak]
562+
terminal,
563+
move |_, _| {
564+
terminal.copy_clipboard_format(vte4::Format::Text);
565+
}
566+
));
567+
action_group.add_action(&copy_action);
568+
569+
let paste_action = gio::SimpleAction::new("paste", None);
570+
paste_action.connect_activate(clone!(
571+
#[weak]
572+
terminal,
573+
move |_, _| {
574+
terminal.paste_clipboard();
575+
}
576+
));
577+
action_group.add_action(&paste_action);
578+
579+
terminal.insert_action_group("terminal", Some(&action_group));
580+
581+
// Create context menu
582+
let menu_model = gio::Menu::new();
583+
menu_model.append(Some("Copy"), Some("terminal.copy"));
584+
menu_model.append(Some("Paste"), Some("terminal.paste"));
585+
586+
terminal.set_context_menu_model(Some(&menu_model));
587+
556588
// Create a container for the terminal with a reload button overlay
557589
let terminal_overlay = gtk::Overlay::new();
558590
terminal_overlay.set_child(Some(&terminal));

0 commit comments

Comments
 (0)