show warning message if podman and docker are not installed
Some checks failed
Publish Release / Publish binaries (push) Has been cancelled

This commit is contained in:
Dvlv 2024-09-27 18:29:51 +01:00
parent ea4382957e
commit fac9aad9b4
No known key found for this signature in database
GPG key ID: 1F4BD7220B7FDCFA
3 changed files with 42 additions and 3 deletions

View file

@ -40,6 +40,11 @@
<url type="help">https://dvlv.github.io/BoxBuddyRS</url> <url type="help">https://dvlv.github.io/BoxBuddyRS</url>
<releases> <releases>
<release version="2.2.13" date="2024-09-28">
<description>
<p>Added detection for a system without Podman or Docker</p>
</description>
</release>
<release version="2.2.12" date="2024-09-09"> <release version="2.2.12" date="2024-09-09">
<description> <description>
<p>Translation Updates</p> <p>Translation Updates</p>

View file

@ -28,7 +28,7 @@ use utils::{
get_download_dir_path, get_my_deb_boxes, get_my_rpm_boxes, get_rpm_distros, get_download_dir_path, get_my_deb_boxes, get_my_rpm_boxes, get_rpm_distros,
get_supported_terminals, get_supported_terminals_list, get_terminal_and_separator_arg, get_supported_terminals, get_supported_terminals_list, get_terminal_and_separator_arg,
has_distrobox_installed, has_file_extension, has_home_or_host_access, has_host_access, has_distrobox_installed, has_file_extension, has_home_or_host_access, has_host_access,
set_up_localisation, has_podman_or_docker_installed, set_up_localisation,
}; };
const APP_ID: &str = "io.github.dvlv.boxbuddyrs"; const APP_ID: &str = "io.github.dvlv.boxbuddyrs";
@ -100,7 +100,11 @@ fn make_window(app: &Application) -> ApplicationWindow {
window.set_child(Some(&toast_overlay)); window.set_child(Some(&toast_overlay));
if has_distrobox_installed() { if has_distrobox_installed() {
load_boxes(&scroll_area, &window, Some(0)); if has_podman_or_docker_installed() {
load_boxes(&scroll_area, &window, Some(0));
} else {
render_podman_not_installed(&scroll_area);
}
} else { } else {
render_not_installed(&scroll_area); render_not_installed(&scroll_area);
} }
@ -285,6 +289,21 @@ fn render_not_installed(scroll_area: &gtk::Box) {
scroll_area.append(&not_installed_lbl_two); scroll_area.append(&not_installed_lbl_two);
} }
fn render_podman_not_installed(scroll_area: &gtk::Box) {
// TRANSLATORS: Error message
let not_installed_lbl = gtk::Label::new(Some(&gettext("Podman / Docker not found!")));
not_installed_lbl.add_css_class("title-1");
// TRANSLATORS: Error message
let not_installed_lbl_two = gtk::Label::new(Some(&gettext(
"Could not find podman or docker, please install one of them!",
)));
not_installed_lbl_two.add_css_class("title-2");
scroll_area.append(&not_installed_lbl);
scroll_area.append(&not_installed_lbl_two);
}
fn load_boxes(scroll_area: &gtk::Box, window: &ApplicationWindow, active_page: Option<u32>) { fn load_boxes(scroll_area: &gtk::Box, window: &ApplicationWindow, active_page: Option<u32>) {
let tabs = Notebook::new(); let tabs = Notebook::new();
tabs.set_tab_pos(PositionType::Left); tabs.set_tab_pos(PositionType::Left);
@ -869,7 +888,7 @@ fn show_about_popup(window: &ApplicationWindow) {
let d = adw::AboutWindow::new(); let d = adw::AboutWindow::new();
d.set_transient_for(Some(window)); d.set_transient_for(Some(window));
d.set_application_name("BoxBuddy"); d.set_application_name("BoxBuddy");
d.set_version("2.2.12"); d.set_version("2.2.13");
d.set_developer_name("Dvlv"); d.set_developer_name("Dvlv");
d.set_license_type(gtk::License::MitX11); d.set_license_type(gtk::License::MitX11);
// TRANSLATORS: Description of the application // TRANSLATORS: Description of the application

View file

@ -226,6 +226,21 @@ pub fn has_distrobox_installed() -> bool {
true true
} }
/// Whether or not the `podman` or `docker` command can be successfully run
pub fn has_podman_or_docker_installed() -> bool {
let output = get_command_output("which", Some(&["podman"]));
if output.contains("no podman in") || output.is_empty() {
let docker_output = get_command_output("which", Some(&["docker"]));
if docker_output.contains("no docker in") || docker_output.is_empty() {
return false;
}
}
true
}
/// Returns a Vec of `TerminalOption`s representing all terminals supported by `BoxBuddy` /// Returns a Vec of `TerminalOption`s representing all terminals supported by `BoxBuddy`
pub fn get_supported_terminals() -> Vec<TerminalOption> { pub fn get_supported_terminals() -> Vec<TerminalOption> {
vec![ vec![