mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2025-02-16 10:35:16 +00:00
GPS: port to GTK4
This commit is contained in:
parent
b36fd0aebe
commit
25b2d1f8bf
6 changed files with 307 additions and 664 deletions
207
Cargo.lock
generated
207
Cargo.lock
generated
|
@ -8,30 +8,6 @@ version = "1.0.44"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1"
|
checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "atk"
|
|
||||||
version = "0.14.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a83b21d2aa75e464db56225e1bda2dd5993311ba1095acaa8fa03d1ae67026ba"
|
|
||||||
dependencies = [
|
|
||||||
"atk-sys",
|
|
||||||
"bitflags",
|
|
||||||
"glib 0.14.8",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "atk-sys"
|
|
||||||
version = "0.14.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "badcf670157c84bb8b1cf6b5f70b650fed78da2033c9eed84c4e49b11cbe83ea"
|
|
||||||
dependencies = [
|
|
||||||
"glib-sys 0.14.0",
|
|
||||||
"gobject-sys 0.14.0",
|
|
||||||
"libc",
|
|
||||||
"system-deps 3.2.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -77,6 +53,15 @@ dependencies = [
|
||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-expr"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "edae0b9625d1fce32f7d64b71784d9b1bf8469ec1a9c417e44aaf16a9cbd7571"
|
||||||
|
dependencies = [
|
||||||
|
"smallvec",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
@ -167,22 +152,6 @@ dependencies = [
|
||||||
"slab",
|
"slab",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gdk"
|
|
||||||
version = "0.14.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b9d749dcfc00d8de0d7c3a289e04a04293eb5ba3d8a4e64d64911d481fa9933b"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"cairo-rs",
|
|
||||||
"gdk-pixbuf",
|
|
||||||
"gdk-sys",
|
|
||||||
"gio",
|
|
||||||
"glib 0.14.8",
|
|
||||||
"libc",
|
|
||||||
"pango",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gdk-pixbuf"
|
name = "gdk-pixbuf"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
|
@ -209,20 +178,36 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gdk-sys"
|
name = "gdk4"
|
||||||
version = "0.14.0"
|
version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0e091b3d3d6696949ac3b3fb3c62090e5bfd7bd6850bef5c3c5ea701de1b1f1e"
|
checksum = "f97a162c17214d1bf981af3f683156a0b1667dd1927057c4f0a68513251ecf0f"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cairo-rs",
|
||||||
|
"gdk-pixbuf",
|
||||||
|
"gdk4-sys",
|
||||||
|
"gio",
|
||||||
|
"glib 0.14.8",
|
||||||
|
"libc",
|
||||||
|
"pango",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gdk4-sys"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9498f4e06969fb96a4e4234dfe1d308a3ac6b120b3c6d93e3ec5c77fe88bc6d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cairo-sys-rs",
|
"cairo-sys-rs",
|
||||||
"gdk-pixbuf-sys",
|
"gdk-pixbuf-sys",
|
||||||
"gio-sys",
|
"gio-sys",
|
||||||
"glib-sys 0.14.0",
|
"glib-sys 0.14.0",
|
||||||
"gobject-sys 0.14.0",
|
"gobject-sys 0.14.0",
|
||||||
|
"graphene-sys",
|
||||||
"libc",
|
"libc",
|
||||||
"pango-sys",
|
"pango-sys",
|
||||||
"pkg-config",
|
"system-deps 5.0.0",
|
||||||
"system-deps 3.2.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -366,13 +351,68 @@ dependencies = [
|
||||||
"system-deps 3.2.0",
|
"system-deps 3.2.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "graphene-rs"
|
||||||
|
version = "0.14.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e3380f132530ef9eb9e0a2bac180e30390aa5e49892d20294f822a974117a563"
|
||||||
|
dependencies = [
|
||||||
|
"glib 0.14.8",
|
||||||
|
"graphene-sys",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "graphene-sys"
|
||||||
|
version = "0.14.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a9ac7450b3aa80792513a3c029920a2ede419de13fb5169a4e51b07a5685332"
|
||||||
|
dependencies = [
|
||||||
|
"glib-sys 0.14.0",
|
||||||
|
"libc",
|
||||||
|
"pkg-config",
|
||||||
|
"system-deps 3.2.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gsk4"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eff59ca46c4fc5087fd7a0c3770a71ea4b6e94f8c24c12e2c2e8538f9f6fd764"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cairo-rs",
|
||||||
|
"gdk4",
|
||||||
|
"glib 0.14.8",
|
||||||
|
"graphene-rs",
|
||||||
|
"gsk4-sys",
|
||||||
|
"libc",
|
||||||
|
"pango",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gsk4-sys"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "13aa53ce70234da02f9954339d988d5ab853d746a8f47a4ae17735ff873545b5"
|
||||||
|
dependencies = [
|
||||||
|
"cairo-sys-rs",
|
||||||
|
"gdk4-sys",
|
||||||
|
"glib-sys 0.14.0",
|
||||||
|
"gobject-sys 0.14.0",
|
||||||
|
"graphene-sys",
|
||||||
|
"libc",
|
||||||
|
"pango-sys",
|
||||||
|
"system-deps 5.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gst_pipeline_studio"
|
name = "gst_pipeline_studio"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gstreamer",
|
"gstreamer",
|
||||||
"gtk",
|
"gtk4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -412,54 +452,37 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gtk"
|
name = "gtk4"
|
||||||
version = "0.14.3"
|
version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2eb51122dd3317e9327ec1e4faa151d1fa0d95664cd8fb8dcfacf4d4d29ac70c"
|
checksum = "58a04f421d1485ba4739e723199f5828bca05ab4e622ed39a96a342b6b1a6a3d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atk",
|
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cairo-rs",
|
"cairo-rs",
|
||||||
"field-offset",
|
"field-offset",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"gdk",
|
|
||||||
"gdk-pixbuf",
|
"gdk-pixbuf",
|
||||||
|
"gdk4",
|
||||||
"gio",
|
"gio",
|
||||||
"glib 0.14.8",
|
"glib 0.14.8",
|
||||||
"gtk-sys",
|
"graphene-rs",
|
||||||
"gtk3-macros",
|
"gsk4",
|
||||||
|
"gtk4-macros",
|
||||||
|
"gtk4-sys",
|
||||||
"libc",
|
"libc",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"pango",
|
"pango",
|
||||||
"pkg-config",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gtk-sys"
|
name = "gtk4-macros"
|
||||||
version = "0.14.0"
|
version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8c14c8d3da0545785a7c5a120345b3abb534010fb8ae0f2ef3f47c027fba303e"
|
checksum = "5068d4354af02454f44687adc613100aa98ae11e273cdcac84f89dc08be2b4a1"
|
||||||
dependencies = [
|
|
||||||
"atk-sys",
|
|
||||||
"cairo-sys-rs",
|
|
||||||
"gdk-pixbuf-sys",
|
|
||||||
"gdk-sys",
|
|
||||||
"gio-sys",
|
|
||||||
"glib-sys 0.14.0",
|
|
||||||
"gobject-sys 0.14.0",
|
|
||||||
"libc",
|
|
||||||
"pango-sys",
|
|
||||||
"system-deps 3.2.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gtk3-macros"
|
|
||||||
version = "0.14.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "21de1da96dc117443fb03c2e270b2d34b7de98d0a79a19bbb689476173745b79"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"heck",
|
"heck",
|
||||||
|
"itertools 0.10.1",
|
||||||
"proc-macro-crate 1.1.0",
|
"proc-macro-crate 1.1.0",
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -467,6 +490,25 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gtk4-sys"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e20a64c8f0ddcff8902ff04c130747f2fb7834a43530f75d03d6c71335733b49"
|
||||||
|
dependencies = [
|
||||||
|
"cairo-sys-rs",
|
||||||
|
"gdk-pixbuf-sys",
|
||||||
|
"gdk4-sys",
|
||||||
|
"gio-sys",
|
||||||
|
"glib-sys 0.14.0",
|
||||||
|
"gobject-sys 0.14.0",
|
||||||
|
"graphene-sys",
|
||||||
|
"gsk4-sys",
|
||||||
|
"libc",
|
||||||
|
"pango-sys",
|
||||||
|
"system-deps 5.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
@ -802,7 +844,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "480c269f870722b3b08d2f13053ce0c2ab722839f472863c3e2d61ff3a1c2fa6"
|
checksum = "480c269f870722b3b08d2f13053ce0c2ab722839f472863c3e2d61ff3a1c2fa6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cfg-expr",
|
"cfg-expr 0.8.1",
|
||||||
"heck",
|
"heck",
|
||||||
"itertools 0.10.1",
|
"itertools 0.10.1",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
|
@ -813,6 +855,19 @@ dependencies = [
|
||||||
"version-compare 0.0.11",
|
"version-compare 0.0.11",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "system-deps"
|
||||||
|
version = "5.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "18db855554db7bd0e73e06cf7ba3df39f97812cb11d3f75e71c39bf45171797e"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-expr 0.9.0",
|
||||||
|
"heck",
|
||||||
|
"pkg-config",
|
||||||
|
"toml",
|
||||||
|
"version-compare 0.0.11",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.30"
|
version = "1.0.30"
|
||||||
|
|
|
@ -6,6 +6,6 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gtk = "0.14.3"
|
gtk = { version = "0.3", package = "gtk4" }
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
gstreamer = "0.16"
|
gstreamer = "0.16"
|
||||||
|
|
|
@ -13,13 +13,13 @@ Check https://rustup.rs for alternative installation options.
|
||||||
### Ubuntu/Debian/etc
|
### Ubuntu/Debian/etc
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
apt install libgtk-3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
|
apt install libgtk-4-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Fedora/RedHat/SuSE/etc
|
### Fedora/RedHat/SuSE/etc
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
dnf install gtk3-devel gstreamer1-devel gstreamer1-plugins-base-devel
|
dnf install gtk4-devel gstreamer1-devel gstreamer1-plugins-base-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
131
src/app.rs
131
src/app.rs
|
@ -17,11 +17,11 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
use gtk::cairo::Context;
|
use gtk::cairo::Context;
|
||||||
use gtk::glib;
|
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
use gtk::{gio, glib};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
AboutDialog, AccelFlags, AccelGroup, ApplicationWindow, Builder, Button, DrawingArea, EventBox,
|
AboutDialog, Application, ApplicationWindow, Builder, Button, DrawingArea, FileChooserDialog,
|
||||||
FileChooserDialog, MenuItem, ResponseType, Viewport, WindowPosition,
|
ResponseType, Statusbar, Viewport,
|
||||||
};
|
};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
|
@ -79,8 +79,7 @@ impl GPSApp {
|
||||||
let builder = Builder::from_string(glade_src);
|
let builder = Builder::from_string(glade_src);
|
||||||
let window: ApplicationWindow = builder.object("mainwindow").expect("Couldn't get window");
|
let window: ApplicationWindow = builder.object("mainwindow").expect("Couldn't get window");
|
||||||
window.set_application(Some(application));
|
window.set_application(Some(application));
|
||||||
window.set_title("GstPipelineStudio");
|
window.set_title(Some("GstPipelineStudio"));
|
||||||
window.set_position(WindowPosition::Center);
|
|
||||||
window.set_size_request(800, 600);
|
window.set_size_request(800, 600);
|
||||||
let pipeline = Pipeline::new().expect("Unable to initialize the pipeline");
|
let pipeline = Pipeline::new().expect("Unable to initialize the pipeline");
|
||||||
let drawing_area = DrawingArea::new();
|
let drawing_area = DrawingArea::new();
|
||||||
|
@ -109,10 +108,11 @@ impl GPSApp {
|
||||||
// When the application is activated show the UI. This happens when the first process is
|
// When the application is activated show the UI. This happens when the first process is
|
||||||
// started, and in the first process whenever a second process is started
|
// started, and in the first process whenever a second process is started
|
||||||
let app_weak = app.downgrade();
|
let app_weak = app.downgrade();
|
||||||
application.connect_activate(move |_| {
|
|
||||||
|
application.connect_activate(glib::clone!(@weak application => move |_| {
|
||||||
let app = upgrade_weak!(app_weak);
|
let app = upgrade_weak!(app_weak);
|
||||||
app.build_ui();
|
app.build_ui(&application);
|
||||||
});
|
}));
|
||||||
|
|
||||||
let app_container = RefCell::new(Some(app));
|
let app_container = RefCell::new(Some(app));
|
||||||
application.connect_shutdown(move |_| {
|
application.connect_shutdown(move |_| {
|
||||||
|
@ -124,58 +124,74 @@ impl GPSApp {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_ui(&self) {
|
pub fn build_ui(&self, application: &Application) {
|
||||||
let view_port: Viewport = self
|
|
||||||
.builder
|
|
||||||
.object("drawing_area")
|
|
||||||
.expect("Couldn't get window");
|
|
||||||
let event_box = EventBox::new();
|
|
||||||
event_box.add(&self.drawing_area);
|
|
||||||
view_port.add(&event_box);
|
|
||||||
|
|
||||||
let app_weak = self.downgrade();
|
let app_weak = self.downgrade();
|
||||||
self.drawing_area.connect_draw(move |w, c| {
|
let drawing_area = gtk::DrawingArea::builder()
|
||||||
let app = upgrade_weak!(app_weak, gtk::Inhibit(false));
|
.content_height(24)
|
||||||
println!("w: {} c:{}", w, c);
|
.content_width(24)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
drawing_area.set_draw_func(move |_, c, width, height| {
|
||||||
|
let app = upgrade_weak!(app_weak);
|
||||||
|
println!("w: {} h: {} c:{}", width, height, c);
|
||||||
let mut graph = app.graph.borrow_mut();
|
let mut graph = app.graph.borrow_mut();
|
||||||
let elements = graph.elements();
|
let elements = graph.elements();
|
||||||
draw_elements(&elements, c);
|
draw_elements(&elements, c);
|
||||||
gtk::Inhibit(false)
|
c.paint().expect("Invalid cairo surface state");
|
||||||
});
|
|
||||||
let app_weak = self.downgrade();
|
|
||||||
event_box.connect_button_release_event(move |_w, evt| {
|
|
||||||
let app = upgrade_weak!(app_weak, gtk::Inhibit(false));
|
|
||||||
let mut element: Element = Default::default();
|
|
||||||
element.position.0 = evt.position().0;
|
|
||||||
element.position.1 = evt.position().1;
|
|
||||||
app.add_new_element(element);
|
|
||||||
app.drawing_area.queue_draw();
|
|
||||||
gtk::Inhibit(false)
|
|
||||||
});
|
});
|
||||||
|
let drawing_area_window: Viewport = self
|
||||||
|
.builder
|
||||||
|
.object("drawing_area")
|
||||||
|
.expect("Couldn't get window");
|
||||||
|
drawing_area_window.set_child(Some(&drawing_area));
|
||||||
|
|
||||||
|
// let app_weak = self.downgrade();
|
||||||
|
// event_box.connect_button_release_event(move |_w, evt| {
|
||||||
|
// let app = upgrade_weak!(app_weak, gtk::Inhibit(false));
|
||||||
|
// let mut element: Element = Default::default();
|
||||||
|
// element.position.0 = evt.position().0;
|
||||||
|
// element.position.1 = evt.position().1;
|
||||||
|
// app.add_new_element(element);
|
||||||
|
// app.drawing_area.queue_draw();
|
||||||
|
// gtk::Inhibit(false)
|
||||||
|
// });
|
||||||
let window = &self.window;
|
let window = &self.window;
|
||||||
|
|
||||||
window.show_all();
|
window.show();
|
||||||
|
let status_bar: Statusbar = self
|
||||||
|
.builder
|
||||||
|
.object("status_bar")
|
||||||
|
.expect("Couldn't get window");
|
||||||
|
status_bar.push(status_bar.context_id("Description"), "GPS is ready");
|
||||||
|
|
||||||
|
let action = gio::SimpleAction::new("quit", None);
|
||||||
|
action.connect_activate({
|
||||||
|
let app = application.downgrade();
|
||||||
|
move |_, _| {
|
||||||
|
let app = app.upgrade().unwrap();
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
application.add_action(&action);
|
||||||
|
application.set_accels_for_action("app.quit", &["<primary>q"]);
|
||||||
|
|
||||||
|
let action = gio::SimpleAction::new("new-window", None);
|
||||||
|
|
||||||
|
application.add_action(&action);
|
||||||
|
application.set_accels_for_action("app.new-window", &["<primary>n"]);
|
||||||
|
|
||||||
let quit: MenuItem = self
|
|
||||||
.builder
|
|
||||||
.object("menu-quit")
|
|
||||||
.expect("Couldn't get window");
|
|
||||||
let about: MenuItem = self
|
|
||||||
.builder
|
|
||||||
.object("menu-about")
|
|
||||||
.expect("Couldn't get window");
|
|
||||||
let about_dialog: AboutDialog = self
|
let about_dialog: AboutDialog = self
|
||||||
.builder
|
.builder
|
||||||
.object("dialog-about")
|
.object("dialog-about")
|
||||||
.expect("Couldn't get window");
|
.expect("Couldn't get window");
|
||||||
about.connect_activate(move |_| {
|
let action = gio::SimpleAction::new("about", None);
|
||||||
about_dialog.connect_delete_event(|dialog, _| {
|
action.connect_activate({
|
||||||
dialog.hide();
|
move |_, _| {
|
||||||
gtk::Inhibit(true)
|
about_dialog.show();
|
||||||
});
|
}
|
||||||
|
|
||||||
about_dialog.show_all();
|
|
||||||
});
|
});
|
||||||
|
application.add_action(&action);
|
||||||
|
application.set_accels_for_action("app.about", &["<primary>a"]);
|
||||||
|
|
||||||
// Create a dialog to select GStreamer elements.
|
// Create a dialog to select GStreamer elements.
|
||||||
let add_button: Button = self
|
let add_button: Button = self
|
||||||
|
@ -204,29 +220,16 @@ impl GPSApp {
|
||||||
("Open", ResponseType::Ok),
|
("Open", ResponseType::Ok),
|
||||||
("Cancel", ResponseType::Cancel)
|
("Cancel", ResponseType::Cancel)
|
||||||
]);
|
]);
|
||||||
open_dialog.set_select_multiple(true);
|
|
||||||
open_dialog.connect_response(|open_dialog, response| {
|
open_dialog.connect_response(|open_dialog, response| {
|
||||||
if response == ResponseType::Ok {
|
if response == ResponseType::Ok {
|
||||||
let files = open_dialog.filenames();
|
let file = open_dialog.file().expect("Couldn't get file");
|
||||||
println!("Files: {:?}", files);
|
println!("Files: {:?}", file);
|
||||||
}
|
}
|
||||||
open_dialog.close();
|
open_dialog.close();
|
||||||
});
|
});
|
||||||
open_dialog.show_all();
|
open_dialog.show();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let accel_group = AccelGroup::new();
|
|
||||||
window.add_accel_group(&accel_group);
|
|
||||||
|
|
||||||
quit.connect_activate(glib::clone!(@weak window => move |_| {
|
|
||||||
window.close();
|
|
||||||
}));
|
|
||||||
|
|
||||||
// `Primary` is `Ctrl` on Windows and Linux, and `command` on macOS
|
|
||||||
// It isn't available directly through `gdk::ModifierType`, since it has
|
|
||||||
// different values on different platforms.
|
|
||||||
let (key, modifier) = gtk::accelerator_parse("<Primary>Q");
|
|
||||||
quit.add_accelerator("activate", &accel_group, key, modifier, AccelFlags::VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Downgrade to a weak reference
|
// Downgrade to a weak reference
|
||||||
|
|
582
src/gps.ui
582
src/gps.ui
|
@ -1,590 +1,184 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Generated with glade 3.38.2 -->
|
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.24"/>
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<menu id="primary_menu">
|
||||||
|
<section>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes" comments="Primary menu entry that opens a new window.">_New Window</attribute>
|
||||||
|
<attribute name="action">app.new-window</attribute>
|
||||||
|
<attribute name="accel"><primary>n</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes" comments="Primary menu entry that opens the About dialog.">_About GstPipelineStudio</attribute>
|
||||||
|
<attribute name="action">app.about</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes" comments="Primary menu entry that quit app">_Quit GstPipelineStudio</attribute>
|
||||||
|
<attribute name="action">app.quit</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
|
</menu>
|
||||||
<object class="GtkAboutDialog" id="dialog-about">
|
<object class="GtkAboutDialog" id="dialog-about">
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="type-hint">dialog</property>
|
|
||||||
<property name="program-name">GstPipelineStudio</property>
|
<property name="program-name">GstPipelineStudio</property>
|
||||||
<property name="authors">Stéphane Cerveau</property>
|
<property name="authors">Stéphane Cerveau</property>
|
||||||
<property name="logo-icon-name">image-missing</property>
|
<property name="hide-on-close">True</property>
|
||||||
<child internal-child="vbox">
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">2</property>
|
|
||||||
<child internal-child="action_area">
|
|
||||||
<object class="GtkButtonBox">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="layout-style">end</property>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<object class="GtkFileChooserDialog" id="dialog-open-file">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="type-hint">dialog</property>
|
|
||||||
<child internal-child="vbox">
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">2</property>
|
|
||||||
<child internal-child="action_area">
|
|
||||||
<object class="GtkButtonBox">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="layout-style">end</property>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
<object class="GtkDialog" id="dialog-plugin-list">
|
<object class="GtkDialog" id="dialog-plugin-list">
|
||||||
<property name="can-focus">False</property>
|
<property name="transient-for">mainwindow</property>
|
||||||
<property name="default-width">320</property>
|
<property name="default-width">320</property>
|
||||||
<property name="default-height">260</property>
|
<property name="default-height">260</property>
|
||||||
<property name="type-hint">dialog</property>
|
<property name="hide-on-close">True</property>
|
||||||
<child internal-child="vbox">
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox" id="v_box">
|
||||||
<property name="can-focus">False</property>
|
<property name="orientation">horizontal</property>
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">2</property>
|
|
||||||
<child internal-child="action_area">
|
|
||||||
<object class="GtkButtonBox">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="layout-style">end</property>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkScrolledWindow" id="scrolled_window">
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="vexpand">True</property>
|
<property name="vexpand">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow">
|
<object class="GtkTreeView" id="treeview-plugin-list"/>
|
||||||
<property name="visible">True</property>
|
</child>
|
||||||
<property name="can-focus">True</property>
|
</object>
|
||||||
<property name="hexpand">True</property>
|
</child>
|
||||||
<property name="shadow-type">in</property>
|
<child>
|
||||||
<child>
|
<object class="GtkScrolledWindow" id="scrolled2_window">
|
||||||
<object class="GtkTreeView" id="treeview-plugin-list">
|
<property name="hexpand">True</property>
|
||||||
<property name="visible">True</property>
|
<property name="vexpand">True</property>
|
||||||
<property name="can-focus">True</property>
|
<child>
|
||||||
<child internal-child="selection">
|
<object class="GtkTextView" id="textview-plugin-list"/>
|
||||||
<object class="GtkTreeSelection"/>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkScrolledWindow">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="shadow-type">in</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkTextView" id="textview-plugin-list">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="editable">False</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkApplicationWindow" id="mainwindow">
|
<object class="GtkApplicationWindow" id="mainwindow">
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="border-width">6</property>
|
|
||||||
<property name="title" translatable="yes">GstPipelineStudio</property>
|
<property name="title" translatable="yes">GstPipelineStudio</property>
|
||||||
<property name="default-width">800</property>
|
<property name="default-width">800</property>
|
||||||
<property name="default-height">600</property>
|
<property name="default-height">600</property>
|
||||||
|
<child type="titlebar">
|
||||||
|
<object class="GtkHeaderBar" id="header-bar">
|
||||||
|
<property name="hexpand">0</property>
|
||||||
|
<property name="show-title-buttons">True</property>
|
||||||
|
<child type="start">
|
||||||
|
<object class="GtkButton">
|
||||||
|
<property name="action-name">win.open</property>
|
||||||
|
<property name="label">Open</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">1</property>
|
<property name="spacing">1</property>
|
||||||
<child>
|
|
||||||
<object class="GtkStatusbar">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="valign">end</property>
|
|
||||||
<property name="margin-left">10</property>
|
|
||||||
<property name="margin-right">10</property>
|
|
||||||
<property name="margin-start">10</property>
|
|
||||||
<property name="margin-end">10</property>
|
|
||||||
<property name="margin-top">6</property>
|
|
||||||
<property name="margin-bottom">6</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">2</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="pack-type">end</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkMenuBar" id="menu">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkMenuItem">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="label" translatable="yes">_File</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<child type="submenu">
|
|
||||||
<object class="GtkMenu">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="menu-new-graph">
|
|
||||||
<property name="label">gtk-new</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="menu-open-graph">
|
|
||||||
<property name="label">gtk-open</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="menu-save-graph">
|
|
||||||
<property name="label">gtk-save</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="menu-save-as-graph">
|
|
||||||
<property name="label">gtk-save-as</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSeparatorMenuItem">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="menu-quit">
|
|
||||||
<property name="label">gtk-quit</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkMenuItem">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="label" translatable="yes">_Graph</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<child type="submenu">
|
|
||||||
<object class="GtkMenu">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="menu-add-element">
|
|
||||||
<property name="label">gtk-add</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="menu-open-uri">
|
|
||||||
<property name="label">gtk-open</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSeparatorMenuItem">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem">
|
|
||||||
<property name="label">gtk-media-play</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem">
|
|
||||||
<property name="label">gtk-media-pause</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem">
|
|
||||||
<property name="label">gtk-media-stop</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem">
|
|
||||||
<property name="label">gtk-delete</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkMenuItem">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="label" translatable="yes">_Help</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<child type="submenu">
|
|
||||||
<object class="GtkMenu">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="menu-about">
|
|
||||||
<property name="label">gtk-about</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="use-underline">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="vexpand">0</property>
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="vexpand">False</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButtonBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="layout-style">start</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="button-add-plugin">
|
<object class="GtkButton" id="button-add-plugin">
|
||||||
|
<property name="hexpand">1</property>
|
||||||
<property name="label">gtk-add</property>
|
<property name="label">gtk-add</property>
|
||||||
<property name="visible">True</property>
|
<property name="receives-default">1</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="icon-name">list-add</property>
|
||||||
<property name="receives-default">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
<property name="always-show-image">True</property>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="button-open-file">
|
<object class="GtkButton" id="button-open-file">
|
||||||
|
<property name="hexpand">1</property>
|
||||||
<property name="label">gtk-open</property>
|
<property name="label">gtk-open</property>
|
||||||
<property name="visible">True</property>
|
<property name="receives-default">1</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="icon-name">document-open-symbolic</property>
|
||||||
<property name="receives-default">True</property>
|
|
||||||
<property name="use-stock">True</property>
|
|
||||||
<property name="always-show-image">True</property>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="button-play">
|
<object class="GtkButton" id="button-play">
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">1</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="receives-default">1</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="icon-name">media-playback-start-symbolic</property>
|
||||||
<property name="always-show-image">True</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="stock">gtk-media-play</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="button-pause">
|
<object class="GtkButton" id="button-pause">
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">1</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="receives-default">1</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="icon-name">media-playback-pause-symbolic</property>
|
||||||
<property name="always-show-image">True</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="stock">gtk-media-pause</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="button-stop">
|
<object class="GtkButton" id="button-stop">
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">1</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="receives-default">1</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="icon-name">media-playback-stop-symbolic</property>
|
||||||
<property name="always-show-image">True</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="stock">gtk-media-stop</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="button-clear">
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">1</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="receives-default">1</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="label">clear</property>
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="stock">gtk-clear</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">6</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScale">
|
<object class="GtkScale">
|
||||||
<property name="visible">True</property>
|
<property name="draw-value">1</property>
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="round-digits">1</property>
|
<property name="round-digits">1</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="vexpand">True</property>
|
<property name="vexpand">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow">
|
<object class="GtkScrolledWindow" id="drawing_area-window">
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="vexpand">True</property>
|
||||||
<property name="shadow-type">in</property>
|
<property name="child">
|
||||||
<child>
|
|
||||||
<object class="GtkViewport" id="drawing_area">
|
<object class="GtkViewport" id="drawing_area">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow">
|
<object class="GtkScrolledWindow">
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="vexpand">True</property>
|
||||||
<property name="shadow-type">in</property>
|
<property name="child">
|
||||||
<child>
|
|
||||||
<object class="GtkTreeView">
|
<object class="GtkTreeView">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<child internal-child="selection">
|
|
||||||
<object class="GtkTreeSelection"/>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeViewColumn">
|
<object class="GtkTreeViewColumn">
|
||||||
<property name="title" translatable="yes">column</property>
|
<property name="title" translatable="yes">column</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="pack-type">end</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow">
|
<object class="GtkScrolledWindow">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="valign">end</property>
|
<property name="valign">end</property>
|
||||||
<property name="shadow-type">in</property>
|
<property name="child">
|
||||||
<child>
|
<object class="GtkTreeView"/>
|
||||||
<object class="GtkTreeView">
|
</property>
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<child internal-child="selection">
|
|
||||||
<object class="GtkTreeSelection"/>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStatusbar" id="status_bar">
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
@ -20,15 +20,11 @@ use crate::app::GPSApp;
|
||||||
use crate::graph::Element;
|
use crate::graph::Element;
|
||||||
use crate::pipeline::ElementInfo;
|
use crate::pipeline::ElementInfo;
|
||||||
use crate::pipeline::Pipeline;
|
use crate::pipeline::Pipeline;
|
||||||
|
use gtk::prelude::*;
|
||||||
use gtk::TextBuffer;
|
use gtk::TextBuffer;
|
||||||
use gtk::{
|
use gtk::{gio, glib};
|
||||||
glib::{self, clone},
|
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use gtk::{
|
use gtk::{CellRendererText, Dialog, ListStore, TextView, TreeView, TreeViewColumn};
|
||||||
CellRendererText, Dialog, ListStore, TextView, TreeView, TreeViewColumn, WindowPosition,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn create_and_fill_model(elements: &[ElementInfo]) -> ListStore {
|
fn create_and_fill_model(elements: &[ElementInfo]) -> ListStore {
|
||||||
// Creation of a model with two rows.
|
// Creation of a model with two rows.
|
||||||
|
@ -41,6 +37,7 @@ fn create_and_fill_model(elements: &[ElementInfo]) -> ListStore {
|
||||||
&[(0, &(i as u32 + 1)), (1, &entry.name.as_ref().unwrap())],
|
&[(0, &(i as u32 + 1)), (1, &entry.name.as_ref().unwrap())],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
model
|
model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,37 +57,35 @@ pub fn display_plugin_list(app: &GPSApp, elements: &[ElementInfo]) {
|
||||||
.object("dialog-plugin-list")
|
.object("dialog-plugin-list")
|
||||||
.expect("Couldn't get window");
|
.expect("Couldn't get window");
|
||||||
|
|
||||||
dialog.set_title("Plugin list");
|
dialog.set_title(Some("Plugin list"));
|
||||||
dialog.set_position(WindowPosition::Center);
|
|
||||||
dialog.set_default_size(640, 480);
|
dialog.set_default_size(640, 480);
|
||||||
|
|
||||||
let tree: TreeView = app
|
|
||||||
.builder
|
|
||||||
.object("treeview-plugin-list")
|
|
||||||
.expect("Couldn't get window");
|
|
||||||
|
|
||||||
let text_view: TextView = app
|
let text_view: TextView = app
|
||||||
.builder
|
.builder
|
||||||
.object("textview-plugin-list")
|
.object("textview-plugin-list")
|
||||||
.expect("Couldn't get window");
|
.expect("Couldn't get window");
|
||||||
let text_buffer: TextBuffer = text_view
|
let text_buffer: TextBuffer = text_view.buffer();
|
||||||
.buffer()
|
|
||||||
.expect("Couldn't get buffer from text_view");
|
let tree: TreeView = app
|
||||||
|
.builder
|
||||||
|
.object("treeview-plugin-list")
|
||||||
|
.expect("Couldn't get window");
|
||||||
if tree.n_columns() < 2 {
|
if tree.n_columns() < 2 {
|
||||||
append_column(&tree, 0);
|
append_column(&tree, 0);
|
||||||
append_column(&tree, 1);
|
append_column(&tree, 1);
|
||||||
}
|
}
|
||||||
|
tree.set_search_column(1);
|
||||||
let model = create_and_fill_model(elements);
|
let model = create_and_fill_model(elements);
|
||||||
// Setting the model into the view.
|
// Setting the model into the view.
|
||||||
tree.set_model(Some(&model));
|
tree.set_model(Some(&model));
|
||||||
|
|
||||||
// The closure responds to selection changes by connection to "::cursor-changed" signal,
|
// The closure responds to selection changes by connection to "::cursor-changed" signal,
|
||||||
// that gets emitted when the cursor moves (focus changes).
|
// that gets emitted when the cursor moves (focus changes).
|
||||||
tree.connect_cursor_changed(clone!(@weak dialog, @weak text_buffer => move |tree_view| {
|
tree.connect_cursor_changed(glib::clone!(@weak dialog, @weak text_buffer => move |tree_view| {
|
||||||
let selection = tree_view.selection();
|
let selection = tree_view.selection();
|
||||||
if let Some((model, iter)) = selection.selected() {
|
if let Some((model, iter)) = selection.selected() {
|
||||||
let element_name = model
|
let element_name = model
|
||||||
.value(&iter, 1)
|
.get(&iter, 1)
|
||||||
.get::<String>()
|
.get::<String>()
|
||||||
.expect("Treeview selection, column 1");
|
.expect("Treeview selection, column 1");
|
||||||
let description = Pipeline::element_description(&element_name).expect("Unable to get element list from GStreamer");
|
let description = Pipeline::element_description(&element_name).expect("Unable to get element list from GStreamer");
|
||||||
|
@ -101,7 +96,7 @@ pub fn display_plugin_list(app: &GPSApp, elements: &[ElementInfo]) {
|
||||||
}));
|
}));
|
||||||
let app_weak = app.downgrade();
|
let app_weak = app.downgrade();
|
||||||
tree.connect_row_activated(
|
tree.connect_row_activated(
|
||||||
clone!(@weak dialog => move |tree_view, _tree_path, _tree_column| {
|
glib::clone!(@weak dialog => move |tree_view, _tree_path, _tree_column| {
|
||||||
let app = upgrade_weak!(app_weak);
|
let app = upgrade_weak!(app_weak);
|
||||||
let selection = tree_view.selection();
|
let selection = tree_view.selection();
|
||||||
if let Some((model, iter)) = selection.selected() {
|
if let Some((model, iter)) = selection.selected() {
|
||||||
|
@ -110,7 +105,7 @@ pub fn display_plugin_list(app: &GPSApp, elements: &[ElementInfo]) {
|
||||||
//
|
//
|
||||||
let element = Element {
|
let element = Element {
|
||||||
name: model
|
name: model
|
||||||
.value(&iter, 1)
|
.get(&iter, 1)
|
||||||
.get::<String>()
|
.get::<String>()
|
||||||
.expect("Treeview selection, column 1"),
|
.expect("Treeview selection, column 1"),
|
||||||
position: (100.0,100.0),
|
position: (100.0,100.0),
|
||||||
|
@ -118,7 +113,7 @@ pub fn display_plugin_list(app: &GPSApp, elements: &[ElementInfo]) {
|
||||||
};
|
};
|
||||||
|
|
||||||
let element_name = model
|
let element_name = model
|
||||||
.value(&iter, 1)
|
.get(&iter, 1)
|
||||||
.get::<String>()
|
.get::<String>()
|
||||||
.expect("Treeview selection, column 1");
|
.expect("Treeview selection, column 1");
|
||||||
app.add_new_element(element);
|
app.add_new_element(element);
|
||||||
|
@ -128,9 +123,5 @@ pub fn display_plugin_list(app: &GPSApp, elements: &[ElementInfo]) {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
dialog.connect_delete_event(|dialog, _| {
|
dialog.show();
|
||||||
dialog.hide();
|
|
||||||
gtk::Inhibit(true)
|
|
||||||
});
|
|
||||||
dialog.show_all();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue