mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-07-24 01:41:42 +00:00
feat: finished editable profiles; profile prop to pull or not on build; profile props to set alternate component repos
This commit is contained in:
parent
371f874e3b
commit
5382ff92d2
21 changed files with 418 additions and 112 deletions
|
@ -6,9 +6,10 @@ set -ev
|
||||||
|
|
||||||
GIT_URL=$1
|
GIT_URL=$1
|
||||||
REPO_DIR=$2
|
REPO_DIR=$2
|
||||||
|
DO_PULL=$3
|
||||||
|
|
||||||
_usage() {
|
_usage() {
|
||||||
echo "Usage: $0 GIT_URL REPO_DIR"
|
echo "Usage: $0 GIT_URL REPO_DIR [DO_PULL]"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,12 +21,19 @@ if [[ -z $GIT_URL ]]; then
|
||||||
_usage
|
_usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z $DO_PULL ]]; then
|
||||||
|
DO_PULL=1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -d "$REPO_DIR" ]]; then
|
if [[ -d "$REPO_DIR" ]]; then
|
||||||
if [[ ! -d "$REPO_DIR/.git" ]]; then
|
if [[ ! -d "$REPO_DIR/.git" ]]; then
|
||||||
echo "Error: $REPO_DIR exists but is not a git repository"
|
rmdir "$REPO_DIR"
|
||||||
exit 1
|
git clone "$GIT_URL" "$REPO_DIR" --recurse-submodules
|
||||||
|
else
|
||||||
|
if [[ "$DO_PULL" -eq 1 ]]; then
|
||||||
|
git -C "$REPO_DIR" pull
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
git -C "$REPO_DIR" pull
|
|
||||||
else
|
else
|
||||||
git clone "$GIT_URL" "$REPO_DIR" --recurse-submodules
|
git clone "$GIT_URL" "$REPO_DIR" --recurse-submodules
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -9,13 +9,22 @@ exit 1
|
||||||
#
|
#
|
||||||
# PREFIX=$2
|
# PREFIX=$2
|
||||||
#
|
#
|
||||||
# if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]]; then
|
# DO_PULL=$3
|
||||||
# echo "Usage: $0 REPO_DIR PREFIX"
|
#
|
||||||
|
# REPO_URL=$4
|
||||||
|
#
|
||||||
|
# if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]] || [[ -z $DO_PULL ]]; then
|
||||||
|
# echo "Usage: $0 REPO_DIR PREFIX DO_PULL [REPO_URL]"
|
||||||
# exit 1
|
# exit 1
|
||||||
# fi
|
# fi
|
||||||
#
|
#
|
||||||
# "$(dirname -- "$0")/_clone_or_pull.sh" "https://github.com/cntools/libsurvive" "$REPO_DIR"
|
# if [[ -z $REPO_URL ]]; then
|
||||||
|
# REPO_URL="https://gitlab.freedesktop.org/mateosss/basalt"
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# "$(dirname -- "$0")/_clone_or_pull.sh" "$REPO_URL" "$REPO_DIR" "$DO_PULL"
|
||||||
#
|
#
|
||||||
# cd "$REPO_DIR"
|
# cd "$REPO_DIR"
|
||||||
|
# rm -rf build
|
||||||
# mkdir -p build
|
# mkdir -p build
|
||||||
# cd build
|
# cd build
|
||||||
|
|
|
@ -6,14 +6,23 @@ REPO_DIR=$1
|
||||||
|
|
||||||
PREFIX=$2
|
PREFIX=$2
|
||||||
|
|
||||||
if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]]; then
|
DO_PULL=$3
|
||||||
echo "Usage: $0 REPO_DIR PREFIX"
|
|
||||||
|
REPO_URL=$4
|
||||||
|
|
||||||
|
if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]] || [[ -z $DO_PULL ]]; then
|
||||||
|
echo "Usage: $0 REPO_DIR PREFIX DO_PULL [REPO_URL]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"$(dirname -- "$0")/_clone_or_pull.sh" "https://github.com/cntools/libsurvive" "$REPO_DIR"
|
if [[ -z $REPO_URL ]]; then
|
||||||
|
REPO_URL="https://github.com/cntools/libsurvive"
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$(dirname -- "$0")/_clone_or_pull.sh" "$REPO_URL" "$REPO_DIR" "$DO_PULL"
|
||||||
|
|
||||||
cd "$REPO_DIR"
|
cd "$REPO_DIR"
|
||||||
|
rm -rf build
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
@ -23,6 +32,5 @@ cmake -DCMAKE_BUILD_TYPE=Release \
|
||||||
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
|
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
|
||||||
-DCMAKE_INSTALL_LIBDIR="${PREFIX}/lib" \
|
-DCMAKE_INSTALL_LIBDIR="${PREFIX}/lib" \
|
||||||
..
|
..
|
||||||
make clean
|
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
make install
|
make install
|
||||||
|
|
|
@ -8,14 +8,23 @@ REPO_DIR=$1
|
||||||
|
|
||||||
PREFIX=$2
|
PREFIX=$2
|
||||||
|
|
||||||
if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]]; then
|
DO_PULL=$3
|
||||||
echo "Usage: $0 REPO_DIR PREFIX"
|
|
||||||
|
REPO_URL=$4
|
||||||
|
|
||||||
|
if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]] || [[ -z $DO_PULL ]]; then
|
||||||
|
echo "Usage: $0 REPO_DIR PREFIX DO_PULL [REPO_URL]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"$(dirname -- "$0")/_clone_or_pull.sh" "https://gitlab.freedesktop.org/monado/monado" "$REPO_DIR"
|
if [[ -z $REPO_URL ]]; then
|
||||||
|
REPO_URL="https://gitlab.freedesktop.org/monado/monado"
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$(dirname -- "$0")/_clone_or_pull.sh" "$REPO_URL" "$REPO_DIR" "$DO_PULL"
|
||||||
|
|
||||||
cd "$REPO_DIR"
|
cd "$REPO_DIR"
|
||||||
|
rm -rf build
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
|
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
|
||||||
|
@ -25,6 +34,5 @@ cmake -DCMAKE_BUILD_TYPE=Release \
|
||||||
-DCMAKE_C_FLAGS="-Wl,-rpath ${PREFIX}/lib" \
|
-DCMAKE_C_FLAGS="-Wl,-rpath ${PREFIX}/lib" \
|
||||||
-DCMAKE_CXX_FLAGS="-Wl,-rpath ${PREFIX}/lib" \
|
-DCMAKE_CXX_FLAGS="-Wl,-rpath ${PREFIX}/lib" \
|
||||||
..
|
..
|
||||||
make clean
|
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
make install
|
make install
|
||||||
|
|
|
@ -6,9 +6,23 @@ set -ev
|
||||||
|
|
||||||
REPO_DIR=$1
|
REPO_DIR=$1
|
||||||
|
|
||||||
"$(dirname -- "$0")/_clone_or_pull.sh" "https://gitlab.com/znixian/OpenOVR.git" "$REPO_DIR"
|
DO_PULL=$2
|
||||||
|
|
||||||
|
REPO_URL=$3
|
||||||
|
|
||||||
|
if [[ -z $REPO_DIR ]] || [[ -z $DO_PULL ]]; then
|
||||||
|
echo "Usage: $0 REPO_DIR DO_PULL [REPO_URL]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $REPO_URL ]]; then
|
||||||
|
REPO_URL="https://gitlab.com/znixian/OpenOVR.git"
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$(dirname -- "$0")/_clone_or_pull.sh" "$REPO_URL" "$REPO_DIR" "$DO_PULL"
|
||||||
|
|
||||||
cd "$REPO_DIR"
|
cd "$REPO_DIR"
|
||||||
|
rm -rf build
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||||
|
|
|
@ -8,14 +8,23 @@ REPO_DIR=$1
|
||||||
|
|
||||||
PREFIX=$2
|
PREFIX=$2
|
||||||
|
|
||||||
if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]]; then
|
DO_PULL=$3
|
||||||
echo "Usage: $0 REPO_DIR PREFIX"
|
|
||||||
|
REPO_URL=$4
|
||||||
|
|
||||||
|
if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]] || [[ -z $DO_PULL ]]; then
|
||||||
|
echo "Usage: $0 REPO_DIR PREFIX DO_PULL [REPO_URL]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"$(dirname -- "$0")/_clone_or_pull.sh" "https://github.com/Meumeu/WiVRn" "$REPO_DIR"
|
if [[ -z $REPO_URL ]]; then
|
||||||
|
REPO_URL="https://github.com/Meumeu/WiVRn"
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$(dirname -- "$0")/_clone_or_pull.sh" "$REPO_URL" "$REPO_DIR" "$DO_PULL"
|
||||||
|
|
||||||
cd "$REPO_DIR"
|
cd "$REPO_DIR"
|
||||||
|
rm -rf build
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
cmake -B build-server -DCMAKE_BUILD_TYPE=Release \
|
cmake -B build-server -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
use expect_dialog::ExpectDialog;
|
use expect_dialog::ExpectDialog;
|
||||||
|
|
||||||
use crate::{constants::PKG_DATA_DIR, profile::Profile, runner::Runner};
|
use crate::{constants::PKG_DATA_DIR, profile::Profile, runner::Runner};
|
||||||
|
|
||||||
pub fn get_build_basalt_runner(profile: Profile) -> Runner {
|
pub fn get_build_basalt_runner(profile: Profile) -> Runner {
|
||||||
|
let mut args = vec![
|
||||||
|
profile
|
||||||
|
.basalt_path
|
||||||
|
.expect_dialog("Missing basalt path for given profile"),
|
||||||
|
profile.prefix,
|
||||||
|
match profile.pull_on_build {
|
||||||
|
true => "1".into(),
|
||||||
|
false => "0".into(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
if profile.basalt_repo.is_some() {
|
||||||
|
args.push(profile.basalt_repo.unwrap());
|
||||||
|
}
|
||||||
let runner = Runner::new(
|
let runner = Runner::new(
|
||||||
None,
|
None,
|
||||||
format!("{sysdata}/scripts/build_basalt.sh", sysdata = PKG_DATA_DIR),
|
format!("{sysdata}/scripts/build_basalt.sh", sysdata = PKG_DATA_DIR),
|
||||||
vec![
|
args,
|
||||||
profile
|
|
||||||
.basalt_path
|
|
||||||
.expect_dialog("Missing basalt path for given profile"),
|
|
||||||
profile.prefix,
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
runner
|
runner
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,27 @@
|
||||||
use crate::{profile::Profile, runner::Runner, constants::PKG_DATA_DIR};
|
use crate::{constants::PKG_DATA_DIR, profile::Profile, runner::Runner};
|
||||||
use expect_dialog::ExpectDialog;
|
use expect_dialog::ExpectDialog;
|
||||||
|
|
||||||
pub fn get_build_libsurvive_runner(profile: Profile) -> Runner {
|
pub fn get_build_libsurvive_runner(profile: Profile) -> Runner {
|
||||||
|
let mut args = vec![
|
||||||
|
profile
|
||||||
|
.libsurvive_path
|
||||||
|
.expect_dialog("Missing libsurvive path for given profile"),
|
||||||
|
profile.prefix,
|
||||||
|
match profile.pull_on_build {
|
||||||
|
true => "1".into(),
|
||||||
|
false => "0".into(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
if profile.libsurvive_repo.is_some() {
|
||||||
|
args.push(profile.libsurvive_repo.unwrap());
|
||||||
|
}
|
||||||
let runner = Runner::new(
|
let runner = Runner::new(
|
||||||
None,
|
None,
|
||||||
format!("{sysdata}/scripts/build_libsurvive.sh", sysdata = PKG_DATA_DIR),
|
format!(
|
||||||
vec![
|
"{sysdata}/scripts/build_libsurvive.sh",
|
||||||
profile
|
sysdata = PKG_DATA_DIR
|
||||||
.libsurvive_path
|
),
|
||||||
.expect_dialog("Missing libsurvive path for given profile"),
|
args,
|
||||||
profile.prefix,
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
runner
|
runner
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
use crate::{runner::Runner, profile::Profile, constants::PKG_DATA_DIR};
|
use crate::{constants::PKG_DATA_DIR, profile::Profile, runner::Runner};
|
||||||
|
|
||||||
pub fn get_build_monado_runner(profile: Profile) -> Runner {
|
pub fn get_build_monado_runner(profile: Profile) -> Runner {
|
||||||
|
let mut args = vec![
|
||||||
|
profile.xrservice_path,
|
||||||
|
profile.prefix,
|
||||||
|
match profile.pull_on_build {
|
||||||
|
true => "1".into(),
|
||||||
|
false => "0".into(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
if profile.xrservice_repo.is_some() {
|
||||||
|
args.push(profile.xrservice_repo.unwrap());
|
||||||
|
}
|
||||||
let runner = Runner::new(
|
let runner = Runner::new(
|
||||||
None,
|
None,
|
||||||
format!("{sysdata}/scripts/build_monado.sh", sysdata = PKG_DATA_DIR),
|
format!("{sysdata}/scripts/build_monado.sh", sysdata = PKG_DATA_DIR),
|
||||||
vec![
|
args,
|
||||||
profile.xrservice_path,
|
|
||||||
profile.prefix,
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
runner
|
runner
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,23 @@
|
||||||
use crate::{profile::Profile, runner::Runner, constants::PKG_DATA_DIR};
|
use crate::{constants::PKG_DATA_DIR, profile::Profile, runner::Runner};
|
||||||
|
|
||||||
pub fn get_build_opencomposite_runner(profile: Profile) -> Runner {
|
pub fn get_build_opencomposite_runner(profile: Profile) -> Runner {
|
||||||
|
let mut args = vec![
|
||||||
|
profile.opencomposite_path,
|
||||||
|
match profile.pull_on_build {
|
||||||
|
true => "1".into(),
|
||||||
|
false => "0".into(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
if profile.opencomposite_repo.is_some() {
|
||||||
|
args.push(profile.opencomposite_repo.unwrap());
|
||||||
|
}
|
||||||
let runner = Runner::new(
|
let runner = Runner::new(
|
||||||
None,
|
None,
|
||||||
format!("{sysdata}/scripts/build_opencomposite.sh", sysdata = PKG_DATA_DIR),
|
format!(
|
||||||
vec![
|
"{sysdata}/scripts/build_opencomposite.sh",
|
||||||
profile.opencomposite_path,
|
sysdata = PKG_DATA_DIR
|
||||||
]
|
),
|
||||||
|
args,
|
||||||
);
|
);
|
||||||
runner
|
runner
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
use crate::{profile::Profile, runner::Runner, constants::PKG_DATA_DIR};
|
use crate::{constants::PKG_DATA_DIR, profile::Profile, runner::Runner};
|
||||||
|
|
||||||
pub fn get_build_wivrn_runner(profile: Profile) -> Runner {
|
pub fn get_build_wivrn_runner(profile: Profile) -> Runner {
|
||||||
|
let mut args = vec![
|
||||||
|
profile.xrservice_path,
|
||||||
|
profile.prefix,
|
||||||
|
match profile.pull_on_build {
|
||||||
|
true => "1".into(),
|
||||||
|
false => "0".into(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
if profile.xrservice_repo.is_some() {
|
||||||
|
args.push(profile.xrservice_repo.unwrap());
|
||||||
|
}
|
||||||
let runner = Runner::new(
|
let runner = Runner::new(
|
||||||
None,
|
None,
|
||||||
format!("{sysdata}/scripts/build_wivrn.sh", sysdata = PKG_DATA_DIR),
|
format!("{sysdata}/scripts/build_wivrn.sh", sysdata = PKG_DATA_DIR),
|
||||||
vec![
|
args,
|
||||||
profile.xrservice_path,
|
|
||||||
profile.prefix,
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
runner
|
runner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,17 @@ pub struct Profile {
|
||||||
pub libsurvive_enabled: bool,
|
pub libsurvive_enabled: bool,
|
||||||
pub basalt_enabled: bool,
|
pub basalt_enabled: bool,
|
||||||
pub mercury_enabled: bool,
|
pub mercury_enabled: bool,
|
||||||
|
pub xrservice_repo: Option<String>,
|
||||||
|
pub opencomposite_repo: Option<String>,
|
||||||
|
pub libsurvive_repo: Option<String>,
|
||||||
|
pub basalt_repo: Option<String>,
|
||||||
|
pub mercury_repo: Option<String>,
|
||||||
pub environment: HashMap<String, String>,
|
pub environment: HashMap<String, String>,
|
||||||
/** Install prefix */
|
/** Install prefix */
|
||||||
pub prefix: String,
|
pub prefix: String,
|
||||||
pub can_be_built: bool,
|
pub can_be_built: bool,
|
||||||
pub editable: bool,
|
pub editable: bool,
|
||||||
|
pub pull_on_build: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Profile {
|
impl Display for Profile {
|
||||||
|
@ -89,6 +95,12 @@ impl Default for Profile {
|
||||||
data = get_data_dir()
|
data = get_data_dir()
|
||||||
),
|
),
|
||||||
can_be_built: true,
|
can_be_built: true,
|
||||||
|
pull_on_build: true,
|
||||||
|
xrservice_repo: None,
|
||||||
|
opencomposite_repo: None,
|
||||||
|
libsurvive_repo: None,
|
||||||
|
basalt_repo: None,
|
||||||
|
mercury_repo: None,
|
||||||
editable: true,
|
editable: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,8 +215,8 @@ mod tests {
|
||||||
mercury_enabled: false,
|
mercury_enabled: false,
|
||||||
environment: env,
|
environment: env,
|
||||||
prefix: String::from("/home/user/rex2prefix"),
|
prefix: String::from("/home/user/rex2prefix"),
|
||||||
can_be_built: true,
|
|
||||||
editable: true,
|
editable: true,
|
||||||
|
..Default::default()
|
||||||
};
|
};
|
||||||
let fpath = String::from("./target/testout/testprofile.json");
|
let fpath = String::from("./target/testout/testprofile.json");
|
||||||
p.dump_profile(&fpath);
|
p.dump_profile(&fpath);
|
||||||
|
|
|
@ -23,5 +23,6 @@ pub fn system_valve_index_profile() -> Profile {
|
||||||
prefix: SYSTEM_PREFIX.into(),
|
prefix: SYSTEM_PREFIX.into(),
|
||||||
can_be_built: false,
|
can_be_built: false,
|
||||||
editable: false,
|
editable: false,
|
||||||
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,6 @@ pub fn valve_index_profile() -> Profile {
|
||||||
prefix,
|
prefix,
|
||||||
can_be_built: true,
|
can_be_built: true,
|
||||||
editable: false,
|
editable: false,
|
||||||
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,5 +23,6 @@ pub fn wivrn_profile() -> Profile {
|
||||||
prefix,
|
prefix,
|
||||||
can_be_built: true,
|
can_be_built: true,
|
||||||
editable: false,
|
editable: false,
|
||||||
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
83
src/ui/factories/entry_row_factory.rs
Normal file
83
src/ui/factories/entry_row_factory.rs
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
use crate::ui::profile_editor::ProfileEditorMsg;
|
||||||
|
use adw::prelude::*;
|
||||||
|
use gtk::prelude::*;
|
||||||
|
use relm4::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct EntryModel {
|
||||||
|
key: String,
|
||||||
|
name: String,
|
||||||
|
value: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct EntryModelInit {
|
||||||
|
pub key: String,
|
||||||
|
pub name: String,
|
||||||
|
pub value: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum EntryModelMsg {
|
||||||
|
Changed(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum EntryModelOutMsg {
|
||||||
|
Changed(String, String),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[relm4::factory(pub)]
|
||||||
|
impl FactoryComponent for EntryModel {
|
||||||
|
type Init = EntryModelInit;
|
||||||
|
type Input = EntryModelMsg;
|
||||||
|
type Output = EntryModelOutMsg;
|
||||||
|
type CommandOutput = ();
|
||||||
|
type Widgets = EntryModelWidgets;
|
||||||
|
type ParentInput = ProfileEditorMsg;
|
||||||
|
type ParentWidget = adw::PreferencesGroup;
|
||||||
|
|
||||||
|
view! {
|
||||||
|
root = adw::EntryRow {
|
||||||
|
set_title: &self.name,
|
||||||
|
set_text: &self.value,
|
||||||
|
add_suffix: clear_btn = >k::Button {
|
||||||
|
set_icon_name: "edit-clear-symbolic",
|
||||||
|
set_tooltip_text: Some("Clear"),
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
add_css_class: "flat",
|
||||||
|
add_css_class: "circular",
|
||||||
|
connect_clicked[root] => move |_| {
|
||||||
|
root.set_text("");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
connect_changed[sender] => move |entry| {
|
||||||
|
sender.input_sender().emit(Self::Input::Changed(entry.text().to_string()));
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(&mut self, message: Self::Input, sender: FactorySender<Self>) {
|
||||||
|
match message {
|
||||||
|
Self::Input::Changed(val) => {
|
||||||
|
self.value = val.clone();
|
||||||
|
sender
|
||||||
|
.output_sender()
|
||||||
|
.emit(Self::Output::Changed(self.key.clone(), val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn forward_to_parent(output: Self::Output) -> Option<Self::ParentInput> {
|
||||||
|
Some(match output {
|
||||||
|
Self::Output::Changed(key, value) => ProfileEditorMsg::EntryChanged(key, value),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_model(init: Self::Init, index: &Self::Index, sender: FactorySender<Self>) -> Self {
|
||||||
|
Self {
|
||||||
|
key: init.key,
|
||||||
|
name: init.name,
|
||||||
|
value: init.value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
pub mod env_var_row_factory;
|
pub mod env_var_row_factory;
|
||||||
pub mod switch_row_factory;
|
pub mod switch_row_factory;
|
||||||
pub mod path_row_factory;
|
pub mod path_row_factory;
|
||||||
|
pub mod entry_row_factory;
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl FactoryComponent for PathModel {
|
||||||
set_valign: gtk::Align::Center,
|
set_valign: gtk::Align::Center,
|
||||||
add_css_class: "flat",
|
add_css_class: "flat",
|
||||||
add_css_class: "circular",
|
add_css_class: "circular",
|
||||||
set_icon_name: "edit-clear",
|
set_icon_name: "edit-clear-symbolic",
|
||||||
set_tooltip_text: Some("Clear Path"),
|
set_tooltip_text: Some("Clear Path"),
|
||||||
connect_clicked[sender] => move |_| {
|
connect_clicked[sender] => move |_| {
|
||||||
sender.input(Self::Input::Changed(None));
|
sender.input(Self::Input::Changed(None));
|
||||||
|
|
|
@ -261,6 +261,7 @@ impl SimpleComponent for MainView {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.clone()
|
.clone()
|
||||||
.set_selected(index);
|
.set_selected(index);
|
||||||
|
self.set_selected_profile(self.profiles.get(index as usize).unwrap().clone());
|
||||||
}
|
}
|
||||||
Self::Input::ProfileSelected(position) => {
|
Self::Input::ProfileSelected(position) => {
|
||||||
sender.output(MainViewOutMsg::ProfileSelected(
|
sender.output(MainViewOutMsg::ProfileSelected(
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use super::factories::{
|
use super::factories::{
|
||||||
|
entry_row_factory::{EntryModel, EntryModelInit},
|
||||||
env_var_row_factory::{EnvVarModel, EnvVarModelInit},
|
env_var_row_factory::{EnvVarModel, EnvVarModelInit},
|
||||||
path_row_factory::{PathModel, PathModelInit},
|
path_row_factory::{PathModel, PathModelInit},
|
||||||
switch_row_factory::{SwitchModel, SwitchModelInit},
|
switch_row_factory::{SwitchModel, SwitchModelInit},
|
||||||
|
@ -24,11 +25,15 @@ pub struct ProfileEditor {
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
type_row: adw::ComboRow,
|
type_row: adw::ComboRow,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
|
pull_on_build_switch: Option<gtk::Switch>,
|
||||||
|
#[tracker::do_not_track]
|
||||||
env_rows: FactoryVecDeque<EnvVarModel>,
|
env_rows: FactoryVecDeque<EnvVarModel>,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
switch_rows: FactoryVecDeque<SwitchModel>,
|
switch_rows: FactoryVecDeque<SwitchModel>,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
path_rows: FactoryVecDeque<PathModel>,
|
path_rows: FactoryVecDeque<PathModel>,
|
||||||
|
#[tracker::do_not_track]
|
||||||
|
repo_rows: FactoryVecDeque<EntryModel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -36,7 +41,7 @@ pub enum ProfileEditorMsg {
|
||||||
Present(Profile),
|
Present(Profile),
|
||||||
EnvVarChanged(String, String),
|
EnvVarChanged(String, String),
|
||||||
EnvVarDelete(String),
|
EnvVarDelete(String),
|
||||||
TextChanged(String, String),
|
EntryChanged(String, String),
|
||||||
PathChanged(String, Option<String>),
|
PathChanged(String, Option<String>),
|
||||||
SwitchChanged(String, bool),
|
SwitchChanged(String, bool),
|
||||||
ComboChanged(String, String),
|
ComboChanged(String, String),
|
||||||
|
@ -69,13 +74,25 @@ impl SimpleComponent for ProfileEditor {
|
||||||
},
|
},
|
||||||
add: mainpage = &adw::PreferencesPage {
|
add: mainpage = &adw::PreferencesPage {
|
||||||
add: maingrp = &adw::PreferencesGroup {
|
add: maingrp = &adw::PreferencesGroup {
|
||||||
set_title: "Profile Info",
|
set_title: "General",
|
||||||
model.name_row.clone(),
|
model.name_row.clone(),
|
||||||
model.type_row.clone(),
|
model.type_row.clone(),
|
||||||
|
adw::ActionRow {
|
||||||
|
set_title: "Update on Build",
|
||||||
|
add_suffix: pull_on_build_switch = >k::Switch {
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
connect_state_set[sender] => move |_, state| {
|
||||||
|
sender.input(Self::Input::SwitchChanged("pull_on_build".into(), state));
|
||||||
|
gtk::Inhibit(false)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
set_activatable_widget: Some(&pull_on_build_switch),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
add: model.env_rows.widget(),
|
add: model.env_rows.widget(),
|
||||||
add: model.switch_rows.widget(),
|
add: model.switch_rows.widget(),
|
||||||
add: model.path_rows.widget(),
|
add: model.path_rows.widget(),
|
||||||
|
add: model.repo_rows.widget(),
|
||||||
add: save_grp = &adw::PreferencesGroup {
|
add: save_grp = &adw::PreferencesGroup {
|
||||||
add: save_box = >k::Box {
|
add: save_box = >k::Box {
|
||||||
set_orientation: gtk::Orientation::Vertical,
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
@ -106,65 +123,106 @@ impl SimpleComponent for ProfileEditor {
|
||||||
|
|
||||||
self.type_row.set_selected(prof.xrservice_type.as_number());
|
self.type_row.set_selected(prof.xrservice_type.as_number());
|
||||||
|
|
||||||
self.env_rows.guard().clear();
|
self.pull_on_build_switch.as_ref().unwrap().set_active(prof.pull_on_build);
|
||||||
for (k, v) in p.environment.iter() {
|
|
||||||
self.env_rows.guard().push_back(EnvVarModelInit {
|
{
|
||||||
name: k.clone(),
|
let mut guard = self.env_rows.guard();
|
||||||
value: v.clone(),
|
guard.clear();
|
||||||
|
for (k, v) in p.environment.iter() {
|
||||||
|
guard.push_back(EnvVarModelInit {
|
||||||
|
name: k.clone(),
|
||||||
|
value: v.clone(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut guard = self.switch_rows.guard();
|
||||||
|
guard.clear();
|
||||||
|
guard.push_back(SwitchModelInit {
|
||||||
|
name: "Libsurvive".into(),
|
||||||
|
description: Some("Lighthouse based spacial tracking".into()),
|
||||||
|
key: "libsurvive_enabled".into(),
|
||||||
|
value: p.libsurvive_enabled,
|
||||||
|
});
|
||||||
|
guard.push_back(SwitchModelInit {
|
||||||
|
name: "Basalt".into(),
|
||||||
|
description: Some("Camera based SLAM tracking".into()),
|
||||||
|
key: "basalt_enabled".into(),
|
||||||
|
value: p.basalt_enabled,
|
||||||
|
});
|
||||||
|
guard.push_back(SwitchModelInit {
|
||||||
|
name: "Mercury".into(),
|
||||||
|
description: Some("Camera based hand tracking".into()),
|
||||||
|
key: "mercury_enabled".into(),
|
||||||
|
value: p.mercury_enabled,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
self.switch_rows.guard().clear();
|
{
|
||||||
self.switch_rows.guard().push_back(SwitchModelInit {
|
let mut guard = self.path_rows.guard();
|
||||||
name: "Libsurvive".into(),
|
guard.clear();
|
||||||
description: Some("Lighthouse based spacial tracking".into()),
|
guard.push_back(PathModelInit {
|
||||||
key: "libsurvive_enabled".into(),
|
name: "XR Service Path".into(),
|
||||||
value: p.libsurvive_enabled,
|
key: "xrservice_path".into(),
|
||||||
});
|
value: Some(p.xrservice_path),
|
||||||
self.switch_rows.guard().push_back(SwitchModelInit {
|
});
|
||||||
name: "Basalt".into(),
|
guard.push_back(PathModelInit {
|
||||||
description: Some("Camera based SLAM tracking".into()),
|
name: "OpenComposite Path".into(),
|
||||||
key: "basalt_enabled".into(),
|
key: "opencomposite_path".into(),
|
||||||
value: p.basalt_enabled,
|
value: Some(p.opencomposite_path),
|
||||||
});
|
});
|
||||||
self.switch_rows.guard().push_back(SwitchModelInit {
|
guard.push_back(PathModelInit {
|
||||||
name: "Mercury".into(),
|
name: "Libsurvive Path".into(),
|
||||||
description: Some("Camera based hand tracking".into()),
|
key: "libsurvive_path".into(),
|
||||||
key: "mercury_enabled".into(),
|
value: p.libsurvive_path,
|
||||||
value: p.mercury_enabled,
|
});
|
||||||
});
|
guard.push_back(PathModelInit {
|
||||||
|
name: "Basalt Path".into(),
|
||||||
|
key: "basalt_path".into(),
|
||||||
|
value: p.basalt_path,
|
||||||
|
});
|
||||||
|
guard.push_back(PathModelInit {
|
||||||
|
name: "Mercury Path".into(),
|
||||||
|
key: "mercury_path".into(),
|
||||||
|
value: p.mercury_path,
|
||||||
|
});
|
||||||
|
guard.push_back(PathModelInit {
|
||||||
|
name: "Install Prefix".into(),
|
||||||
|
key: "prefix".into(),
|
||||||
|
value: Some(p.prefix),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
self.path_rows.guard().clear();
|
{
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
let mut guard = self.repo_rows.guard();
|
||||||
name: "XR Service Path".into(),
|
guard.clear();
|
||||||
key: "xrservice_path".into(),
|
guard.push_back(EntryModelInit {
|
||||||
value: Some(p.xrservice_path),
|
key: "xrservice_repo".into(),
|
||||||
});
|
name: "XR Service Repo".into(),
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
value: p.xrservice_repo.unwrap_or("".into()),
|
||||||
name: "OpenComposite Path".into(),
|
});
|
||||||
key: "opencomposite_path".into(),
|
guard.push_back(EntryModelInit {
|
||||||
value: Some(p.opencomposite_path),
|
key: "opencomposite_repo".into(),
|
||||||
});
|
name: "OpenComposite Repo".into(),
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
value: p.opencomposite_repo.unwrap_or("".into()),
|
||||||
name: "Libsurvive Path".into(),
|
});
|
||||||
key: "libsurvive_path".into(),
|
guard.push_back(EntryModelInit {
|
||||||
value: p.libsurvive_path,
|
key: "libsurvive_repo".into(),
|
||||||
});
|
name: "Libsurvive Repo".into(),
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
value: p.libsurvive_repo.unwrap_or("".into()),
|
||||||
name: "Basalt Path".into(),
|
});
|
||||||
key: "basalt_path".into(),
|
guard.push_back(EntryModelInit {
|
||||||
value: p.basalt_path,
|
key: "basalt_repo".into(),
|
||||||
});
|
name: "Basalt Repo".into(),
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
value: p.basalt_repo.unwrap_or("".into()),
|
||||||
name: "Mercury Path".into(),
|
});
|
||||||
key: "mercury_path".into(),
|
guard.push_back(EntryModelInit {
|
||||||
value: p.mercury_path,
|
key: "mercury_repo".into(),
|
||||||
});
|
name: "Mercury Repo".into(),
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
value: p.mercury_repo.unwrap_or("".into()),
|
||||||
name: "Install Prefix".into(),
|
});
|
||||||
key: "prefix".into(),
|
}
|
||||||
value: Some(p.prefix),
|
|
||||||
});
|
|
||||||
|
|
||||||
self.set_profile(Some(prof.clone()));
|
self.set_profile(Some(prof.clone()));
|
||||||
|
|
||||||
|
@ -221,13 +279,44 @@ impl SimpleComponent for ProfileEditor {
|
||||||
"libsurvive_enabled" => prof.libsurvive_enabled = value,
|
"libsurvive_enabled" => prof.libsurvive_enabled = value,
|
||||||
"basalt_enabled" => prof.basalt_enabled = value,
|
"basalt_enabled" => prof.basalt_enabled = value,
|
||||||
"mercury_enabled" => prof.mercury_enabled = value,
|
"mercury_enabled" => prof.mercury_enabled = value,
|
||||||
|
"pull_on_build" => prof.pull_on_build = value,
|
||||||
_ => panic!("Unknown profile switch key"),
|
_ => panic!("Unknown profile switch key"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Input::TextChanged(key, value) => {
|
Self::Input::EntryChanged(key, value) => {
|
||||||
let prof = self.profile.as_mut().unwrap();
|
let prof = self.profile.as_mut().unwrap();
|
||||||
match key.as_str() {
|
match key.as_str() {
|
||||||
"name" => prof.name = value,
|
"name" => prof.name = value,
|
||||||
|
"xrservice_repo" => {
|
||||||
|
prof.xrservice_repo = match value.trim() {
|
||||||
|
"" => None,
|
||||||
|
s => Some(s.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"opencomposite_repo" => {
|
||||||
|
prof.opencomposite_repo = match value.trim() {
|
||||||
|
"" => None,
|
||||||
|
s => Some(s.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"libsurvive_repo" => {
|
||||||
|
prof.libsurvive_repo = match value.trim() {
|
||||||
|
"" => None,
|
||||||
|
s => Some(s.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"basalt_repo" => {
|
||||||
|
prof.basalt_repo = match value.trim() {
|
||||||
|
"" => None,
|
||||||
|
s => Some(s.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"mercury_repo" => {
|
||||||
|
prof.mercury_repo = match value.trim() {
|
||||||
|
"" => None,
|
||||||
|
s => Some(s.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => panic!("Unknown profile text key"),
|
_ => panic!("Unknown profile text key"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,6 +404,7 @@ impl SimpleComponent for ProfileEditor {
|
||||||
.as_slice(),
|
.as_slice(),
|
||||||
))
|
))
|
||||||
.build(),
|
.build(),
|
||||||
|
pull_on_build_switch: None,
|
||||||
env_rows: FactoryVecDeque::new(
|
env_rows: FactoryVecDeque::new(
|
||||||
adw::PreferencesGroup::builder()
|
adw::PreferencesGroup::builder()
|
||||||
.title("Environment Variables")
|
.title("Environment Variables")
|
||||||
|
@ -337,13 +427,20 @@ impl SimpleComponent for ProfileEditor {
|
||||||
.build(),
|
.build(),
|
||||||
sender.input_sender(),
|
sender.input_sender(),
|
||||||
),
|
),
|
||||||
|
repo_rows: FactoryVecDeque::new(
|
||||||
|
adw::PreferencesGroup::builder()
|
||||||
|
.title("Repositories")
|
||||||
|
.description("Change the repositories from which various components are pulled.\n\nLeave empty to use the default repository.")
|
||||||
|
.build(),
|
||||||
|
sender.input_sender(),
|
||||||
|
),
|
||||||
tracker: 0,
|
tracker: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
let name_sender = sender.clone();
|
let name_sender = sender.clone();
|
||||||
model.name_row.connect_changed(move |nr| {
|
model.name_row.connect_changed(move |nr| {
|
||||||
name_sender.input(Self::Input::TextChanged(
|
name_sender.input(Self::Input::EntryChanged(
|
||||||
"name".to_string(),
|
"name".to_string(),
|
||||||
nr.text().to_string(),
|
nr.text().to_string(),
|
||||||
));
|
));
|
||||||
|
@ -366,6 +463,7 @@ impl SimpleComponent for ProfileEditor {
|
||||||
|
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
model.win = Some(widgets.win.clone());
|
model.win = Some(widgets.win.clone());
|
||||||
|
model.pull_on_build_switch = Some(widgets.pull_on_build_switch.clone());
|
||||||
|
|
||||||
ComponentParts { model, widgets }
|
ComponentParts { model, widgets }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"uuid": "demo",
|
||||||
"name": "Demo profile",
|
"name": "Demo profile",
|
||||||
"xrservice_path": "/home/user/monado",
|
"xrservice_path": "/home/user/monado",
|
||||||
"xrservice_type": "Monado",
|
"xrservice_type": "Monado",
|
||||||
|
@ -15,5 +16,12 @@
|
||||||
"SURVIVE_GLOBALSCENESOLVER": "0"
|
"SURVIVE_GLOBALSCENESOLVER": "0"
|
||||||
},
|
},
|
||||||
"prefix": "/home/user/rex2prefix",
|
"prefix": "/home/user/rex2prefix",
|
||||||
"can_be_built": true
|
"can_be_built": true,
|
||||||
|
"editable": true,
|
||||||
|
"pull_on_build": true,
|
||||||
|
"xrservice_repo": null,
|
||||||
|
"opencomposite_repo": null,
|
||||||
|
"libsurvive_repo": null,
|
||||||
|
"basalt_repo": null,
|
||||||
|
"mercury_repo": null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue