Skip to content

Commit 4e844f8

Browse files
committed
Add advanced create options and remove Ctrl+D/Ctrl+L shortcuts
1 parent 375717d commit 4e844f8

4 files changed

Lines changed: 35 additions & 17 deletions

File tree

data/gtk/shortcuts-dialog.ui

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
<property name="action-name">win.preferences</property>
1717
</object>
1818
</child>
19-
<child>
20-
<object class="AdwShortcutsItem">
21-
<property name="title" translatable="yes" context="shortcut window">Command Log</property>
22-
<property name="action-name">win.command-log</property>
23-
</object>
24-
</child>
2519
<child>
2620
<object class="AdwShortcutsItem">
2721
<property name="title" translatable="yes" context="shortcut window">Quit</property>
@@ -51,12 +45,6 @@
5145
<property name="action-name">win.upgrade-all</property>
5246
</object>
5347
</child>
54-
<child>
55-
<object class="AdwShortcutsItem">
56-
<property name="title" translatable="yes" context="shortcut window">Clone Container</property>
57-
<property name="action-name">win.clone-container</property>
58-
</object>
59-
</child>
6048
<child>
6149
<object class="AdwShortcutsItem">
6250
<property name="title" translatable="yes" context="shortcut window">Stop Container</property>

src/application.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ mod imp {
8888
obj.set_accels_for_action("win.upgrade-all", &["<primary><shift>u"]);
8989
obj.set_accels_for_action("win.install-package", &["<primary>i"]);
9090
obj.set_accels_for_action("win.preferences", &["<primary>comma"]);
91-
obj.set_accels_for_action("win.command-log", &["<primary>l"]);
9291
obj.set_accels_for_action("win.open-terminal", &["<primary>period"]);
93-
obj.set_accels_for_action("win.clone-container", &["<primary>d"]);
9492
obj.set_accels_for_action("win.view-exportable-apps", &["<primary>e"]);
9593
obj.set_accels_for_action("win.delete-container", &["<primary>Delete"]);
9694
obj.set_accels_for_action("win.stop-container", &["<primary>s"]);

src/backends/distrobox/distrobox.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ impl CreateArgName {
240240
pub struct CreateArgs {
241241
pub init: bool,
242242
pub nvidia: bool,
243+
pub root: bool,
244+
pub hostname: Option<String>,
243245
pub home_path: Option<String>,
244246
pub image: String,
245247
pub name: CreateArgName,
@@ -1014,11 +1016,17 @@ impl Distrobox {
10141016
if !args.name.0.is_empty() {
10151017
cmd.arg("--name").arg(args.name.0);
10161018
}
1019+
if let Some(hostname) = args.hostname {
1020+
cmd.arg("--hostname").arg(hostname);
1021+
}
10171022
if args.init {
10181023
cmd.arg("--init")
10191024
.arg("--additional-packages")
10201025
.arg("systemd");
10211026
}
1027+
if args.root {
1028+
cmd.arg("--root");
1029+
}
10221030
if args.nvidia {
10231031
cmd.arg("--nvidia");
10241032
}
@@ -1355,6 +1363,8 @@ Categories=Utility;Security;";
13551363
image: "docker.io/library/ubuntu:latest".into(),
13561364
init: true,
13571365
nvidia: true,
1366+
root: true,
1367+
hostname: Some("my-host".into()),
13581368
home_path: Some("/home/me".into()),
13591369
volumes: vec![
13601370
Volume::from_str("/mnt/sdb1:/mnt/sdb1")?,
@@ -1363,7 +1373,7 @@ Categories=Utility;Security;";
13631373
..Default::default()
13641374
};
13651375
smol::block_on(db.create(args))?;
1366-
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";
1376+
let expected = "distrobox create --yes --image docker.io/library/ubuntu:latest --hostname my-host --init --additional-packages systemd --root --nvidia --home /home/me --volume /mnt/sdb1:/mnt/sdb1 --volume /mnt/sdb4:/mnt/sdb4:ro";
13671377
assert_eq!(
13681378
output_tracker.items()[0].command().unwrap().to_string(),
13691379
expected

src/dialogs/create_distrobox_dialog.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ mod imp {
5252
pub assemble_url: RefCell<Option<String>>,
5353
pub nvidia_row: adw::SwitchRow,
5454
pub init_row: adw::SwitchRow,
55+
pub hostname_row: adw::EntryRow,
56+
pub root_row: adw::SwitchRow,
5557
pub volume_rows: Rc<RefCell<Vec<adw::EntryRow>>>,
5658
pub scrolled_window: gtk::ScrolledWindow,
5759
#[property(get, set, nullable, construct_only)]
@@ -277,14 +279,24 @@ impl CreateDistroboxDialog {
277279

278280
imp.init_row.set_title(&gettext("Init process"));
279281

282+
imp.hostname_row.set_title(&gettext("Hostname"));
283+
284+
imp.root_row.set_title(&gettext("Privileged"));
285+
280286
preferences_group.add(&imp.name_row);
281287
preferences_group.add(&imp.image_row);
282288
preferences_group.add(&imp.home_row_expander);
283-
preferences_group.add(&imp.nvidia_row);
284-
preferences_group.add(&imp.init_row);
289+
290+
let advanced_group = adw::PreferencesGroup::new();
291+
advanced_group.set_title(&gettext("Advanced"));
292+
advanced_group.add(&imp.hostname_row);
293+
advanced_group.add(&imp.root_row);
294+
advanced_group.add(&imp.nvidia_row);
295+
advanced_group.add(&imp.init_row);
285296

286297
let volumes_group = self.build_volumes_group();
287298
content.append(&preferences_group);
299+
content.append(&advanced_group);
288300
content.append(&volumes_group);
289301

290302
let create_btn = self.build_create_btn();
@@ -927,13 +939,23 @@ impl CreateDistroboxDialog {
927939
.collect::<Result<Vec<_>, _>>()?;
928940

929941
let name = CreateArgName::new(&imp.name_row.text())?;
942+
let hostname = {
943+
let value = imp.hostname_row.text().trim().to_string();
944+
if value.is_empty() {
945+
None
946+
} else {
947+
Some(value)
948+
}
949+
};
930950

931951
let create_args = CreateArgs {
932952
name,
933953
image: image.to_string(),
934954
nvidia: imp.nvidia_row.is_active(),
935955
home_path: self.home_folder(),
936956
init: imp.init_row.is_active(),
957+
hostname,
958+
root: imp.root_row.is_active(),
937959
volumes,
938960
};
939961

0 commit comments

Comments
 (0)