split host and home access, put back window size on create popup
Some checks failed
Publish Release / Publish binaries (push) Has been cancelled
Some checks failed
Publish Release / Publish binaries (push) Has been cancelled
This commit is contained in:
parent
a9e4f7cdbd
commit
989566f758
2 changed files with 51 additions and 12 deletions
12
src/main.rs
12
src/main.rs
|
@ -19,7 +19,8 @@ use distrobox_handler::*;
|
||||||
mod utils;
|
mod utils;
|
||||||
use utils::{
|
use utils::{
|
||||||
get_assemble_icon, get_distro_img, get_supported_terminals_list,
|
get_assemble_icon, get_distro_img, get_supported_terminals_list,
|
||||||
get_terminal_and_separator_arg, has_distrobox_installed, has_host_access, set_up_localisation,
|
get_terminal_and_separator_arg, has_distrobox_installed, has_home_or_host_access,
|
||||||
|
has_host_access, set_up_localisation,
|
||||||
};
|
};
|
||||||
|
|
||||||
const APP_ID: &str = "io.github.dvlv.boxbuddyrs";
|
const APP_ID: &str = "io.github.dvlv.boxbuddyrs";
|
||||||
|
@ -103,7 +104,7 @@ fn make_titlebar(window: &ApplicationWindow) {
|
||||||
assemble_btn_clone.set_child(Some(&new_image));
|
assemble_btn_clone.set_child(Some(&new_image));
|
||||||
});
|
});
|
||||||
|
|
||||||
if has_host_access() {
|
if has_home_or_host_access() {
|
||||||
// TRANSLATORS: Button tooltip
|
// TRANSLATORS: Button tooltip
|
||||||
assemble_btn.set_tooltip_text(Some(&gettext("Assemble A Distrobox")));
|
assemble_btn.set_tooltip_text(Some(&gettext("Assemble A Distrobox")));
|
||||||
|
|
||||||
|
@ -150,7 +151,7 @@ fn make_titlebar(window: &ApplicationWindow) {
|
||||||
let titlebar = adw::HeaderBar::builder().title_widget(&title_lbl).build();
|
let titlebar = adw::HeaderBar::builder().title_widget(&title_lbl).build();
|
||||||
|
|
||||||
titlebar.pack_start(&add_btn);
|
titlebar.pack_start(&add_btn);
|
||||||
if has_host_access() {
|
if has_home_or_host_access() {
|
||||||
titlebar.pack_start(&assemble_btn);
|
titlebar.pack_start(&assemble_btn);
|
||||||
}
|
}
|
||||||
titlebar.pack_end(&about_btn);
|
titlebar.pack_end(&about_btn);
|
||||||
|
@ -391,6 +392,7 @@ fn create_new_distrobox(window: &ApplicationWindow) {
|
||||||
let new_box_popup = gtk::Window::new();
|
let new_box_popup = gtk::Window::new();
|
||||||
new_box_popup.set_transient_for(Some(window));
|
new_box_popup.set_transient_for(Some(window));
|
||||||
new_box_popup.set_modal(true);
|
new_box_popup.set_modal(true);
|
||||||
|
new_box_popup.set_default_size(700, 350);
|
||||||
|
|
||||||
// TRANSLATORS: Button Label
|
// TRANSLATORS: Button Label
|
||||||
let title_lbl = gtk::Label::new(Some(&gettext("Create New Distrobox")));
|
let title_lbl = gtk::Label::new(Some(&gettext("Create New Distrobox")));
|
||||||
|
@ -419,7 +421,7 @@ fn create_new_distrobox(window: &ApplicationWindow) {
|
||||||
new_box_titlebar.pack_end(&create_btn);
|
new_box_titlebar.pack_end(&create_btn);
|
||||||
new_box_titlebar.pack_start(&cancel_btn);
|
new_box_titlebar.pack_start(&cancel_btn);
|
||||||
|
|
||||||
if !has_host_access() {
|
if !has_home_or_host_access() {
|
||||||
new_box_titlebar.pack_end(&info_btn);
|
new_box_titlebar.pack_end(&info_btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,7 +591,7 @@ fn create_new_distrobox(window: &ApplicationWindow) {
|
||||||
boxed_list.append(&image_select_row);
|
boxed_list.append(&image_select_row);
|
||||||
boxed_list.append(&init_row);
|
boxed_list.append(&init_row);
|
||||||
|
|
||||||
if has_host_access() {
|
if has_home_or_host_access() {
|
||||||
boxed_list.append(&home_select_row);
|
boxed_list.append(&home_select_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
51
src/utils.rs
51
src/utils.rs
|
@ -5,6 +5,20 @@ use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
pub struct FilesystemAccess {
|
||||||
|
pub home: bool,
|
||||||
|
pub host: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FilesystemAccess {
|
||||||
|
fn new() -> Self {
|
||||||
|
FilesystemAccess {
|
||||||
|
home: false,
|
||||||
|
host: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run_command(
|
pub fn run_command(
|
||||||
cmd_to_run: std::string::String,
|
cmd_to_run: std::string::String,
|
||||||
args_for_cmd: Option<&[&str]>,
|
args_for_cmd: Option<&[&str]>,
|
||||||
|
@ -279,7 +293,8 @@ pub fn get_host_desktop_files() -> Vec<String> {
|
||||||
host_apps
|
host_apps
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_flatpak_filesystem_override() -> bool {
|
pub fn get_flatpak_filesystem_permissions() -> FilesystemAccess {
|
||||||
|
let mut access = FilesystemAccess::new();
|
||||||
// this will check for BoxBuddy installed as a system flatpak
|
// this will check for BoxBuddy installed as a system flatpak
|
||||||
let sys_output = get_command_output(
|
let sys_output = get_command_output(
|
||||||
String::from("flatpak"),
|
String::from("flatpak"),
|
||||||
|
@ -289,8 +304,14 @@ pub fn has_flatpak_filesystem_override() -> bool {
|
||||||
if line.starts_with("filesystems=") {
|
if line.starts_with("filesystems=") {
|
||||||
let fs_overrides = line.replace("filesystems=", "");
|
let fs_overrides = line.replace("filesystems=", "");
|
||||||
for ovr in fs_overrides.split(';') {
|
for ovr in fs_overrides.split(';') {
|
||||||
if ovr == "host" || ovr == "home" {
|
match ovr {
|
||||||
return true;
|
"host" => {
|
||||||
|
access.host = true;
|
||||||
|
}
|
||||||
|
"home" => {
|
||||||
|
access.home = true;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,19 +326,35 @@ pub fn has_flatpak_filesystem_override() -> bool {
|
||||||
if line.starts_with("filesystems=") {
|
if line.starts_with("filesystems=") {
|
||||||
let fs_overrides = line.replace("filesystems=", "");
|
let fs_overrides = line.replace("filesystems=", "");
|
||||||
for ovr in fs_overrides.split(';') {
|
for ovr in fs_overrides.split(';') {
|
||||||
if ovr == "host" || ovr == "home" {
|
match ovr {
|
||||||
return true;
|
"host" => {
|
||||||
|
access.host = true;
|
||||||
|
}
|
||||||
|
"home" => {
|
||||||
|
access.home = true;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
false
|
access
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_host_access() -> bool {
|
pub fn has_host_access() -> bool {
|
||||||
if is_flatpak() {
|
if is_flatpak() {
|
||||||
return has_flatpak_filesystem_override();
|
let access = get_flatpak_filesystem_permissions();
|
||||||
|
return access.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_home_or_host_access() -> bool {
|
||||||
|
if is_flatpak() {
|
||||||
|
let access = get_flatpak_filesystem_permissions();
|
||||||
|
return access.host || access.home;
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in a new issue