Skip to content

Commit 34eeb8e

Browse files
authored
Merge pull request #36 from ranfdev/next
Next
2 parents 6bb5300 + 3574d45 commit 34eeb8e

File tree

9 files changed

+315
-241
lines changed

9 files changed

+315
-241
lines changed

data/com.ranfdev.DistroShelf.metainfo.xml.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@
7171
</screenshots>
7272

7373
<releases>
74+
<release version="1.0.11" date="2025-07-01">
75+
<description translate="no">
76+
<ul>
77+
<li>Fix switch rows not working in creation dialog</li>
78+
<li>Auto select nvidia support if nvidia driver is installed</li>
79+
<li>Add tooltips on headerbar buttons to improve accessibility</li>
80+
<li>Install additional systemd package when init option is selected</li>
81+
<li>Refactor path resolution and command runner abstraction</li>
82+
</ul>
83+
</description>
84+
</release>
7485
<release version="1.0.10" date="2025-06-24">
7586
<description translate="no">
7687
<ul>

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project('distroshelf', 'rust',
2-
version: '1.0.10',
2+
version: '1.0.11',
33
meson_version: '>= 1.0.0',
44
default_options: [ 'warning_level=2', 'werror=false', ],
55
)

src/application.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ impl DistroShelfApplication {
259259
.developers(vec!["Lorenzo Miglietta"])
260260
// Translators: Replace "translator-credits" with your name/username, and optionally an email or URL.
261261
.translator_credits(gettext("translator-credits"))
262-
.copyright("© 2024 Lorenzo Miglietta")
262+
.copyright("© 2024 Lorenzo Miglietta.\nAll brand icons are trademarks of their respective owners")
263+
.comments(gettext("A distrobox management application."))
263264
.build();
264265

265266
about.present(Some(&window));

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub static VERSION: &str = "1.0.10";
1+
pub static VERSION: &str = "1.0.11";
22
pub static GETTEXT_PACKAGE: &str = "distroshelf";
33
pub static LOCALEDIR: &str = "/app/share/locale";
44
pub static PKGDATADIR: &str = "/app/share/distroshelf";

src/create_distrobox_dialog.rs

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,15 @@ mod imp {
122122
}
123123
));
124124

125-
let nvidia_row = adw::SwitchRow::new();
126-
nvidia_row.set_title("NVIDIA Support");
125+
self.nvidia_row.set_title("NVIDIA Support");
127126

128-
let init_row = adw::SwitchRow::new();
129-
init_row.set_title("Init process");
127+
self.init_row.set_title("Init process");
130128

131129
preferences_group.add(&self.name_row);
132130
preferences_group.add(&self.image_row);
133131
preferences_group.add(&self.home_row_expander);
134-
preferences_group.add(&nvidia_row);
135-
preferences_group.add(&init_row);
132+
preferences_group.add(&self.nvidia_row);
133+
preferences_group.add(&self.init_row);
136134

137135
let volumes_group = self.obj().build_volumes_group();
138136
gui_page.append(&preferences_group);
@@ -330,6 +328,20 @@ impl CreateDistroboxDialog {
330328
));
331329
this.root_store().images().reload();
332330

331+
glib::MainContext::ref_thread_default().spawn_local(clone!(
332+
#[weak]
333+
this,
334+
async move {
335+
this.root_store()
336+
.is_nvidia_host()
337+
.await
338+
.ok()
339+
.map(|is_nvidia| {
340+
this.imp().nvidia_row.set_active(is_nvidia);
341+
});
342+
}
343+
));
344+
333345
this
334346
}
335347

@@ -358,26 +370,25 @@ impl CreateDistroboxDialog {
358370
move |res: Result<File, _>| {
359371
if let Ok(file) = res {
360372
if let Some(path) = file.path() {
361-
362-
glib::MainContext::ref_thread_default().spawn_local(async move {
363-
match this
364-
.root_store()
365-
.resolve_host_path(&path.display().to_string())
366-
.await
367-
{
368-
Ok(resolved_path) => {
369-
row.set_subtitle(&resolved_path);
370-
cb(PathBuf::from(resolved_path));
371-
}
372-
373-
Err(e) => {
374-
this.update_errors::<()>(&Err(Error::InvalidField(
375-
title.to_lowercase(),
376-
e.to_string(),
377-
)));
373+
glib::MainContext::ref_thread_default().spawn_local(async move {
374+
match this
375+
.root_store()
376+
.resolve_host_path(&path.display().to_string())
377+
.await
378+
{
379+
Ok(resolved_path) => {
380+
row.set_subtitle(&resolved_path);
381+
cb(PathBuf::from(resolved_path));
382+
}
383+
384+
Err(e) => {
385+
this.update_errors::<()>(&Err(Error::InvalidField(
386+
title.to_lowercase(),
387+
e.to_string(),
388+
)));
389+
}
378390
}
379-
}
380-
});
391+
});
381392
}
382393
}
383394
}
@@ -428,21 +439,11 @@ impl CreateDistroboxDialog {
428439

429440
let name = CreateArgName::new(&imp.name_row.text())?;
430441

431-
dbg!(&self.home_folder());
432442
let create_args = CreateArgs {
433443
name,
434444
image: image.to_string(),
435445
nvidia: imp.nvidia_row.is_active(),
436-
home_path: if let Some(home) = self.home_folder() {
437-
Some(
438-
self.root_store()
439-
.resolve_host_path(&home)
440-
.await
441-
.map_err(|e| Error::InvalidField("home".to_string(), e.to_string()))?,
442-
)
443-
} else {
444-
None
445-
},
446+
home_path: self.home_folder(),
446447
init: imp.init_row.is_active(),
447448
volumes,
448449
};

src/distrobox/mod.rs

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1+
use crate::fakers::{
2+
Child, Command, CommandRunner, FdMode, InnerCommandRunner, NullCommandRunnerBuilder,
3+
};
14
use std::{
2-
cell::LazyCell, collections::BTreeMap, future::Future, io, path::{Path, PathBuf}, pin::Pin, process::Output, rc::Rc, str::FromStr
5+
cell::LazyCell,
6+
collections::BTreeMap,
7+
future::Future,
8+
io,
9+
path::{Path, PathBuf},
10+
pin::Pin,
11+
process::Output,
12+
rc::Rc,
13+
str::FromStr,
314
};
415
use tracing::{debug, error, info, warn};
5-
use crate::fakers::{CommandRunner, NullCommandRunnerBuilder, Command, Child, InnerCommandRunner, FdMode};
616

717
mod desktop_file;
818

919
pub use desktop_file::*;
1020

11-
1221
#[derive(Clone)]
1322
pub struct FlatpakCommandRunner {
1423
pub command_runner: Rc<dyn InnerCommandRunner>,
@@ -40,7 +49,6 @@ impl InnerCommandRunner for FlatpakCommandRunner {
4049
}
4150
}
4251

43-
4452
pub struct Distrobox {
4553
cmd_runner: CommandRunner,
4654
}
@@ -468,14 +476,10 @@ impl DistroboxCommandRunnerResponse {
468476

469477
impl Distrobox {
470478
pub fn new(cmd_runner: CommandRunner) -> Self {
471-
Self {
472-
cmd_runner,
473-
}
479+
Self { cmd_runner }
474480
}
475481

476-
pub fn null_command_runner(
477-
responses: &[DistroboxCommandRunnerResponse],
478-
) -> CommandRunner {
482+
pub fn null_command_runner(responses: &[DistroboxCommandRunnerResponse]) -> CommandRunner {
479483
let mut builder = NullCommandRunnerBuilder::new();
480484
for res in responses {
481485
for (cmd, out) in res.clone().to_commands() {
@@ -700,7 +704,10 @@ impl Distrobox {
700704
));
701705
}
702706
let mut cmd = dbcmd();
703-
cmd.arg("assemble").arg("create").arg("--file").arg(file_path);
707+
cmd.arg("assemble")
708+
.arg("create")
709+
.arg("--file")
710+
.arg(file_path);
704711
self.cmd_spawn(cmd)
705712
}
706713

@@ -726,7 +733,9 @@ impl Distrobox {
726733
cmd.arg("--name").arg(args.name.0);
727734
}
728735
if args.init {
729-
cmd.arg("--init");
736+
cmd.arg("--init")
737+
.arg("--additional-packages")
738+
.arg("systemd");
730739
}
731740
if args.nvidia {
732741
cmd.arg("--nvidia");
@@ -883,12 +892,15 @@ d24405b14180 | ubuntu | Created | ghcr.io/ublue-os/ubun
883892
);
884893
assert_eq!(
885894
db.list().await?,
886-
BTreeMap::from_iter([("ubuntu".into(), ContainerInfo {
887-
id: "d24405b14180".into(),
888-
name: "ubuntu".into(),
889-
status: Status::Created("".into()),
890-
image: "ghcr.io/ublue-os/ubuntu-toolbox:latest".into(),
891-
})])
895+
BTreeMap::from_iter([(
896+
"ubuntu".into(),
897+
ContainerInfo {
898+
id: "d24405b14180".into(),
899+
name: "ubuntu".into(),
900+
status: Status::Created("".into()),
901+
image: "ghcr.io/ublue-os/ubuntu-toolbox:latest".into(),
902+
}
903+
)])
892904
);
893905
Ok(())
894906
})
@@ -986,8 +998,11 @@ Categories=Utility;Network;
986998
..Default::default()
987999
};
9881000
smol::block_on(db.create(args))?;
989-
let expected = "distrobox create --yes --image docker.io/library/ubuntu:latest --init --nvidia --home /home/me --volume /mnt/sdb1:/mnt/sdb1 --volume /mnt/sdb4:/mnt/sdb4:ro";
990-
assert_eq!(output_tracker.items()[0].command().unwrap().to_string(), expected);
1001+
let expected = "distrobox create --yes --image docker.io/library/ubuntu:latest --init --additional-packages systemd --nvidia --home /home/me --volume /mnt/sdb1:/mnt/sdb1 --volume /mnt/sdb4:/mnt/sdb4:ro";
1002+
assert_eq!(
1003+
output_tracker.items()[0].command().unwrap().to_string(),
1004+
expected
1005+
);
9911006
Ok(())
9921007
}
9931008
#[test]

0 commit comments

Comments
 (0)