mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-12-18 14:06:30 +00:00
app: support cmd line to open a custom pipeline
Add a way to open a pipeline from the cmd line
This commit is contained in:
parent
30baa56881
commit
c5f9cac444
4 changed files with 137 additions and 24 deletions
96
Cargo.lock
generated
96
Cargo.lock
generated
|
@ -17,6 +17,15 @@ version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ansi_term"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.44"
|
version = "1.0.44"
|
||||||
|
@ -29,6 +38,17 @@ version = "0.1.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "73b5e5f48b927f04e952dedc932f31995a65a0bf65ec971c74436e51bf6e970d"
|
checksum = "73b5e5f48b927f04e952dedc932f31995a65a0bf65ec971c74436e51bf6e970d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atty"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"libc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -143,6 +163,21 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "2.34.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||||
|
dependencies = [
|
||||||
|
"ansi_term",
|
||||||
|
"atty",
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"strsim",
|
||||||
|
"textwrap",
|
||||||
|
"unicode-width",
|
||||||
|
"vec_map",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dtoa"
|
name = "dtoa"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
|
@ -541,6 +576,7 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_any",
|
"serde_any",
|
||||||
"simplelog",
|
"simplelog",
|
||||||
|
"structopt",
|
||||||
"xml-rs 0.8.4",
|
"xml-rs 0.8.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -734,6 +770,15 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.1.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
|
@ -1189,6 +1234,36 @@ version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
|
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strsim"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "structopt"
|
||||||
|
version = "0.3.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
"lazy_static",
|
||||||
|
"structopt-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "structopt-derive"
|
||||||
|
version = "0.4.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
|
||||||
|
dependencies = [
|
||||||
|
"heck 0.3.3",
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.80",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.80"
|
version = "1.0.80"
|
||||||
|
@ -1245,6 +1320,15 @@ dependencies = [
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.30"
|
version = "1.0.30"
|
||||||
|
@ -1342,6 +1426,12 @@ version = "1.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
|
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-width"
|
||||||
|
version = "0.1.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
@ -1359,6 +1449,12 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vec_map"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version-compare"
|
name = "version-compare"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -20,6 +20,7 @@ simplelog = "0.11.2"
|
||||||
futures-channel = "0.3"
|
futures-channel = "0.3"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
structopt = "0.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
futures-executor = "0.3"
|
futures-executor = "0.3"
|
||||||
|
|
27
src/app.rs
27
src/app.rs
|
@ -150,7 +150,7 @@ impl GPSApp {
|
||||||
.insert(paned_name.to_string(), paned.position());
|
.insert(paned_name.to_string(), paned.position());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_startup(application: >k::Application) {
|
pub fn on_startup(application: >k::Application, pipeline_desc: &String) {
|
||||||
// Create application and error out if that fails for whatever reason
|
// Create application and error out if that fails for whatever reason
|
||||||
let app = match GPSApp::new(application) {
|
let app = match GPSApp::new(application) {
|
||||||
Ok(app) => app,
|
Ok(app) => app,
|
||||||
|
@ -160,13 +160,7 @@ impl GPSApp {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// When the application is activated show the UI. This happens when the first process is
|
app.build_ui(application, pipeline_desc);
|
||||||
// started, and in the first process whenever a second process is started
|
|
||||||
let app_weak = app.downgrade();
|
|
||||||
application.connect_activate(glib::clone!(@weak application => move |_| {
|
|
||||||
let app = upgrade_weak!(app_weak);
|
|
||||||
app.build_ui(&application);
|
|
||||||
}));
|
|
||||||
|
|
||||||
let app_weak = app.downgrade();
|
let app_weak = app.downgrade();
|
||||||
let slider: gtk::Scale = app
|
let slider: gtk::Scale = app
|
||||||
|
@ -449,7 +443,7 @@ impl GPSApp {
|
||||||
notebook_preview.set_current_page(Some(n_video_sink as u32));
|
notebook_preview.set_current_page(Some(n_video_sink as u32));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_ui(&self, application: &Application) {
|
pub fn build_ui(&self, application: &Application, pipeline_desc: &String) {
|
||||||
graphbook::setup_graphbook(self);
|
graphbook::setup_graphbook(self);
|
||||||
graphbook::create_graphtab(self, 0, None);
|
graphbook::create_graphtab(self, 0, None);
|
||||||
|
|
||||||
|
@ -514,8 +508,9 @@ impl GPSApp {
|
||||||
&Settings::recent_pipeline_description(),
|
&Settings::recent_pipeline_description(),
|
||||||
&app,
|
&app,
|
||||||
move |app, pipeline_desc| {
|
move |app, pipeline_desc| {
|
||||||
app.load_pipeline(&pipeline_desc)
|
app.load_pipeline(&pipeline_desc).unwrap_or_else(|_| {
|
||||||
.unwrap_or_else(|_| GPS_ERROR!("Unable to open file {}", pipeline_desc));
|
GPS_ERROR!("Unable to open pipeline description {}", pipeline_desc)
|
||||||
|
});
|
||||||
Settings::set_recent_pipeline_description(&pipeline_desc);
|
Settings::set_recent_pipeline_description(&pipeline_desc);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -607,7 +602,7 @@ impl GPSApp {
|
||||||
GPSUI::elements::setup_favorite_list(self);
|
GPSUI::elements::setup_favorite_list(self);
|
||||||
// Setup the favorite list
|
// Setup the favorite list
|
||||||
GPSUI::elements::setup_elements_list(self);
|
GPSUI::elements::setup_elements_list(self);
|
||||||
|
if pipeline_desc.is_empty() {
|
||||||
let _ = self
|
let _ = self
|
||||||
.load_graph(
|
.load_graph(
|
||||||
Settings::graph_file_path()
|
Settings::graph_file_path()
|
||||||
|
@ -618,6 +613,11 @@ impl GPSApp {
|
||||||
.map_err(|_e| {
|
.map_err(|_e| {
|
||||||
GPS_WARN!("Unable to load default graph");
|
GPS_WARN!("Unable to load default graph");
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
self.load_pipeline(pipeline_desc).unwrap_or_else(|_| {
|
||||||
|
GPS_ERROR!("Unable to open pipeline description {}", pipeline_desc)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Downgrade to a weak reference
|
// Downgrade to a weak reference
|
||||||
|
@ -778,9 +778,10 @@ impl GPSApp {
|
||||||
|
|
||||||
fn load_pipeline(&self, pipeline_desc: &str) -> anyhow::Result<()> {
|
fn load_pipeline(&self, pipeline_desc: &str) -> anyhow::Result<()> {
|
||||||
let graphtab = graphbook::current_graphtab(self);
|
let graphtab = graphbook::current_graphtab(self);
|
||||||
|
let pd_parsed = pipeline_desc.replace('\\', "");
|
||||||
graphtab
|
graphtab
|
||||||
.player()
|
.player()
|
||||||
.graphview_from_pipeline_description(&graphtab.graphview(), pipeline_desc);
|
.graphview_from_pipeline_description(&graphtab.graphview(), &pd_parsed);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -22,14 +22,29 @@ use gtk::prelude::*;
|
||||||
|
|
||||||
use crate::app::GPSApp;
|
use crate::app::GPSApp;
|
||||||
use crate::common::init;
|
use crate::common::init;
|
||||||
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
#[derive(StructOpt, Debug)]
|
||||||
|
struct Command {
|
||||||
|
#[structopt(about = "Sets the pipeline description", default_value = "")]
|
||||||
|
pipeline: String,
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// gio::resources_register_include!("compiled.gresource").unwrap();
|
// gio::resources_register_include!("compiled.gresource").unwrap();
|
||||||
init().expect("Unable to init app");
|
init().expect("Unable to init app");
|
||||||
let application = gtk::Application::new(Some(config::APP_ID), Default::default());
|
let application = gtk::Application::new(
|
||||||
|
Some(config::APP_ID),
|
||||||
|
gtk::gio::ApplicationFlags::HANDLES_COMMAND_LINE,
|
||||||
|
);
|
||||||
application.connect_startup(|application| {
|
application.connect_startup(|application| {
|
||||||
GPSApp::on_startup(application);
|
let args = Command::from_args();
|
||||||
|
GPSApp::on_startup(application, &args.pipeline);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
application.connect_command_line(|_app, _cmd_line| {
|
||||||
|
// structopt already handled arguments
|
||||||
|
0
|
||||||
|
});
|
||||||
application.run();
|
application.run();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue