Skip to content

Commit fe9c7d2

Browse files
committed
Add VTE terminal
1 parent 1026dee commit fe9c7d2

14 files changed

+370
-94
lines changed

Cargo.lock

Lines changed: 160 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55

66
[dependencies]
77
gettext-rs = { version = "0.7", features = ["gettext-system"] }
8-
gtk = { version = "0.9", package = "gtk4", features = ["gnome_47"] }
8+
gtk = { version = "0.10", package = "gtk4", features = ["gnome_48"] }
99
thiserror = "1.0.64"
1010
async-channel = "2.3.1"
1111
async-process = "2.3.0"
@@ -16,11 +16,12 @@ 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"
1920

2021
[dependencies.adw]
2122
package = "libadwaita"
22-
version = "0.7.1"
23-
features = ["v1_7"]
23+
version = "0.8.0"
24+
features = ["v1_8"]
2425

2526
[dev-dependencies]
2627
smol = "2.0.2"

com.ranfdev.DistroShelf.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@
4343
"*.a"
4444
],
4545
"modules" : [
46+
{
47+
"name": "vte",
48+
"buildsystem": "meson",
49+
"config-opts": [
50+
"-Ddocs=false"
51+
],
52+
"sources": [
53+
{
54+
"type": "archive",
55+
"url": "https://download.gnome.org/sources/vte/0.82/vte-0.82.1.tar.xz",
56+
"sha256": "79376d70402d271e2d38424418e1aea72357934d272e321e3906b71706a78e3a"
57+
}
58+
]
59+
},
4660
{
4761
"name" : "distroshelf",
4862
"builddir" : true,

src/container.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ impl Container {
158158
self.set_status_detail(status_detail);
159159
}
160160

161+
pub fn is_running(&self) -> bool {
162+
self.status_tag() == "up"
163+
}
164+
161165
pub fn apps(&self) -> Query<TypedListStore<BoxedAnyObject>> {
162166
self.imp().apps.clone()
163167
}

src/dialogs/create_distrobox_dialog.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ mod imp {
5050
pub clone_sidebar: RefCell<Option<SidebarRow>>,
5151
pub cloning_content: gtk::Box,
5252
pub view_switcher: adw::InlineViewSwitcher,
53+
pub clone_warning_banner: adw::Banner,
5354
}
5455

5556
impl CreateDistroboxDialog {
@@ -69,11 +70,19 @@ mod imp {
6970
// insert at the top of the cloning_content box
7071
self.cloning_content.append(&sidebar_row);
7172
self.clone_sidebar.replace(Some(sidebar_row));
73+
74+
// Show warning if container is running
75+
if container.is_running() {
76+
self.clone_warning_banner.set_revealed(true);
77+
} else {
78+
self.clone_warning_banner.set_revealed(false);
79+
}
7280
} else {
7381
// no clone source, ensure image row is visible
7482
self.image_row.set_visible(true);
7583
self.cloning_content.set_visible(false);
7684
self.view_switcher.set_visible(true);
85+
self.clone_warning_banner.set_revealed(false);
7786
}
7887
}
7988
}
@@ -115,6 +124,12 @@ mod imp {
115124
cloning_header.append(&cloning_label);
116125

117126
self.cloning_content.append(&cloning_header);
127+
128+
// Add warning banner for running containers
129+
self.clone_warning_banner.set_title("Cloning the container requires stopping it first");
130+
self.clone_warning_banner.set_revealed(false);
131+
self.cloning_content.append(&self.clone_warning_banner);
132+
118133
self.content.append(&self.cloning_content);
119134

120135
let preferences_group = adw::PreferencesGroup::new();
@@ -204,6 +219,7 @@ mod imp {
204219
if let Ok(create_args) = res {
205220
// If cloning from a source, delegate to clone_container, otherwise create normally
206221
if let Some(src) = obj.clone_src() {
222+
src.stop();
207223
obj.root_store()
208224
.clone_container(&src.name(), create_args);
209225
} else {
@@ -366,7 +382,8 @@ mod imp {
366382

367383
glib::wrapper! {
368384
pub struct CreateDistroboxDialog(ObjectSubclass<imp::CreateDistroboxDialog>)
369-
@extends adw::Dialog, gtk::Widget;
385+
@extends adw::Dialog, gtk::Widget,
386+
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
370387
}
371388
impl CreateDistroboxDialog {
372389
pub fn new(root_store: RootStore) -> Self {

src/dialogs/exportable_apps_dialog.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ mod imp {
155155

156156
glib::wrapper! {
157157
pub struct ExportableAppsDialog(ObjectSubclass<imp::ExportableAppsDialog>)
158-
@extends adw::Dialog, gtk::Widget;
158+
@extends adw::Dialog, gtk::Widget,
159+
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
159160
}
160161
impl ExportableAppsDialog {
161162
/// Check if a binary exists on the host system

src/dialogs/preferences_dialog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ mod imp {
134134
glib::wrapper! {
135135
pub struct PreferencesDialog(ObjectSubclass<imp::PreferencesDialog>)
136136
@extends adw::PreferencesDialog, adw::Dialog, gtk::Widget,
137-
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
137+
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
138138
}
139139

140140
impl PreferencesDialog {

src/dialogs/task_manager_dialog.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ mod imp {
161161

162162
glib::wrapper! {
163163
pub struct TaskManagerDialog(ObjectSubclass<imp::TaskManagerDialog>)
164-
@extends adw::Dialog, gtk::Widget;
164+
@extends adw::Dialog, gtk::Widget,
165+
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
165166
}
166167

167168
impl TaskManagerDialog {

src/distro_combo_row_item.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ mod imp {
2929
self.label.set_xalign(0.0);
3030

3131
let obj = self.obj();
32+
obj.set_spacing(6);
3233
obj.append(&self.icon);
3334
obj.append(&self.label);
3435
}
@@ -47,7 +48,8 @@ mod imp {
4748

4849
glib::wrapper! {
4950
pub struct DistroComboRowItem(ObjectSubclass<imp::DistroComboRowItem>)
50-
@extends gtk::Box, gtk::Widget;
51+
@extends gtk::Box, gtk::Widget,
52+
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Actionable;
5153
}
5254
impl DistroComboRowItem {
5355
pub fn new() -> Self {

src/distrobox/mod.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,25 @@ impl FlatpakCommandRunner {
2828
pub fn new(command_runner: Rc<dyn InnerCommandRunner>) -> Self {
2929
FlatpakCommandRunner { command_runner }
3030
}
31-
32-
pub fn wrap_flatpak_cmd(mut prev: Command) -> Command {
33-
let mut args = vec!["--host".into(), prev.program];
34-
args.extend(prev.args);
35-
36-
prev.args = args;
37-
prev.program = "flatpak-spawn".into();
38-
prev
39-
}
4031
}
4132

4233
impl InnerCommandRunner for FlatpakCommandRunner {
34+
fn wrap_command(&self, mut command: Command) -> Command {
35+
let mut args = vec!["--host".into(), command.program];
36+
args.extend(command.args);
37+
38+
command.args = args;
39+
command.program = "flatpak-spawn".into();
40+
command
41+
}
4342
fn spawn(&self, command: Command) -> io::Result<Box<dyn Child + Send>> {
44-
self.command_runner.spawn(Self::wrap_flatpak_cmd(command))
43+
self.command_runner.spawn(self.wrap_command(command))
4544
}
4645
fn output(
4746
&self,
4847
command: Command,
4948
) -> Pin<Box<dyn Future<Output = io::Result<std::process::Output>>>> {
50-
self.command_runner.output(Self::wrap_flatpak_cmd(command))
49+
self.command_runner.output(self.wrap_command(command))
5150
}
5251
}
5352

0 commit comments

Comments
 (0)