Skip to content

Commit e29d20d

Browse files
committed
feat(preferences): default --no-entry on and clarify app-list visibility
1 parent 2b5a318 commit e29d20d

4 files changed

Lines changed: 45 additions & 0 deletions

File tree

data/com.ranfdev.DistroShelf.gschema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,10 @@
2121
<summary>Distrobox executable source</summary>
2222
<description>The source of the distrobox executable. Can be 'host' or 'bundled'.</description>
2323
</key>
24+
<key name="distrobox-create-no-entry" type="b">
25+
<default>true</default>
26+
<summary>Use --no-entry when creating a distrobox</summary>
27+
<description>When enabled, distrobox create commands include --no-entry by default.</description>
28+
</key>
2429
</schema>
2530
</schemalist>

src/backends/distrobox/distrobox.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ pub struct CreateArgs {
241241
pub init: bool,
242242
pub nvidia: bool,
243243
pub root: bool,
244+
pub no_entry: bool,
244245
pub hostname: Option<String>,
245246
pub home_path: Option<String>,
246247
pub image: String,
@@ -1024,6 +1025,9 @@ impl Distrobox {
10241025
if args.root {
10251026
cmd.arg("--root");
10261027
}
1028+
if args.no_entry {
1029+
cmd.arg("--no-entry");
1030+
}
10271031
if args.nvidia {
10281032
cmd.arg("--nvidia");
10291033
}
@@ -1377,6 +1381,24 @@ Categories=Utility;Security;";
13771381
);
13781382
Ok(())
13791383
}
1384+
1385+
#[test]
1386+
fn create_with_no_entry() -> Result<(), Error> {
1387+
let db = Distrobox::new(CommandRunner::new_null(), default_cmd_factory());
1388+
let output_tracker = db.cmd_runner.output_tracker();
1389+
let args = CreateArgs {
1390+
image: "docker.io/library/ubuntu:latest".into(),
1391+
no_entry: true,
1392+
..Default::default()
1393+
};
1394+
1395+
smol::block_on(db.create(args))?;
1396+
1397+
let command = output_tracker.items()[0].command().unwrap().to_string();
1398+
assert!(command.contains(" --no-entry"));
1399+
Ok(())
1400+
}
1401+
13801402
#[test]
13811403
fn assemble() -> Result<(), Error> {
13821404
let db = Distrobox::new(CommandRunner::new_null(), default_cmd_factory());

src/dialogs/create_distrobox_dialog.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,10 @@ impl CreateDistroboxDialog {
956956
init: imp.init_row.is_active(),
957957
hostname,
958958
root: imp.root_row.is_active(),
959+
no_entry: self
960+
.root_store()
961+
.settings()
962+
.boolean("distrobox-create-no-entry"),
959963
volumes,
960964
};
961965

src/dialogs/preferences_dialog.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,20 @@ mod imp {
166166

167167
distrobox_group.add(&distrobox_source_row);
168168

169+
let no_entry_row = adw::SwitchRow::new();
170+
no_entry_row.set_title(&gettext("Use --no-entry for new containers"));
171+
no_entry_row.set_subtitle(&gettext(
172+
"No .desktop app entry is created, so it won't appear in your app list.",
173+
));
174+
no_entry_row.set_active(settings.boolean("distrobox-create-no-entry"));
175+
176+
let settings_for_no_entry = settings.clone();
177+
no_entry_row.connect_active_notify(move |row| {
178+
let _ = settings_for_no_entry.set_boolean("distrobox-create-no-entry", row.is_active());
179+
});
180+
181+
distrobox_group.add(&no_entry_row);
182+
169183
// Add version row
170184
let version_row = adw::ActionRow::new();
171185
version_row.set_title(&gettext("Distrobox Version"));

0 commit comments

Comments
 (0)