Compare commits

...

144 commits
0.2.2 ... main

Author SHA1 Message Date
Stéphane Cerveau 1f200f4f30 app: update to gtk 0.8.0 and gst 0.22.2
In the change, the glib::channel has been dropped to use
async_io which achieves the same to receive message
for the logger and display it in the treeview.
Another message is received when a new gtkpaintablesink
has been instanciated.
2024-03-14 16:34:55 +01:00
Stéphane Cerveau 44d64ccdc4 cargo: update gtk and gst crate
gtk4 0.7.3
gst 0.21.3
gst-plugins-gtk 0.11.3
2024-01-25 20:04:38 +01:00
Stéphane Cerveau 3985458832 properties: can now support ParamSpecFloat 2024-01-23 10:29:57 +01:00
Stéphane Cerveau 7a70feedba pages: update the pages with release 0.3.5 2024-01-05 16:34:13 +01:00
Stéphane Cerveau 88afa4a99e release: 0.3.5 2024-01-05 15:36:00 +01:00
Stéphane Cerveau d32c75b639 ci: change to macos 13 runner 2024-01-05 14:37:13 +01:00
Stéphane Cerveau 7789588aef ci: fix yaml issue detected by pre-commit 2024-01-05 11:25:03 +01:00
Stéphane Cerveau b1ad0e958b graphmanager: fix typos detected by pre-commit 2024-01-05 11:25:03 +01:00
Stéphane Cerveau 9c8a578e05 gps: fix typos and format detected by pre-commit 2024-01-05 11:25:03 +01:00
Stéphane Cerveau 3e15b7cecb graphmanager: remove link export 2024-01-05 11:25:03 +01:00
Stéphane Cerveau 11cf962bfd ci: add pre-commit job 2024-01-05 11:25:03 +01:00
Stéphane Cerveau a25f0499c8 macos: disabled ges build
Due to an error with python, disable GES build
for now.
2024-01-05 09:32:40 +01:00
Stéphane Cerveau 51769d6061 logger: support variable length for logger split 2024-01-04 15:20:14 +00:00
Stéphane Cerveau af317eee96 app: rename gst_pipeline_studio to gst-pipeline-studio 2024-01-04 14:32:17 +01:00
Stéphane Cerveau 3aded523c2 element: add property special case for float 2024-01-03 13:52:04 +01:00
Stéphane Cerveau d3005335b8 logger: add function name in the logs 2024-01-03 13:25:49 +01:00
Stéphane Cerveau 18458e3465 properties: fix expect for ParamSpecFlags 2024-01-03 13:25:49 +01:00
Stéphane Cerveau a6f03db8f6 element: element property special convert for enum and flags
In element_property, add special case enum and flags
property to use a better value such as nick or the
proper u32 flags
2024-01-03 13:25:49 +01:00
Stéphane Cerveau bed8d6a58e logger: fix clippy complain 2024-01-02 14:51:38 +01:00
Stéphane Cerveau c5f9cac444 app: support cmd line to open a custom pipeline
Add a way to open a pipeline from the cmd line
2024-01-02 14:51:03 +01:00
Stéphane Cerveau 30baa56881 wix: installer to a different UI profile
In order to remove minimal and full option
uses only a minimal profile.
2023-12-22 15:08:18 +01:00
Stéphane Cerveau 13165fa9c0 ci: use release build for windows
Create an image with release build of
gstreamer and gtk
2023-12-22 11:40:59 +01:00
Stéphane Cerveau 6ca3059914 ci: set the bundler version to 2.4.22 2023-12-19 11:20:56 +01:00
Stéphane Cerveau f4019fd2af wix: change wix banner and dialog bmp 2023-12-19 10:29:32 +01:00
Stéphane Cerveau 8c6cda2e92 player: feed the app with gst logs
Get the debug callback to retrieve the gst logs
and display it in the debug tab.
2023-11-30 11:54:15 +01:00
Stéphane Cerveau 9c03de5d00 player: keep a reference to bus_watch_guard
In order to receive the message from the bus
the API enforces to keep a reference to the bus_watch_guard
otherwise the watch gets lost.
2023-11-30 11:52:28 +01:00
Stéphane Cerveau 24121856ee app: use the channel to receive other logs
Add another logger to receive message, events or GST logs
2023-11-30 11:52:28 +01:00
Stéphane Cerveau e410289a13 ui: support multiple tab in debug section
Add GST logs, message, events in the debug section
2023-11-29 23:16:06 +01:00
Stéphane Cerveau 2601454143 Update README.md to include the website 2023-10-05 12:28:41 +00:00
Stéphane Cerveau f47b0624fd appdata: add a release description 2023-09-29 15:48:02 +02:00
Stéphane Cerveau b2c6a8bc2a pages: update the pages with release 0.3.4 2023-09-28 19:06:06 +02:00
Stéphane Cerveau d002e2811f release: 0.3.4 2023-09-28 16:45:01 +02:00
Stéphane Cerveau 0148a43946 windows: install the share folder from gtk/gst 2023-09-28 16:45:01 +02:00
Stéphane Cerveau e12fecf971 settings: create the default app folder
To avoid a crash if the settings folder is
not present and the log can not be created properly
2023-09-28 16:45:01 +02:00
Stéphane Cerveau 886c099dba data: update homepage in appdata
This appdata will be the mirror of what we
can see on
https://flathub.org/apps/org.freedesktop.dabrain34.GstPipelineStudio
2023-09-28 16:44:42 +02:00
Stéphane Cerveau f81bedb71a data: update the screenshot for 0.3.3 2023-09-24 12:57:09 +02:00
Stéphane Cerveau 2787211f0d release: update release version fetcher 2023-09-23 09:05:30 +02:00
Stéphane Cerveau 98d6451e74 pages: update the pages with release 0.3.3 2023-09-22 15:32:09 +02:00
Stéphane Cerveau 970103ddee version: 0.3.3 2023-09-22 15:03:45 +02:00
Stéphane Cerveau aa551db066 ci: update macos job to start build earlier 2023-09-22 14:33:26 +02:00
Stéphane Cerveau 4569fa79e8 meson: set minimum version of meson==0.63.0 2023-09-22 14:33:26 +02:00
Stéphane Cerveau be2d7ab6d0 macos: copy gtk4 dependencies 2023-09-22 14:32:29 +02:00
Stéphane Cerveau cf438b523c ci: pages test removed 2023-09-20 22:24:25 +02:00
Stéphane Cerveau 66cd1b9c15 app: use default size to save/load app size
Use maximize on all platform except
macos

Fixes #19
2023-09-20 22:20:10 +02:00
Stéphane Cerveau 1789bb0b25 app: remove the maximize call
The maximize call blocks the resize on MacOS.

Fixes #19
2023-09-20 13:34:16 +00:00
Stéphane Cerveau c1ae2c37b6 ci: add gitlab pages jobs 2023-09-19 13:00:20 +02:00
Stéphane Cerveau a32b16c467 release: update the description 2023-09-18 16:08:19 +02:00
Stéphane Cerveau 06b0ec8ead graphbook: remove double call to set_tooltip_markup 2023-09-18 15:57:54 +02:00
Stéphane Cerveau d0bf6091a4 update to version 0.3.2 2023-09-18 13:55:38 +02:00
Stéphane Cerveau f4be2299b9 graphbook: introduce element_factory_exists
This method helps to tell if a factory exists
when loading a graph.
If the factory does not exists, use light mode
to display it and prevent some menu item
and change its description.
2023-09-18 12:34:58 +02:00
Stéphane Cerveau 111750a33b build-aux: use copy2 instead of copyfile 2023-09-18 12:33:25 +02:00
Stéphane Cerveau 40e999f7d1 installers: add VERSION file 2023-09-18 12:33:25 +02:00
Stéphane Cerveau dd4700eb11 ci: add linux release 2023-09-17 17:52:45 +02:00
Stéphane Cerveau f2cc9ea886 meson: change minimum requirement for gst
Use gst 1.22
2023-09-17 16:20:50 +02:00
Stéphane Cerveau 5c9a273fcc version: prepare v0.3.1 2023-09-17 16:20:50 +02:00
Stéphane Cerveau 38928e07b8 macos: get tag for version 2023-09-16 10:37:59 +02:00
Stéphane Cerveau 4a5964c340 app: manage graphtab as a tab of notebook
graph tab in the graphbook containing a player
and a graphview
2023-09-16 10:37:59 +02:00
Stéphane Cerveau bcc39acf5e app: add session structure
This structure represents a graphview and a player.
It will allow a future use of notebook
in the main window
2023-09-15 11:56:16 +02:00
Stéphane Cerveau 3fbaa3166d player: register external plugins only once
In case of multiple graph tab the player was registering
several time the gtk4paintablesink
2023-09-15 11:56:16 +02:00
Stéphane Cerveau 3689d4d57c graphview: change log level for link name 2023-09-15 11:56:16 +02:00
Stéphane Cerveau ea43d37589 changelog: update changelog and todo 2023-08-31 17:23:58 +02:00
Stéphane Cerveau eda453df53 graphview: use gtk::style_context_add_provider_for_display
gtk::StyleContext::add_provider_for_display is now deprecated
since gtk update to 0.7.2
2023-08-31 17:23:58 +02:00
Stéphane Cerveau 375f083cbf cargo: update rust, gtk and gstreamer version 2023-08-31 17:23:58 +02:00
Stéphane Cerveau a56c0956ab macos: remove useless comment in deploy 2023-08-26 21:42:58 +02:00
Stéphane Cerveau d2b1c8875e deploy_macos: copy gst plugin dep in lib 2023-08-26 21:00:29 +02:00
Stéphane Cerveau aa66eb37de macos: relocate the libraries with rpath 2023-08-26 19:50:33 +02:00
Stéphane Cerveau 0a48ff3d58 gstreamer: use stable 1.22 version
This version includes the patch for orc

https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4866
2023-08-26 19:50:33 +02:00
Stéphane Cerveau 234b5fe043 ci: update fedora version to 38 2023-08-26 12:52:30 +02:00
Stéphane Cerveau 16db9ab30a app: remove special use case with caps filter 2023-08-26 12:52:30 +02:00
Stéphane Cerveau ad6c53a531 app: support of caps filter by link name 2023-08-26 12:52:30 +02:00
Stéphane Cerveau aaf47503fe graphmanager: add link name
Allow to set and display a link name
2023-08-26 12:52:30 +02:00
Stéphane Cerveau 5de51d5565 meson: add gtk4 as a subproject
Add gtk.wrap to subprojects

Remove gtk4 from brew_setup.sh
2023-06-14 22:35:22 +02:00
Stéphane Cerveau 21962866c5 ci: update fedora image with missing package
Add flex and bison
2023-06-14 22:35:21 +02:00
Stéphane Cerveau 14a872fb89 meson: add gstreamer 1.0 as a subproject 2023-06-14 22:35:20 +02:00
Stéphane Cerveau bb38972aea macos: deploying application
https://www.datatable.online/en/blog/004-how-to-deploy-gtk-app-on-mac.html#deploy-your-app-as-linux-app
2023-06-14 22:32:58 +02:00
Stéphane Cerveau e0274e8fd6 ci: fix flatpak release job 2023-04-14 11:27:37 +02:00
Stéphane Cerveau 1aa39f2c62 gps: update version to 0.3.0 2023-04-12 22:38:44 +02:00
Stéphane Cerveau 9c3ee809b1 ci: add windows release 2023-04-12 22:38:44 +02:00
Stéphane Cerveau 0748e9352b ci: use wix install from latest gstreamer ci image 2023-04-12 22:38:44 +02:00
Stéphane Cerveau db83d15ab4 ci: add manual to windows job 2023-04-12 12:08:17 +02:00
Stéphane Cerveau 0d25146878 ci: add default branch value
Gstreamer is now using 1.22
2023-04-12 12:08:17 +02:00
Stéphane Cerveau 2527a730d3 wix: add variable for version and upgrade code 2023-04-12 12:08:15 +02:00
Stéphane Cerveau a99750a571 meson: include data only on linux
data is related to flatpak
2023-04-12 12:07:39 +02:00
Stéphane Cerveau 1e17ab654f wix: add specific install folder 2023-04-12 12:07:39 +02:00
Stéphane Cerveau 9207ae05d2 wix: add license dialog 2023-04-12 12:07:39 +02:00
Stéphane Cerveau 081bc4d3a0 wix: enable a first installer upgradable 2023-04-12 12:07:36 +02:00
Stéphane Cerveau 9c83ff6123 ci: enable windows build 2023-03-05 19:29:38 +01:00
Stéphane Cerveau d1ccea7ea8 logger: create the log in the home directory
Prevent an issue on windows where the application could
not start because the log was created in the app folder.
2023-03-05 19:29:38 +01:00
Stéphane Cerveau 378d867520 meson: rename cargo.sh to cargo.py
To be cross platform, use cargo.py to manage cargo
2023-03-05 19:29:38 +01:00
Stéphane Cerveau d0e284d0a2 gettext: remove crate use because unsupported on Windows.
Part of #12
2023-03-05 19:29:38 +01:00
Stéphane Cerveau 26b834c267 cargo: remove x11 dependency but use GST_XINITTHREADS 2023-03-05 19:29:38 +01:00
Stéphane Cerveau 9bcca3863a src: use python to copy config.rs file 2023-03-05 19:29:38 +01:00
Stéphane Cerveau a744b17490 lang: fixup ip.pio 2023-03-05 19:23:42 +01:00
albanobattistella 8de685a741 lang: add ita.po 2023-02-14 22:13:09 +01:00
Stéphane Cerveau 88ec98bcef player: generate a graph from a pipeline description 2023-02-14 10:18:06 +01:00
Stéphane Cerveau 01df04be60 move glib value_as_str to common module 2023-02-14 10:18:06 +01:00
Stéphane Cerveau c0220c4bdb element: change api to allow the use of direct gst::element
Fetch the property(s) of a given GstElement or check
the property from a feature name.
2023-02-14 10:18:06 +01:00
Stéphane Cerveau 46889d86d0 node: provide an API to fetch port by name
Retrieve the port from a node by its name.
2023-02-14 10:18:06 +01:00
Stéphane Cerveau 8c9cb35928 graphview: node by unique name
keep a unique name value in Node structure
and provide an API to modify it.
2023-02-14 10:18:06 +01:00
Stéphane Cerveau 16fee2a289 settings: remove get prefix
Remove "get_" whenever possible
2023-02-14 10:04:49 +01:00
Stéphane Cerveau 435e7bfd0d ci: update fedora to 36
to support the latest gtk4-rs
2023-02-13 21:55:07 +01:00
Stéphane Cerveau 8872dab55b app: update and fix for gtk4-rs 0.6.1 2023-02-13 21:46:23 +01:00
Stéphane Cerveau 9e6ee57fee graphmanager: update and fix for gtk4-rs 0.6.1 2023-02-13 21:45:54 +01:00
Stéphane Cerveau 17a81a52a6 ci: trigger a new build of FDO docker image 2023-02-13 17:11:19 +01:00
Stéphane Cerveau ae85402eeb player: fix various clippy issues
Fix uninlined_format_args warning
2023-02-13 16:39:56 +01:00
Stéphane Cerveau e2a62ae4d4 graphmanager: Fix various clippy issues
fix uninlined_format_args clippy warning
2023-02-13 16:39:56 +01:00
Stéphane Cerveau a02c99fb61 app: fix various clippy issue
Fix uninlined_format_args since 1.66.0
2023-02-13 16:39:56 +01:00
Stéphane Cerveau 8603b21d98 app: set light mode for capsfilter node/element 2023-02-13 16:39:56 +01:00
Stéphane Cerveau 078940fd48 element: element_is_capsfilter 2023-02-13 16:39:56 +01:00
Stéphane Cerveau cc42cdeaeb graphmanager: add a light mode
Add a light mode to display node with a
dashed style
2023-02-13 16:39:47 +01:00
Stéphane Cerveau 3f75581d60 app: display node properties on double-clicked 2023-02-09 14:05:42 +01:00
Stéphane Cerveau a5767b21fe graphmanager: Add node-double-clicked signal 2023-02-09 14:05:17 +01:00
Stéphane Cerveau 726a6f4d41 cargo: update gst/gtk/gst-plugin-gtk4 2022-11-29 08:42:12 +00:00
Stéphane Cerveau 6b657891c6 graphmanager: fix some lint issues with rust 1.63
Fix format and missing derive
2022-09-06 12:48:40 +02:00
Stéphane Cerveau ebbc1d2261 app: update to rust 1.63 and fix some lint issues
Fix format! and missing derive
2022-09-06 12:48:40 +02:00
Stéphane Cerveau 25859ec1cd gitlab-ci: update image to support git
git is necessary for cargo update
2022-09-05 18:21:33 +02:00
Stéphane Cerveau 39a15df491 cargo: update to latest gtk and gst
gtk: 0.4.8
gst: 0.18.8
2022-09-05 15:18:38 +02:00
Stéphane Cerveau aa5b16aac4 README: update pkg-config package name
Add troubleshooting in case of non working UI
2022-09-02 15:22:14 +02:00
Stéphane Cerveau 9491803a6c README: add macos dependencies list 2022-03-21 10:45:12 +01:00
Stéphane Cerveau b5ec5b2d84 ci: install rust via rustup
Use stable version of rust
2022-03-07 11:48:49 +01:00
Stéphane Cerveau 1fe43d7da3 player: fix clippy error 2022-03-07 11:29:19 +01:00
Stéphane Cerveau ac06bae594 gitlab: add default template 2022-03-06 15:32:28 +01:00
Stéphane Cerveau df537642ba cargo: strip in release 2022-03-06 15:32:11 +01:00
Stéphane Cerveau 76b0c71274 cargo: use last gtk4 gst crates
gtk4 0.4.6
gstreamer 0.18.5
2022-03-01 14:34:38 +01:00
Patrick José Pereira 0ee941efbe src: Use new wrappable argument 2022-02-21 08:49:31 +00:00
Patrick José Pereira ed697a63e9 ui: treeview: Add wrappable feature 2022-02-21 08:49:31 +00:00
Stéphane Cerveau 39554d8d99 logger: add a popup menu to clear the logs
Add a way to clear the logs.
2022-02-21 08:34:34 +00:00
Stéphane Cerveau aaaa58072c logger: display the most recent log on top
The most recent log arrives on top of the list and
is always visible.
2022-02-21 08:34:34 +00:00
Stéphane Cerveau 7762332700 preferences: add log level
Can now set the log level in the application
2022-02-21 08:34:34 +00:00
Stéphane Cerveau 28abb4555a po: remove useless translations 2022-02-18 16:53:07 +01:00
Stéphane Cerveau 28a9cfbd50 graphmanager: update link license
Add a license in GraphManager folder
2022-02-16 17:10:34 +01:00
Stéphane Cerveau 4c7c55bece TODO: split with changeLog
Keep a todo list and move the changes
to the changelog
2022-02-15 09:49:38 +01:00
Stéphane Cerveau 088aff1576 properties: cleanup Label creation 2022-02-10 14:38:13 +00:00
Stéphane Cerveau 57160b3bce about: display GStreamer version 2022-02-10 14:38:13 +00:00
Stéphane Cerveau 6cc908c109 graphview: add a format version to graphview 2022-02-10 14:38:13 +00:00
Stéphane Cerveau 2f60471f8b gitlab: add template for issues
Add bug and RFC templates
2022-02-10 15:35:14 +01:00
Stéphane Cerveau d9fca2580e README: add note about app stability
The app should not be considered as stable until
version 1.0
2022-02-10 15:09:37 +01:00
Stéphane Cerveau 9e4e915b1d release: mention flathub for a new release 2022-02-09 11:29:42 +01:00
Stéphane Cerveau f925c21b1d GPS: cleanup the license
Keep only the SPDX and mention the project
2022-02-09 11:28:59 +01:00
Stéphane Cerveau 0164d71bf2 graphmanager: cleanup the license
Keep only the SPDX and mention the project
2022-02-09 11:28:27 +01:00
Stéphane Cerveau cdd30e830d version: update to 0.2.3 2022-02-08 17:00:56 +01:00
Stéphane Cerveau 3d55c60fd5 ci: disabled dist-package 2022-02-08 17:00:35 +01:00
Stéphane Cerveau 31acf5794f todo: add a bug with non linear flags 2022-02-08 16:59:26 +01:00
Stéphane Cerveau 53a379b790 appdata.xml: can now automatically fill date and version 2022-02-08 16:52:47 +01:00
92 changed files with 6053 additions and 1738 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/target
*.log
src/config.rs
subprojects/*/

View file

@ -2,23 +2,37 @@ include:
- project: "freedesktop/ci-templates" # the project to include from
ref: "34f4ade99434043f88e164933f570301fd18b125" # git ref of that project
file: "/templates/fedora.yml" # the actual file to include
- local: "ci/images_template.yml"
stages:
- prepare
- lint
- test
- release
- deploy
variables:
FDO_UPSTREAM_REPO: "dabrain34/GstPipelineStudio"
GNOME_RUNTIME_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:3.38"
GNOME_RUNTIME_IMAGE: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
WINDOWS_RUST_STABLE_IMAGE: "$CI_REGISTRY_IMAGE/windows:$GST_RS_WIN_IMG_TAG"
WINDOWS_RUST_STABLE_UPSTREAM_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/windows:$GST_RS_WIN_IMG_TAG"
# Version and tag for our current container
.fedora:
variables:
FDO_DISTRIBUTION_VERSION: "35"
FDO_DISTRIBUTION_VERSION: "38"
# Update this to trigger a container rebuild
FDO_DISTRIBUTION_TAG: "2022-01-27.2"
FDO_DISTRIBUTION_TAG: $GST_RS_FDO_IMG_TAG
before_script:
- source ./ci/env.sh
- mkdir .cargo && echo -e "[net]\ngit-fetch-with-cli = true" > .cargo/config
# If cargo exists assume we probably will want to update
# the lockfile
#- |
# if command -v cargo; then
# cargo generate-lockfile --color=always
# cargo update --color=always
# fi
build-fedora-container:
extends:
@ -28,10 +42,6 @@ build-fedora-container:
variables:
# clang-devel: required by rust bindgen
FDO_DISTRIBUTION_PACKAGES: >-
rust
cargo
rustfmt
clippy
gtk4-devel
clang-devel
gstreamer1-devel
@ -44,21 +54,123 @@ build-fedora-container:
python3-setuptools
util-linux
xorg-x11-server-Xvfb
wget
git
flex
bison
FDO_DISTRIBUTION_EXEC: >-
pip3 install meson
ci/install-rust.sh stable &&
pip3 install meson &&
pip3 install pre-commit
rustfmt-clippy:
.windows rust docker build:
stage: prepare
variables:
# Unlike the buildah/linux jobs, this file
# needs to be relative to windows-docker/ subdir
# as it makes life easier in the powershell script
#
# We also don't need a CONTEXT_DIR var as its also
# hardcoded to be windows-docker/
DOCKERFILE: "ci/windows-docker/Dockerfile"
GST_UPSTREAM_BRANCH: "1.22"
tags:
- "windows"
- "shell"
- "2022"
script:
# We need to pass an array and to resolve the env vars, so we can't use a variable:
- $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_GST_BRANCH=$GST_UPSTREAM_BRANCH", "--build-arg", "RUST_VERSION=$RUST_VERSION")
- "& ci/windows-docker/container.ps1 $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $RUST_IMAGE $RUST_UPSTREAM_IMAGE $DOCKERFILE"
- |
if (!($?)) {
echo "Failed to build the image"
Exit 1
}
windows rust docker stable:
extends: ".windows rust docker build"
variables:
RUST_IMAGE: $WINDOWS_RUST_STABLE_IMAGE
RUST_UPSTREAM_IMAGE: $WINDOWS_RUST_STABLE_UPSTREAM_IMAGE"]
RUST_VERSION: $GST_RS_STABLE
.msvc2019 build:
stage: test
tags:
- "docker"
- "windows"
- "2022"
windows installer stable:
needs:
- job: "windows rust docker stable"
artifacts: false
image: "$WINDOWS_RUST_STABLE_IMAGE"
extends: ".msvc2019 build"
script:
- rustc --version
- git fetch --tags
- "& ./ci/build_gps.ps1"
- "& ./installer/wix/prepare_gstreamer.ps1"
- "& ./installer/wix/build_installer.ps1"
artifacts:
paths:
- installer/wix/*.msi
expire_in: 10 days
when: "manual"
pre-commit:
stage: "lint"
extends:
- .fedora
- .fdo.distribution-image@fedora
variables:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
cache:
paths:
- ${PRE_COMMIT_HOME}
script:
- meson setup build
- pre-commit run --all-files
clippy:
extends:
- .fedora
- .fdo.distribution-image@fedora
stage: lint
script:
- meson build
- cargo fmt --version
- cargo fmt -- --color=always --check
- cargo clippy --version
- cargo clippy --color=always --all-targets -- -D warnings
windows installer release:
extends: "windows installer stable"
stage: release
only:
- flatpak
- tags
artifacts:
paths:
- installer/wix/*.msi
when: "always"
linux release:
extends:
- .fedora
- .fdo.distribution-image@fedora
stage: release
only:
- flatpak
- tags
script:
- meson builddir -Dbuildtype=release
- ninja -C builddir/ dist
artifacts:
paths:
- builddir/meson-dist/*
when: "always"
test-stable:
extends:
- .fedora
@ -94,26 +206,17 @@ dist-package:
stage: release
only:
- flatpak
- tags
script:
- meson build
- ninja -C build dist
flatpak:
image: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:41"
stage: release
only:
- flatpak
- tags
# Using gstreamer runner avoids an issue with 'bwrap: No permissions to creating new namespace' during flatpak builder
tags:
- gstreamer
image: $GNOME_RUNTIME_IMAGE
stage: test
variables:
BUNDLE: "gst-pipeline-studio-nightly.flatpak"
MANIFEST_PATH: "build-aux/org.freedesktop.dabrain34.GstPipelineStudio.Devel.json"
FLATPAK_MODULE: "gst-pipeline-studio"
APP_ID: "org.freedesktop.dabrain34.GstPipelineStudio.Devel"
RUNTIME_REPO: "https://nightly.gnome.org/gnome-nightly.flatpakrepo"
BUNDLE: "gst-pipeline-studio-nightly.flatpak"
script:
- flatpak-builder app ${MANIFEST_PATH}
- flatpak build-export repo app
@ -124,6 +227,70 @@ flatpak:
when: "always"
paths:
- "${BUNDLE}"
- ".flatpak-builder/build/${FLATPAK_MODULE}/_flatpak_build/meson-logs/meson-log.txt"
- ".flatpak-builder/build/${FLATPAK_MODULE}/_flatpak_build/meson-logs/testlog.txt"
expire_in: 14 days
cache:
key: "flatpak"
paths:
- .flatpak-builder/downloads/
- .flatpak-builder/git/
- target/
- target_test/
when: "manual"
macos installer stable:
stage: test
tags:
- gst-macos-13
before_script:
- pip3 install --upgrade pip
# Make sure meson is up to date
- pip3 install -U meson
# Need to install certificates for python
- pip3 install --upgrade certifi
# Another way to install certificates
- open /Applications/Python\ 3.8/Install\ Certificates.command
# Get ninja
- pip3 install -U ninja
script:
# rust toolchain
- curl https://sh.rustup.rs -sSf | sh -s -- -y
- source $HOME/.cargo/env
# brew install
- /bin/bash -c "./installer/macos/brew_setup.sh"
- /bin/bash -c "./installer/macos/deploy_macos.sh"
artifacts:
name: "MacOS installer"
paths:
- installer/**/GstPipelineStudio*.dmg
- installer/**/GstPipelineStudio*.tar.gz
expire_in: 14 days
when: "manual"
macos installer release:
extends: "macos installer stable"
stage: release
only:
- flatpak
- tags
artifacts:
name: "MacOS installer"
paths:
- installer/**/GstPipelineStudio*.dmg
- installer/**/GstPipelineStudio*.tar.gz
when: "always"
pages:
image: ruby:2.7
stage: deploy
script:
- gem install bundler -v 2.4.22
- bundle install
- bundle exec jekyll build -d public
artifacts:
paths:
# The folder that contains the files to be exposed at the Page URL
- public
rules:
# This ensures that only pushes to the default branch will trigger
# a pages deploy
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

View file

@ -0,0 +1,41 @@
### Describe your issue
<!-- a clear and concise summary of the bug. -->
<!-- For any GStreamer usage question, please contact the community using the #gstreamer channel on IRC https://www.oftc.net/ or the mailing list on https://gstreamer.freedesktop.org/lists/ -->
#### Expected Behavior
<!-- What did you expect to happen -->
#### Observed Behavior
<!-- What actually happened -->
#### Setup
- **Operating System:**
- **Device:** Computer / Tablet / Mobile / Virtual Machine <!-- Delete as appropriate !-->
- **Flatpak:** Yes/No
- **GstPipelineStudio version:**
- **GStreamer Version:**
### Steps to reproduce the bug
<!-- please fill in exact steps which reproduce the bug on your system, for example: -->
1. open terminal
2. type `command`
### How reproducible is the bug?
<!-- The reproducibility of the bug is Always/Intermittent/Only once after doing a very specific set of steps-->
### Screenshots if relevant
### Solutions you have tried
### Related non-duplicate issues
### Additional Information
<!-- Any other information such as logs. Make use of <details> for long output -->

View file

@ -0,0 +1,41 @@
### Describe your issue
<!-- a clear and concise summary of the bug. -->
<!-- For any GStreamer usage question, please contact the community using the #gstreamer channel on IRC https://www.oftc.net/ or the mailing list on https://gstreamer.freedesktop.org/lists/ -->
#### Expected Behavior
<!-- What did you expect to happen -->
#### Observed Behavior
<!-- What actually happened -->
#### Setup
- **Operating System:**
- **Device:** Computer / Tablet / Mobile / Virtual Machine <!-- Delete as appropriate !-->
- **Flatpak:** Yes/No
- **GstPipelineStudio version:**
- **GStreamer Version:**
### Steps to reproduce the bug
<!-- please fill in exact steps which reproduce the bug on your system, for example: -->
1. open terminal
2. type `command`
### How reproducible is the bug?
<!-- The reproducibility of the bug is Always/Intermittent/Only once after doing a very specific set of steps-->
### Screenshots if relevant
### Solutions you have tried
### Related non-duplicate issues
### Additional Information
<!-- Any other information such as logs. Make use of <details> for long output -->

View file

@ -0,0 +1,12 @@
### Describe your RFC
<!-- a clear and concise summary of the RFC. -->
<!-- For any GStreamer usage question, please contact the community using the #gstreamer channel on IRC https://www.oftc.net/ or the mailing list on https://gstreamer.freedesktop.org/lists/ -->
#### Expected Behavior
<!-- What did you expect to happen -->
### Related non-duplicate issues
### Additional Information

29
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,29 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.11
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
- repo: https://github.com/crate-ci/typos
rev: v1.17.0
hooks:
- id: typos
exclude: '^$|\.svg$'
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt

1173
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,28 +1,35 @@
[package]
name = "gst_pipeline_studio"
version = "0.2.2"
name = "gst-pipeline-studio"
version = "0.3.5"
edition = "2018"
rust-version = "1.70.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
gtk = { version = "0.4.1", package = "gtk4" }
gst = { package = "gstreamer", version = "0.18.1" }
gst-plugin-gtk4 = { version = "0.1.1", optional=true }
gtk = { version = "0.8.0", package = "gtk4" }
gst = { package = "gstreamer", version = "0.22.2" }
gst-plugin-gtk4 = { version = "0.12.1", optional=true }
anyhow = "1"
gettext-rs = {version = "0.7", features = ["gettext-system"]}
log = "0.4.11"
once_cell = "1.7.2"
xml-rs = "0.8.4"
x11 = { version = "2.18", features = ["xlib"] }
serde = "1.0"
serde_any = "0.5"
simplelog = "0.11.2"
futures-channel = "0.3"
lazy_static = "1.4"
chrono = "0.4"
structopt = "0.3"
async-channel = "2.0.0"
[dev-dependencies]
futures-executor = "0.3"
[features]
default = ["gtk4-plugin"]
gtk4-plugin = ["gst-plugin-gtk4"]
gtk4-plugin = ["gst-plugin-gtk4"]
[profile.release]
strip = "debuginfo"

127
ChangeLog.md Normal file
View file

@ -0,0 +1,127 @@
## 0.1.0
- [x] Fix c.fill issue
- [x] Create Element structure with pads and connections
- [x] Get a list of GStreamer elements in dialog add plugin
- [x] Add plugin details in the element dialog
- [x] Draw element with its pad
- [x] Be able to move the element on Screen
- [x] Create connection between element
- [x] create contextual menu on pad or element
- [x] save/load pipeline
- [x] Run a pipeline with GStreamer
- [x] Run the pipeline with GStreamer
- [x] Control the pipeline with GStreamer
- [x] select nodes/links with a Trait Selectable
- [x] be able to remove a link by selecting it
- [x] Connect the logs to the window
- [x] Define the license
- [x] crash with x11 on contextual menu
- [x] open multiple times dialog (About) prevent to close it.
- [x] remove useless code from graphview
- [x] Move render to a specific module
- [x] Move GST render to a specific module
## 0.2.0
### Graphview
- [x] Remove a port from a node when its possible (Presence support)
- [x] Implement graphview unit test
- [x] Add a css class for pad (presence always or sometimes)
- [x] Add properties to Port to store some specific value (ie Caps)
- [x] Unable to connect a port which is already connected
- [x] Unable to connect port with same directions (in/in, out/out)
### GStreamer:
- [x] Add seek support
- [x] Use of gtk4paintablesink
### app
- [x] Check that a node accepts to create a port on request (input/output)
- [x] Render the parse launch line in a message box
- [x] Prevent to create a pad in an element without the template
- [x] Check the pipeline validity
- [x] Save node position in XML
- [x] Auto-save the graph
- [x] Logger in file/app all over the app
- [x] Property window in the main window
- [x] Connect the GPS status to GST status
- [x] Display position and duration
- [x] Seek to position with slider
- [x] One listbox with elements and one listbox with favorites in the app dashboard
- [x] See the link creation with a dashed line
- [x] Display pad properties with tooltip hover
- [x] Add preferences dialog
- [x] Create a window for the video output
### infra
- [x] Icon install
- [x] Flatpak infrastructure
## 0.2.1
### app
- [x] Can set pad properties to be used during the pipeline generation. See videomixer_alpha.xml
- [x] Support gtk4paintablesink with playbin
- [x] Display a pipeline properties dialog (list elements)
## 0.2.2
### app
- [x] Remove quit as it's unnecessary with close button
- [x] Remove the close button in dialogs (properties etc.)
- [x] Unable to use flags in playbin3
- [x] the desktop icon execs gps_pipeline_studio
- [x] move burger menu on the right
### Graphview
- [x] Update node description on property removal
## 0.3.0
### CI/Infra
- [x] Create a macos installer
- [x] Create a windows installer
### Graphview
- [x] set/get the file format version
### GStreamer
- [x] Display GStreamer version in the about dialog
## 0.3.1
### app
- [x] Add multiple graphviews with tabs.
- [x] handle the caps setter element
## 0.3.2
### app
- [x] check that element exists before creating it on file load.
## 0.3.3
### app
- [x] Fix MacOs GTK runtime dependencies
- [x] Fix the maximize call with MacOS
- [x] Fix the default size at GTK save/load state
## 0.3.4
### app
- [x] Fix first run when application folder has not been created, fixes #23
- [x] Fix windows installer to bring share folder and let filesrc work properly, fixes #24
## 0.3.5
### app
- [x] logs: receive multiple log sources such as GST logs and messages.
- [x] settings: add a log level selection
- [x] rename gst_pipeline_studio to gst-pipeline-studio
- [x] can open a pipeline from the command line

3
Gemfile Normal file
View file

@ -0,0 +1,3 @@
source "https://rubygems.org"
gem "jekyll"

View file

@ -1,4 +1,11 @@
# GstPipelineStudio: Draw your own GStreamer pipeline ...
# [GstPipelineStudio](https://dabrain34.pages.freedesktop.org/GstPipelineStudio): Draw your own GStreamer pipeline ...
## Important
Until version 1.0, this software should be considered as **unstable**.
The settings moreover the graph file format might change over the development phase.
## Description
@ -19,7 +26,7 @@ Check https://rustup.rs for alternative installation options.
### Ubuntu/Debian/etc
```sh
apt install python3-pip ninja-build pkgconfig
apt install python3-pip ninja-build pkg-config
pip3 install --user meson
apt install libgtk-4-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
```
@ -32,12 +39,19 @@ pip3 install meson
dnf install gtk4-devel gstreamer1-devel gstreamer1-plugins-base-devel python3-pip ninja-build pkgconfig
```
### MacOS
```sh
brew install gtk4
brew install gstreamer gst-plugins-base gst-plugins-bad
```
## Getting started
```sh
$ meson builddir -Dbuildtype=release
$ ninja -C builddir
$ ./builddir/target/release/gst_pipeline_studio
$ ./builddir/target/release/gst-pipeline-studio
```
## Flatpak
@ -64,3 +78,7 @@ This project has been also possible thanks to amazing projects such as:
Every contribution is greatly appreciated! You will just need a [gitlib account](https://gitlab.freedesktop.org/users/sign_in?redirect_to_referer=yes). [Fork](https://docs.gitlab.com/ee/user/project/repository/forking_workflow.html) this repo, [clone](http://git-scm.com/docs/git-clone) your fork, create a [feature branch](https://www.google.com/search?q=git+feature+branches), [commit](http://git-scm.com/docs/git-commit), [push](http://git-scm.com/docs/git-push) and submit a [merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html).
Submit any suggestions, questions or bugs to the [Issue Tracker](https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio/-/issues/).
## Troubleshooting
Interface is not clean: rm ~/.config/org.freedesktop.dabrain34.GstPipelineStudio/settings.toml

100
TODO.md
View file

@ -1,95 +1,10 @@
## 0.1.0
- [x] Fix c.fill issue
- [x] Create Element structure with pads and connections
- [x] Get a list of GStreamer elements in dialog add plugin
- [x] Add plugin details in the element dialog
- [x] Draw element with its pad
- [x] Be able to move the element on Screen
- [x] Create connection between element
- [x] create contextual menu on pad or element
- [x] save/load pipeline
- [x] Run a pipeline with GStreamer
- [x] Run the pipeline with GStreamer
- [x] Control the pipeline with GStreamer
- [x] select nodes/links with a Trait Selectable
- [x] be able to remove a link by selecting it
- [x] Connect the logs to the window
- [x] Define the license
- [x] crash with x11 on contextual menu
- [x] open multiple times dialog (About) prevent to close it.
- [x] remove useless code from graphview
- [x] Move render to a specific module
- [x] Move GST render to a specific module
## 0.2.0
### Graphview
- [x] Remove a port from a node when its possible (Presence support)
- [x] Implement graphview unit test
- [x] Add a css class for pad (presence always or sometimes)
- [x] Add properties to Port to store some specific value (ie Caps)
- [x] Unable to connect a port which is already connected
- [x] Unable to connect port with same directions (in/in, out/out)
### GStreamer:
- [x] Add seek support
- [x] Use of gtk4paintablesink
### app
- [x] Check that a node accepts to create a port on request (input/output)
- [x] Render the parse launch line in a message box
- [x] Prevent to create a pad in an element without the template
- [x] Check the pipeline validity
- [x] Save node position in XML
- [x] Auto-save the graph
- [x] Logger in file/app all over the app
- [x] Property window in the main window
- [x] Connect the GPS status to GST status
- [x] Display position and duration
- [x] Seek to position with slider
- [x] One listbox with elements and one listbox with favorites in the app dashboard
- [x] See the link creation with a dashed line
- [x] Display pad properties with tooltip hover
- [x] Add preferences dialog
- [x] Create a window for the video output
### infra
- [x] Icon install
- [x] Flatpak infrastructure
## 0.2.1
### app
- [x] Can set pad properties to be used during the pipeline generation. See videomixer_alpha.xml
- [x] Support gtk4paintablesink with playbin
- [x] Display a pipeline properties dialog (list elements)
## 0.2.2
### app
- [x] Remove quit as it's unnecessary with close button
- [x] Remove the close button in dialogs (properties etc.)
- [x] Unable to use flags in playbin3
- [x] the desktop icon execs gps_pipeline_studio
- [x] move burger menu on the right
### Graphview
- [x] Update node description on property removal
## TODO
### Graphview
- [ ] create a crate for graphview/node/port
### GStreamer:
- [ ] Implement pipeline unit test
@ -97,26 +12,23 @@
### app
- [ ] Control the connection between element
- [ ] unable to connect element with incompatible caps.
- [ ] Add multiple graphviews with tabs.
- [ ] unable to connect element with incompatible caps.
- [ ] Implement graph dot render/load
- [ ] Implement a command line parser to graph
- [ ] handle the caps setter element
- [ ] Add probes on each pad to monitor the pipeline
- [ ] Render a media file
- [ ] Offer compatible element to a pad (autorender)
- [ ] Display tags/meta/message detected
- [ ] Change TreeView to ListView
- [ ] Implement zoom on the view (https://gitlab.gnome.org/World/obfuscate/-/blob/master/src/widgets/drawing_area.rs)
- [ ] Settings: add a log level selection
- [ ] reopen the last log on prematured exit (crash)
- [ ] Play/pause should be prevented until the pipeline is ready
- [ ] Filter the elements by class/rank etc.
- [ ] double click on node/pad open the properties
### CI/Infra
- [ ] Create a macos/windows job
## bugs
- [ ] check that element exists before creating it on file load.
- [ ] Combo box is not well selected if the value is not linear such as flags. See flags in playbin
- [ ] opening a graph file can lead a different behavior in the pipeline. See videomixer graph where the zorder
on pads is not correctly set to right one.

1
VERSION Normal file
View file

@ -0,0 +1 @@
0.3.5

45
build-aux/cargo.py Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env python3
import sys
import subprocess
import os
import shutil
env = os.environ
MESON_BUILD_ROOT = sys.argv[1]
MESON_SOURCE_ROOT = sys.argv[2]
CARGO_TARGET_DIR = os.path.join(MESON_BUILD_ROOT, "target")
env["CARGO_TARGET_DIR"] = CARGO_TARGET_DIR
env["CARGO_HOME"] = os.path.join(CARGO_TARGET_DIR, "cargo-home")
OUTPUT = sys.argv[3]
BUILDTYPE = sys.argv[4]
APP_BIN = sys.argv[5]
env["PKG_CONFIG_PATH"] = (
os.path.join(MESON_BUILD_ROOT, "meson-uninstalled")
+ os.pathsep
+ env.get("PKG_CONFIG_PATH", "")
)
if BUILDTYPE == "release":
print("RELEASE MODE")
CMD = [
"cargo",
"build",
"--manifest-path",
os.path.join(MESON_SOURCE_ROOT, "Cargo.toml"),
"--release",
]
subprocess.run(CMD, env=env)
shutil.copy2(os.path.join(CARGO_TARGET_DIR, "release", APP_BIN), OUTPUT)
else:
print("DEBUG MODE")
CMD = [
"cargo",
"build",
"--manifest-path",
os.path.join(MESON_SOURCE_ROOT, "Cargo.toml"),
]
subprocess.run(CMD, env=env)
shutil.copy2(os.path.join(CARGO_TARGET_DIR, "debug", APP_BIN), OUTPUT)

View file

@ -1,24 +0,0 @@
#!/bin/sh
export MESON_BUILD_ROOT="$1"
export MESON_SOURCE_ROOT="$2"
export CARGO_TARGET_DIR="$MESON_BUILD_ROOT"/target
export CARGO_HOME="$CARGO_TARGET_DIR"/cargo-home
export OUTPUT="$3"
export BUILDTYPE="$4"
export APP_BIN="$5"
if [ $BUILDTYPE = "release" ]
then
echo "RELEASE MODE"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml --release && \
cp "$CARGO_TARGET_DIR"/release/"$APP_BIN" "$OUTPUT"
else
echo "DEBUG MODE"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml && \
cp "$CARGO_TARGET_DIR"/debug/"$APP_BIN" "$OUTPUT"
fi

View file

@ -3,19 +3,17 @@
from os import environ, path
from subprocess import call
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = path.join(prefix, 'share')
destdir = environ.get('DESTDIR', '')
prefix = environ.get("MESON_INSTALL_PREFIX", "/usr/local")
datadir = path.join(prefix, "share")
destdir = environ.get("DESTDIR", "")
# Package managers set this so we don't need to run
if not destdir:
print('Updating icon cache...')
call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
print('Updating desktop database...')
call(['update-desktop-database', '-q', path.join(datadir, 'applications')])
print('Compiling GSettings schemas...')
call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')])
print("Updating icon cache...")
call(["gtk-update-icon-cache", "-qtf", path.join(datadir, "icons", "hicolor")])
print("Updating desktop database...")
call(["update-desktop-database", "-q", path.join(datadir, "applications")])
print("Compiling GSettings schemas...")
call(["glib-compile-schemas", path.join(datadir, "glib-2.0", "schemas")])

View file

@ -1,28 +1,56 @@
{
"app-id": "org.freedesktop.dabrain34.GstPipelineStudio.Devel",
"runtime": "org.gnome.Platform",
"runtime-version": "41",
"runtime-version": "master",
"sdk": "org.gnome.Sdk",
"sdk-extensions": ["org.freedesktop.Sdk.Extension.rust-stable"],
"command": "gst_pipeline_studio",
"sdk-extensions": [
"org.freedesktop.Sdk.Extension.rust-stable"
],
"command": "gst-pipeline-studio",
"finish-args": [
"--socket=fallback-x11",
"--socket=wayland",
"--device=dri",
"--share=ipc",
"--share=network",
"--filesystem=home",
"--env=G_MESSAGES_DEBUG=none",
"--env=RUST_BACKTRACE=1"
],
"build-options": {
"append-path": "/usr/lib/sdk/rust-stable/bin",
"build-args": ["--share=network"],
"test-args": ["--socket=x11", "--share=network"]
"build-args": [
"--share=network"
],
"test-args": [
"--socket=x11",
"--share=network"
]
},
"modules": [
{
"name": "gst_pipeline_studio",
"name": "gstreamer",
"buildsystem": "meson",
"builddir": true,
"config-opts": [
"-Ddoc=disabled"
],
"sources": [
{
"type": "git",
"tag": "1.22",
"url": "https://gitlab.freedesktop.org/gstreamer/gstreamer.git",
"disable-submodules": true
}
]
},
{
"name": "gst-pipeline-studio",
"buildsystem": "meson",
"run-tests": true,
"config-opts": ["-Dprofile=development"],
"config-opts": [
"-Dprofile=development"
],
"sources": [
{
"type": "dir",
@ -31,4 +59,4 @@
]
}
]
}
}

6
ci/build_gps.ps1 Normal file
View file

@ -0,0 +1,6 @@
$env:MESON_ARGS = "--prefix=C:\gst-install\ -Dbuildtype=release"
cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=amd64 && meson _build $env:MESON_ARGS && meson compile -C _build && ninja -C _build install"
if (!$?) {
Write-Host "Failed to build and install GstPipelineStudio"
Exit 1
}

3
ci/env.sh Normal file
View file

@ -0,0 +1,3 @@
export RUSTUP_HOME='/usr/local/rustup'
export PATH=$PATH:/usr/local/cargo/bin
export CARGO_HOME='/usr/local/cargo'

4
ci/images_template.yml Normal file
View file

@ -0,0 +1,4 @@
variables:
GST_RS_WIN_IMG_TAG: "2023-12-22.0"
GST_RS_FDO_IMG_TAG: "2024-01-05.0"
GST_RS_STABLE: "1.70.0"

25
ci/install-rust.sh Executable file
View file

@ -0,0 +1,25 @@
source ./ci/env.sh
RUSTUP_VERSION=1.26.0
RUST_VERSION=$1
RUST_ARCH="x86_64-unknown-linux-gnu"
RUSTUP_URL=https://static.rust-lang.org/rustup/archive/$RUSTUP_VERSION/$RUST_ARCH/rustup-init
wget $RUSTUP_URL
chmod +x rustup-init;
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION;
rm rustup-init;
chmod -R a+w $RUSTUP_HOME $CARGO_HOME
rustup --version
cargo --version
rustc --version
rustup component add clippy-preview
rustup component add rustfmt
cargo install --force cargo-audit
cargo install --force cargo-outdated
# fetch project deps
cargo fetch

View file

@ -0,0 +1,27 @@
# escape=`
FROM "registry.freedesktop.org/gstreamer/gstreamer/amd64/windows:2023-08-24.0-main"
# Make sure any failure in PowerShell is fatal
ENV ErrorActionPreference='Stop'
SHELL ["powershell","-NoLogo", "-NonInteractive", "-Command"]
ARG DEFAULT_GST_BRANCH="1.22"
ARG DEFAULT_GTK_BRANCH="4.8.2"
ARG RUST_VERSION="invalid"
RUN choco install -y pkgconfiglite nasm llvm
# https://stackoverflow.com/a/50716450
RUN setx PATH '%PATH%;C:\Program Files\NASM;C:\gst-install\bin;c:\Program Files\gettext-iconv\bin'
ENV PKG_CONFIG_PATH="C:\gst-install\lib\pkgconfig"
COPY install_gst.ps1 install_gtk.ps1 C:\
RUN C:\install_gst.ps1
RUN C:\install_gtk.ps1
RUN Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile C:\rustup-init.exe
RUN C:\rustup-init.exe -y --profile minimal --default-toolchain $env:RUST_VERSION
RUN Invoke-WebRequest -Uri https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.21-v1.16/gettext0.21-iconv1.16-shared-64.exe -OutFile C:\gettext0.21.exe
RUN C:\gettext0.21.exe /SILENT

View file

@ -0,0 +1,60 @@
# Copied from mesa, big kudos
#
# https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/.gitlab-ci/windows/mesa_container.ps1
# https://gitlab.freedesktop.org/mesa/mesa/-/blob/34e3e164936d1d3cef267da7780e87f062fedf39/.gitlab-ci/windows/mesa_container.ps1
# Implements the equivalent of ci-templates container-ifnot-exists, using
# Docker directly as we don't have buildah/podman/skopeo available under
# Windows, nor can we execute Docker-in-Docker
$registry_uri = $args[0]
$registry_username = $args[1]
$registry_password = $args[2]
$registry_user_image = $args[3]
$registry_central_image = $args[4]
$dockerfile = $args[5]
docker --config "windows-docker.conf" login -u "$registry_username" -p "$registry_password" "$registry_uri"
if (!$?) {
Write-Host "docker login failed to $registry_uri"
Exit 1
}
# if the image already exists, don't rebuild it
docker --config "windows-docker.conf" pull "$registry_user_image"
if ($?) {
Write-Host "User image $registry_user_image already exists; not rebuilding"
docker --config "windows-docker.conf" logout "$registry_uri"
Exit 0
}
# if the image already exists upstream, copy it
docker --config "windows-docker.conf" pull "$registry_central_image"
if ($?) {
Write-Host "Copying central image $registry_central_image to user image $registry_user_image"
docker --config "windows-docker.conf" tag "$registry_central_image" "$registry_user_image"
docker --config "windows-docker.conf" push "$registry_user_image"
$pushstatus = $?
docker --config "windows-docker.conf" logout "$registry_uri"
if (!$pushstatus) {
Write-Host "Pushing image to $registry_user_image failed"
Exit 1
}
Exit 0
}
Write-Host "No image found at $registry_user_image or $registry_central_image; rebuilding"
docker --config "windows-docker.conf" build $DOCKER_BUILD_ARGS --no-cache -t "$registry_user_image" -f "$dockerfile" "./ci/windows-docker"
if (!$?) {
Write-Host "Container build failed"
docker --config "windows-docker.conf" logout "$registry_uri"
Exit 1
}
Get-Date
docker --config "windows-docker.conf" push "$registry_user_image"
$pushstatus = $?
docker --config "windows-docker.conf" logout "$registry_uri"
if (!$pushstatus) {
Write-Host "Pushing image to $registry_user_image failed"
Exit 1
}

View file

@ -0,0 +1,62 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
# Download gstreamer and all its subprojects
git clone -b $env:DEFAULT_GST_BRANCH --depth 1 https://gitlab.freedesktop.org/gstreamer/gstreamer.git C:\gstreamer
if (!$?) {
Write-Host "Failed to clone gstreamer"
Exit 1
}
Set-Location C:\gstreamer
# Copy the cache we already have in the image to avoid massive redownloads
Move-Item C:/subprojects/* C:\gstreamer\subprojects
if (!$?) {
Write-Host "Failed to copy subprojects cache"
Exit 1
}
# Update the subprojects cache
Write-Output "Running meson subproject reset"
meson subprojects update --reset
if (!$?) {
Write-Host "Failed to reset subprojects state"
Exit 1
}
$env:MESON_ARGS = "--prefix=C:\gst-install\ -Dbuildtype=release " +
"-Dglib:installed_tests=false " +
"-Dlibnice:tests=disabled " +
"-Dlibnice:examples=disabled " +
"-Dffmpeg:tests=disabled " +
"-Dopenh264:tests=disabled " +
"-Dpygobject:tests=false " +
"-Dugly=enabled " +
"-Dbad=enabled " +
"-Dges=enabled " +
"-Drtsp_server=enabled " +
"-Ddevtools=enabled " +
"-Dsharp=disabled " +
"-Dpython=disabled " +
"-Dlibav=disabled " +
"-Dvaapi=disabled " +
"-Dgst-plugins-base:pango=enabled " +
"-Dgst-plugins-good:cairo=enabled " +
"-Dgpl=enabled "
Write-Output "Building gst"
cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=amd64 && meson _build $env:MESON_ARGS && meson compile -C _build && ninja -C _build install"
if (!$?) {
Write-Host "Failed to build and install gst"
Exit 1
}
cd C:\
cmd /c rmdir /s /q C:\gstreamer
if (!$?) {
Write-Host "Failed to remove gst checkout"
Exit 1
}

View file

@ -0,0 +1,27 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
$env:MESON_ARGS = "--prefix=C:\gst-install\ -Dbuildtype=release"
# Download gtk and all its subprojects
git clone -b $env:DEFAULT_GTK_BRANCH --depth 1 https://gitlab.gnome.org/gnome/gtk.git C:\gtk
if (!$?) {
Write-Host "Failed to clone gtk"
Exit 1
}
Set-Location C:\gtk
Write-Output "Building gtk"
cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=amd64 && meson _build $env:MESON_ARGS && meson compile -C _build && ninja -C _build install"
if (!$?) {
Write-Host "Failed to build and install gtk"
Exit 1
}
cd C:\
cmd /c rmdir /s /q C:\gtk
if (!$?) {
Write-Host "Failed to remove gtk checkout"
Exit 1
}

View file

@ -0,0 +1,27 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
$env:MESON_ARGS = "--prefix=C:\gst-install\ --wrap-mode=forcefallback"
# Download pango all its subprojects
git clone -b $env:DEFAULT_PANGO_BRANCH --depth 1 https://gitlab.gnome.org/gnome/pango.git C:\pango
if (!$?) {
Write-Host "Failed to clone pango"
Exit 1
}
Set-Location C:\pango
Write-Output "Building pango"
cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=amd64 && meson _build $env:MESON_ARGS && meson compile -C _build && ninja -C _build install"
if (!$?) {
Write-Host "Failed to build and install pango"
Exit 1
}
cd C:\
cmd /c rmdir /s /q C:\pango
if (!$?) {
Write-Host "Failed to remove gtk checkout"
Exit 1
}

573
data/css/style.css Normal file
View file

@ -0,0 +1,573 @@
/*
GstPipelineStudio Website
====================
shamelessly stolen CSS from Pipewire
*/
/* GNOME Color Palette */
:root {
--rounded-corner: 12px;
--blue1: rgb(153, 193, 241);
--blue2: rgb(98, 160, 234);
--blue3: rgb(53, 132, 228);
--blue4: rgb(28, 113, 216);
--blue5: rgb(26, 95, 180);
--green1: rgb(143, 240, 164);
--green2: rgb(87, 227, 137);
--green3: rgb(51, 209, 122);
--green4: rgb(46, 194, 126);
--green5: rgb(38, 162, 105);
--yellow1: rgb(249, 240, 107);
--yellow2: rgb(248, 228, 92);
--yellow3: rgb(246, 211, 45);
--yellow4: rgb(245, 194, 17);
--yellow5: rgb(229, 165, 10);
--orange1: rgb(255, 190, 111);
--orange2: rgb(255, 163, 72);
--orange3: rgb(255, 120, 0);
--orange4: rgb(230, 97, 0);
--orange5: rgb(198, 70, 0);
--red1: rgb(246, 97, 81);
--red2: rgb(237, 51, 59);
--red3: rgb(224, 27, 36);
--red4: rgb(192, 28, 40);
--red5: rgb(165, 29, 45);
--purple1: rgb(220, 138, 221);
--purple2: rgb(192, 97, 203);
--purple3: rgb(145, 65, 172);
--purple4: rgb(129, 61, 156);
--purple5: rgb(97, 53, 131);
--brown1: rgb(205, 171, 143);
--brown2: rgb(181, 131, 90);
--brown3: rgb(152, 106, 68);
--brown4: rgb(134, 94, 60);
--brown5: rgb(99, 69, 44);
--light1: rgb(255, 255, 255);
--light2: rgb(246, 245, 244);
--light3: rgb(222, 221, 218);
--light4: rgb(192, 191, 188);
--light5: rgb(154, 153, 150);
--dark1: rgb(119, 118, 123);
--dark2: rgb(94, 92, 100);
--dark3: rgb(61, 56, 70);
--dark4: rgb(36, 31, 49);
--dark5: rgb(0, 0, 0);
--primary-color: var(--blue5);
/* Set your project color */
--borders: var(--light3);
}
/* Typography */
@font-face {
font-family: 'Inter Var';
font-weight: 100 900;
font-display: swap;
font-style: oblique 0deg 10deg;
src: url("fonts/Inter.var.woff2?v=3.19") format("woff2");
}
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html,
body {
margin: 0;
padding: 0;
font-size: 16px;
font-family: "Inter Var", sans-serif;
font-weight: 400;
line-height: 1.6;
}
body {
color: #241f31;
background-color: #f6f5f4;
min-height: 100vh;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 2rem 0 -6px;
font-weight: 600;
line-height: 1.25;
font-variation-settings: "wght" 600;
/* needed for webkit */
}
h1 {
font-size: 30px;
font-weight: 100;
font-style: normal;
margin: 3rem 0 2rem;
}
@media screen and (min-width: 650px) {
h1 {
font-size: 38px;
}
}
h2 {
font-size: 1.2rem;
}
@media (prefers-color-scheme: dark) {
body {
filter: invert(100%) hue-rotate(180deg);
}
html {
background-color: var(--dark5);
}
img,
video,
iframe {
filter: invert(100%) hue-rotate(180deg);
}
}
a {
font-weight: 600;
text-decoration: none;
color: var(--primary-color);
cursor: pointer;
font-variation-settings: "wght" 600;
/* needed for webkit */
}
a:hover {
text-decoration: underline;
}
b {
font-weight: 600;
}
small {
color: #777;
}
hr {
margin: 3rem auto 4rem;
width: 40%;
opacity: 40%;
}
img {
display: block;
margin: 2rem auto;
max-width: 100%;
}
img.full {
width: 100%;
}
img.pixels {
image-rendering: crisp-edges;
/* older firefox browsers */
image-rendering: pixelated;
}
/* Layout */
.container {
width: 80%;
margin-left: auto;
margin-right: auto;
max-width: 720px;
}
/* Singletons */
#logo {
display: block;
width: 35%;
height: 35%;
color: rgba(0, 0, 0, 0);
/* make text transparent */
background: url('../icons/org.freedesktop.dabrain34.GstPipelineStudio.ico') no-repeat center;
padding: 5rem 0 3rem;
margin: 0 auto;
}
.page-logo>img {
margin: 0 auto;
}
@media (prefers-color-scheme: dark) {
a.page-logo {
filter: invert(100%) hue-rotate(180deg);
/* uninvert */
background-image: url('assets/page-logo-i.svg');
}
}
.brand-white {
background-color: #fff;
}
.brand-green {
background-color: #30D475;
}
.brand-black {
background-color: #201A26;
color: white;
}
.page-link::after {
content: " ➜";
}
/* Footer */
footer {
text-align: center;
padding: 3em 0 3em;
font-size: 1em;
margin-top: 4rem;
}
/* Make tables vertically aligned to the top */
tbody td {
vertical-align: top;
}
/* Github Code Highlighting */
.highlight table td {
padding: 5px;
}
.highlight table pre {
margin: 0;
}
.highlight .cm {
color: #999988;
font-style: italic;
}
.highlight .cp {
color: #999999;
font-weight: bold;
}
.highlight .c1 {
color: #999988;
font-style: italic;
}
.highlight .cs {
color: #999999;
font-weight: bold;
font-style: italic;
}
.highlight .c,
.highlight .ch,
.highlight .cd,
.highlight .cpf {
color: #999988;
font-style: italic;
}
.highlight .err {
color: #a61717;
background-color: #e3d2d2;
}
.highlight .gd {
color: #000000;
background-color: #ffdddd;
}
.highlight .ge {
color: #000000;
font-style: italic;
}
.highlight .gr {
color: #aa0000;
}
.highlight .gh {
color: #999999;
}
.highlight .gi {
color: #000000;
background-color: #ddffdd;
}
.highlight .go {
color: #888888;
}
.highlight .gp {
color: #555555;
}
.highlight .gs {
font-weight: bold;
}
.highlight .gu {
color: #aaaaaa;
}
.highlight .gt {
color: #aa0000;
}
.highlight .kc {
color: #000000;
font-weight: bold;
}
.highlight .kd {
color: #000000;
font-weight: bold;
}
.highlight .kn {
color: #000000;
font-weight: bold;
}
.highlight .kp {
color: #000000;
font-weight: bold;
}
.highlight .kr {
color: #000000;
font-weight: bold;
}
.highlight .kt {
color: #445588;
font-weight: bold;
}
.highlight .k,
.highlight .kv {
color: #000000;
font-weight: bold;
}
.highlight .mf {
color: #009999;
}
.highlight .mh {
color: #009999;
}
.highlight .il {
color: #009999;
}
.highlight .mi {
color: #009999;
}
.highlight .mo {
color: #009999;
}
.highlight .m,
.highlight .mb,
.highlight .mx {
color: #009999;
}
.highlight .sb {
color: #d14;
}
.highlight .sc {
color: #d14;
}
.highlight .sd {
color: #d14;
}
.highlight .s2 {
color: #d14;
}
.highlight .se {
color: #d14;
}
.highlight .sh {
color: #d14;
}
.highlight .si {
color: #d14;
}
.highlight .sx {
color: #d14;
}
.highlight .sr {
color: #009926;
}
.highlight .s1 {
color: #d14;
}
.highlight .ss {
color: #990073;
}
.highlight .s,
.highlight .sa,
.highlight .dl {
color: #d14;
}
.highlight .na {
color: #008080;
}
.highlight .bp {
color: #999999;
}
.highlight .nb {
color: #0086B3;
}
.highlight .nc {
color: #445588;
font-weight: bold;
}
.highlight .no {
color: #008080;
}
.highlight .nd {
color: #3c5d5d;
font-weight: bold;
}
.highlight .ni {
color: #800080;
}
.highlight .ne {
color: #990000;
font-weight: bold;
}
.highlight .nf,
.highlight .fm {
color: #990000;
font-weight: bold;
}
.highlight .nl {
color: #990000;
font-weight: bold;
}
.highlight .nn {
color: #555555;
}
.highlight .nt {
color: #000080;
}
.highlight .vc {
color: #008080;
}
.highlight .vg {
color: #008080;
}
.highlight .vi {
color: #008080;
}
.highlight .nv,
.highlight .vm {
color: #008080;
}
.highlight .ow {
color: #000000;
font-weight: bold;
}
.highlight .o {
color: #000000;
font-weight: bold;
}
.highlight .w {
color: #bbbbbb;
}
.highlight {
background-color: #f8f8f8;
}
/* Code Blocks */
.highlighter-rouge {
padding: 2px 1rem;
border-radius: 5px;
background-color: white;
overflow: auto;
}
.highlighter-rouge * {
background-color: white;
}
/* Inline Code */
code.highlighter-rouge {
padding: 2px 6px;
background-color: rgba(0, 0, 0, 0.07);
}
/* Buttons */
.dialog-buttons {
display: flex;
flex-direction: row;
align-items: baseline;
justify-content: space-between;
margin-top: 6rem;
}
.inline-button {
display: inline-block;
font-weight: 900;
font-size: 90%;
padding: .4rem 1rem;
border-radius: var(--rounded-corner);
background-color: rgba(0, 0, 0, 0.05);
color: var(--dark5);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View file

@ -27,6 +27,8 @@ install_data(
appdata_conf = configuration_data()
appdata_conf.set('app-id', application_id)
appdata_conf.set('gettext-package', gettext_package)
appdata_conf.set('version', version)
appdata_conf.set('current_date', current_date)
appdata_file = i18n.merge_file (
input: configure_file(
input: '@0@.appdata.xml.in.in'.format(base_id),

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2019 Guillaume Desmottes 2019 <guillaume@desmottes.be -->
<!-- Copyright 2022 Stephane Cerveau 2022 <scerveau@collabora.com -->
<component type="desktop-application">
<id>@app-id@</id>
<metadata_license>CC0</metadata_license>
@ -15,7 +15,7 @@
<caption>Composition</caption>
</screenshot>
</screenshots>
<url type="homepage">https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio</url>
<url type="homepage">https://dabrain34.pages.freedesktop.org/GstPipelineStudio</url>
<url type="bugtracker">https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio/issues</url>
<categories>
<category>Audio</category>
@ -27,7 +27,17 @@
<translation type="gettext">@gettext-package@</translation>
<launchable type="desktop-id">@app-id@.desktop</launchable>
<releases>
<release version="0.1.0" date="2022-01-11"/>
<release version="@version@" date="@current_date@">
<description>
<p>Welcome to GstPipelineStudio</p>
<ul>
<li>logs: receive multiple log sources such as GST logs and messages.</li>
<li>settings: add a log level selection</li>
<li>rename gst_pipeline_studio to gst-pipeline-studio</li>
<li>can open a pipeline from the command line</li>
</ul>
</description>
</release>
</releases>
<content_rating type="oars-1.1">
<content_attribute id="violence-cartoon">none</content_attribute>

View file

@ -3,7 +3,7 @@ Name=GstPipelineStudio
GenericName=GPS
Comment=A GUI for GStreamer
Type=Application
Exec=gst_pipeline_studio
Exec=gst-pipeline-studio
Terminal=false
Categories=AudioVideo;Audio;Video;Midi;Settings;GNOME;GTK;
Icon=@icon@

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 210 KiB

53
index.html Normal file
View file

@ -0,0 +1,53 @@
<html>
< <head>
<title>GstPipelineStudio</title>
<link rel="stylesheet" href="data/css/style.css">
<link rel="icon" href="data/icons/org.freedesktop.dabrain34.GstPipelineStudio.ico">
</head>
<body>
<div class="container">
<h1 id="logo"></h1>
<h1>GstPipelineStudio: Draw your own pipeline ...</h1>
<p><img src="data/screenshots/gps_screenshot.png" alt=""></p>
<p>GstPipelineStudio aims to provide a graphical user interface to the GStreamer framework. From a first
step in the framework with a simple pipeline to a complex pipeline debugging, the tool provides a
friendly interface to add elements to a pipeline and debug it.</p>
<h2>GstPipelineStudio 0.3.5 is out, checkout the <a
href="https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio/-/blob/main/ChangeLog.md?ref_type=heads#anchor-033">
Release Notes</a> !
<br>
<br>
<p>Download:</p>
<ul>
<li><a href="https://flathub.org/apps/org.freedesktop.dabrain34.GstPipelineStudio">Flathub</a></li>
<li><a
href="https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio/uploads/0ab4098a9385f21d72881d27530e6e27/GstPipelineStudio-0.3.5.msi">Windows
MSI</a>
</li>
<li><a
href="https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio/uploads/d6d703809e3023de04e7ad1449fcb4aa/GstPipelineStudio-0.3.5.dmg">MacOS</a>
</li>
</ul>
<h2 id="getting-gps">Contributing to GstPipelineStudio</h2>
<p>If you want to get the the code from Gitlab, you can visit this <a
href="https://flathub.org/apps/org.freedesktop.dabrain34.GstPipelineStudio">webpage</a>
and follow the <a
href="https://flathub.org/apps/org.freedesktop.dabrain34.GstPipelineStudio/README.md">README</a>
to build your own version of GstPipelineStudio.
</p>
</h2>
</body>
<footer class="site-footer">
<p>&copy; GstPipelineStudio, 2023</p>
<p><a href="https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio">Website source</a></p>
</footer>
</html>

17
installer/macos/brew_setup.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
HOMEBREW_NO_INSTALL_CLEANUP=1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install pkg-config
# GTK4 support
brew install gtk4
# brew install cairo libxrandr libxi libxcursor libxdamage libxinerama
brew install npm
npm install -g appdmg
exit 0

186
installer/macos/deploy_macos.sh Executable file
View file

@ -0,0 +1,186 @@
#!/bin/bash
test_ok() {
$*
if [ $? != 0 ]; then
exit 1
fi
}
# dependency library:
# Make a .app file: https://gist.github.com/oubiwann/453744744da1141ccc542ff75b47e0cf
# Make a .dmg file: https://github.com/LinusU/node-appdmg
# Can't find library: https://www.jianshu.com/p/441a7553700f
BUILD_DIR=builddir
PROJECTDIR="$( cd "$(dirname "$0")/../" ; pwd -P )"
TARGETDIR="${PROJECTDIR}/${BUILD_DIR}/INSTALL_GPS"
VERSION="$(cat VERSION)"
export VERSION
echo "VERSION=$VERSION"
GSTREAMER_OPTS="
-Dforce_fallback_for=gstreamer-1.0,libffi,pcre2 \
-Dgstreamer-1.0:libav=disabled \
-Dgstreamer-1.0:examples=disabled \
-Dgstreamer-1.0:introspection=disabled \
-Dgstreamer-1.0:rtsp_server=disabled \
-Dgstreamer-1.0:devtools=disabled \
-Dgst-plugins-base:tests=disabled \
-Dgstreamer-1.0:tests=disabled \
-Dgst-plugins-bad:openexr=disabled -Dgstreamer-1.0:gst-examples=disabled \
-Dorc:gtk_doc=disabled \
-Dgstreamer-1.0:ges=disabled \
-Dgstreamer-1.0:python=disabled"
# rebuild app release version
rm -rf "${TARGETDIR}"
test_ok meson --prefix=$TARGETDIR --buildtype=release ${BUILD_DIR} ${GSTREAMER_OPTS}
test_ok ninja -C ${BUILD_DIR} install
# copy app data files to target dir
echo -n "Copy app data files......"
test_ok mkdir -p "${TARGETDIR}/etc/"
mkdir -p "${TARGETDIR}/lib/gstreamer-1.0"
mkdir -p "${TARGETDIR}/share/doc"
mkdir -p "${TARGETDIR}/share/themes"
mkdir -p "${TARGETDIR}/share/glib-2.0/schemas"
mkdir -p "${TARGETDIR}/share/licenses/GstPipelineStudio"
mkdir -p "${TARGETDIR}/share/icons/hicolor/scalable/apps"
echo "[done]"
function lib_dependency_copy
{
local target=$1
local folder=$2
lib_dir="$( cd "$( dirname "$1" )" >/dev/null 2>&1 && pwd )"
libraries="$(otool -L $target | grep "/*.*dylib" -o | xargs)"
for lib in $libraries; do
if [[ '/usr/lib/' != ${lib:0:9} && '/System/Library/' != ${lib:0:16} ]]; then
if [[ '@' == ${lib:0:1} ]]; then
if [[ '@loader_path' == ${lib:0:12} ]]; then
cp -n "${lib/@loader_path/$lib_dir}" $folder
else
echo "Unsupported path: $lib"
fi
else
if [[ $lib != $target ]]; then
cp -n $lib $folder
fi
fi
fi
done
}
function lib_dependency_analyze
{
# This function use otool to analyze library dependency.
# then copy the dependency libraries to destination path
local library_dir=$1
local targets_dir=$2
libraries="$(find $library_dir -name \*.dylib -o -name \*.so -type f)"
for lib in $libraries; do
lib_dependency_copy $lib $targets_dir
# otool -L $lib | grep "/usr/local/*.*dylib" -o | xargs -I{} cp -n "{}" "$targets_dir"
done
}
# copy app dependency library to target dir
echo -n "Copy app dependency library......"
lib_dependency_copy ${TARGETDIR}/bin/gst-pipeline-studio "${TARGETDIR}/bin"
lib_dependency_copy ${TARGETDIR}/lib/libgobject-2.0.0.dylib "${TARGETDIR}/bin"
lib_dependency_copy ${TARGETDIR}/lib/libsoup-2.4.1.dylib "${TARGETDIR}/bin"
lib_dependency_copy "${TARGETDIR}/bin/libgtk-4.1.dylib" "${TARGETDIR}/bin"
for file in ${TARGETDIR}/lib/gstreamer-1.0/*.dylib
do
echo "${file}"
lib_dependency_copy ${file} "${TARGETDIR}/lib/"
done
test_ok cp -f "${PROJECTDIR}/macos/mac_launcher.sh" "${TARGETDIR}/bin/launcher.sh"
# FIXME should build and install gtk4 instead of using homebrew
# copy GTK runtime dependencies resource
# echo -n "Copy GTK runtime resource......"
# cp -rf /usr/local/lib/gio "${TARGETDIR}/lib/"
# cp -rf /usr/local/lib/gtk-3.0 "${TARGETDIR}/lib/"
# cp -rf /usr/local/lib/gdk-pixbuf-2.0 "${TARGETDIR}/lib/"
# cp -rf /usr/local/lib/girepository-1.0 "${TARGETDIR}/lib/"
# cp -rf /usr/local/lib/libgda-5.0 "${TARGETDIR}/lib/"
# # Avoid override the latest locale file
cp -r /opt/homebrew/share/locale "${TARGETDIR}/share/"
cp -rf /opt/homebrew/share/icons "${TARGETDIR}/share/"
cp -rf /opt/homebrew/share/gtk4-0 "${TARGETDIR}/share/"
# cp -rf /usr/local/share/fontconfig "${TARGETDIR}/share/"
# cp -rf /usr/local/share/themes/Mac "${TARGETDIR}/share/themes/"
# cp -rf /usr/local/share/themes/Default "${TARGETDIR}/share/themes/"
# cp -rf /usr/local/share/gtksourceview-4 "${TARGETDIR}/share/"
# glib-compile-schemas /usr/local/share/glib-2.0/schemas
# cp -f /usr/local/share/glib-2.0/schemas/gschema* "${TARGETDIR}/share/glib-2.0/schemas"
# # find "${TARGETDIR}/bin" -type f -path '*.dll.a' -exec rm '{}' \;
lib_dependency_analyze ${TARGETDIR}/lib ${TARGETDIR}/bin
lib_dependency_analyze ${TARGETDIR}/bin ${TARGETDIR}/bin
echo "[done]"
# copy app icons and license files to target dir
echo -n "Copy app icon(svg) files......"
cp -f "${PROJECTDIR}/../data/icons/org.freedesktop.dabrain34.GstPipelineStudio.ico" "${TARGETDIR}/bin"
cp -f "${PROJECTDIR}/../data/icons/org.freedesktop.dabrain34.GstPipelineStudio.svg" "${TARGETDIR}/share/icons/hicolor/scalable/apps"
echo "[done]"
# download license file: LGPL-3.0
echo -n "Downloading the remote license file......"
cp -f "${PROJECTDIR}/../LICENSE" "${TARGETDIR}/share/licenses/GstPipelineStudio"
if [ ! -f "${TARGETDIR}/share/licenses/GstPipelineStudio/gpl-3.0.txt" ]; then
curl "https://www.gnu.org/licenses/gpl-3.0.txt" -o "${TARGETDIR}/share/licenses/GstPipelineStudio/gpl-3.0.txt"
if [ $? -eq 0 ]; then
echo "[done]"
else
echo "[failed]"
fi
else
echo "[done]"
fi
echo "make macos executable file(.app)......"
cd "${PROJECTDIR}/${BUILD_DIR}"
cp "${PROJECTDIR}/macos/installers/Info.plist" "${PROJECTDIR}/${BUILD_DIR}"
cp "${PROJECTDIR}/macos/installers/mac.icns" "${PROJECTDIR}/${BUILD_DIR}/GstPipelineStudio.icns"
../macos/mac_app_pack.sh --path "${TARGETDIR}" --name "GstPipelineStudio" --info "Info.plist" --icons "GstPipelineStudio.icns"
if [ $? -eq 0 ]; then
echo "[done]"
else
echo "[failed]"
fi
# make installer package
echo "make macos installer(.dmg)......"
cp "${PROJECTDIR}/macos/installers/dmg.json" gps_dmg.json
cp "${PROJECTDIR}/macos/installers/background.png" "${PROJECTDIR}/${BUILD_DIR}/gps_dmg_background.png"
rm -f ${PROJECTDIR}/GstPipelineStudio-${VERSION}.dmg
appdmg gps_dmg.json "${PROJECTDIR}/GstPipelineStudio-${VERSION}.dmg"
if [ $? -eq 0 ]; then
echo "[done]"
else
echo "[failed]"
fi
# make portable package
echo -n "make macos portable......"
tar czf "${PROJECTDIR}/GstPipelineStudio-${VERSION}.tar.gz" -C "${PROJECTDIR}" ${BUILD_DIR}/GstPipelineStudio.app
if [ $? -eq 0 ]; then
echo "[done]"
else
echo "[failed]"
fi

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!-- Reference: https://github.com/geany/geany-osx/blob/master/Info.plist -->
<dict>
<key>CFBundleShortVersionString</key>
<string>1.36</string>
<key>CFBundleVersion</key>
<string>1.36</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright (C)2022 Stephane Cerveau</string>
<key>CFBundleGetInfoString</key>
<string>Copyright (C)2022 Stephane Cerveau</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleName</key>
<string>GstPipelineStudio</string>
<key>GtkOSXLaunchScriptFile</key>
<string>launcher.sh</string>
<key>CFBundleExecutable</key>
<string>gst-pipeline-studio</string>
<key>CFBundleIconFile</key>
<string>GstPipelineStudio.icns</string>
<key>CFBundleIdentifier</key>
<string>org.freedesktop.dabrain34.GstPipelineStudio</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>LSMinimumSystemVersion</key>
<string>10.9</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

View file

@ -0,0 +1,9 @@
{
"title": "GstPipelineStudio installer",
"icon": "GstPipelineStudio.icns",
"background": "gps_dmg_background.png",
"contents": [
{ "x": 948, "y": 270, "type": "link", "path": "/Applications" },
{ "x": 692, "y": 270, "type": "file", "path": "GstPipelineStudio.app" }
]
}

Binary file not shown.

131
installer/macos/mac_app_pack.sh Executable file
View file

@ -0,0 +1,131 @@
#!/usr/bin/env bash
VERSION=4.0.1
SCRIPT=`basename "$0"`
APP_NAME="GstPipelineStudio"
APP_ICONS="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericApplicationIcon.icns"
OSX_VERSION=`sw_vers -productVersion`
PWD=`pwd`
function usage {
cat <<EOF
$SCRIPT v${VERSION} for for Mac OS X
Usage:
$SCRIPT [options]
Options:
-h, --help Prints this help message, then exits
-p, --path Name of the path to 'appify' (required)
-n, --name Name of the application (default "$APP_NAME")
-o, --info Name of the Info.plist
-i, --icons Name of the icons file to use when creating the app
(defaults to $APP_ICONS)
-v, --version Prints the version of this script, then exits
Description:
Creates the GTK Mac app from a GTK install path.
Appify has one required parameter, the path to appify:
$SCRIPT --path gtk-app-install-path
Note that you cannot rename appified apps. If you want to give your app
a custom name, use the '--name' option
$SCRIPT --path gtk-app-install-path --name "Sweet"
Copyright:
Copyright (c) Thomas Aylott <http://subtlegradient.com/>
Modified by Mathias Bynens <http://mathiasbynens.be/>
Modified by Andrew Dvorak <http://OhReally.net/>
Rewritten by Duncan McGreggor <http://github.com/oubiwann/>
Modified by Zuhong Tao <https://github.com/taozuhong>
EOF
exit 1
}
function version {
echo "v${VERSION}"
exit 1
}
function error {
echo
echo "ERROR: $1"
echo
usage
}
while :; do
case $1 in
-h | --help ) usage;;
-p | --path ) APP_BUILD="$2"; shift ;;
-n | --name ) APP_NAME="$2"; shift ;;
-o | --info ) APP_INFO="$2"; shift ;;
-i | --icons ) APP_ICONS="$2"; shift ;;
-v | --version ) version;;
-- ) shift; break ;;
* ) break ;;
esac
shift
done
if [ -z ${APP_BUILD+nil} ]; then
error "The GTK app path to appify must be provided!"
fi
if [ ! -d "$APP_BUILD" ]; then
error "Can't find the target path '$APP_BUILD'"
fi
if [ -a "$APP_NAME.app" ]; then
rm -rf "$APP_NAME.app"
fi
SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
APP_OUT_DIR="$( cd "$(dirname "$APP_BUILD")" >/dev/null 2>&1 ; pwd -P )"
APP_TOP_DIR=$APP_OUT_DIR/$APP_NAME.app
APP_CON_DIR=$APP_TOP_DIR/Contents
APP_RES_DIR=$APP_CON_DIR/Resources
APP_EXE_DIR=$APP_CON_DIR/MacOS
APP_ETC_DIR=$APP_RES_DIR/etc
APP_LIB_DIR=$APP_RES_DIR/lib
# Copy GstPipelineStudio.app resource
mkdir -vp "$APP_CON_DIR"/{MacOS,Resources}
cp -f "$APP_INFO" "$APP_CON_DIR/Info.plist"
cp -f "$APP_ICONS" "$APP_RES_DIR/$APP_NAME.icns"
cp -rf "$APP_BUILD/etc" "$APP_RES_DIR"
cp -rf "$APP_BUILD/lib" "$APP_RES_DIR"
cp -rf "$APP_BUILD/share" "$APP_RES_DIR"
cp -rf "$APP_BUILD/libexec" "$APP_RES_DIR"
cp $APP_BUILD/bin/gst-pipeline-studio $APP_EXE_DIR/gst-pipeline-studio-real
cp $APP_BUILD/bin/launcher.sh $APP_EXE_DIR/gst-pipeline-studio
chmod 766 "$APP_EXE_DIR/gst-pipeline-studio"
chmod 766 "$APP_EXE_DIR/gst-pipeline-studio-real"
chmod -R 766 "$APP_RES_DIR"/libexec/gstreamer-1.0
# Copy dependency libraries and update their search path
source $SCRIPT_PATH/mac_app_path.sh
if ls $APP_BUILD/bin/*.so 1> /dev/null 2>&1; then
for sofile in $APP_BUILD/bin/*.so; do
cp $sofile $APP_LIB_DIR
done
fi
cp $APP_BUILD/bin/*.dylib $APP_LIB_DIR
chmod -R 766 $APP_LIB_DIR
echo -n "relocate the gstreamer plugins......"
for file in $APP_LIB_DIR/gstreamer-1.0/*.dylib
do
echo "relocating ${file}"
lib_change_paths \
@executable_path/../Resources/lib \
$APP_LIB_DIR \
${file}
done
lib_change_paths \
@executable_path/../Resources/lib \
$APP_LIB_DIR \
$APP_EXE_DIR/gst-pipeline-studio-real
lib_change_siblings $APP_LIB_DIR @loader_path
echo "Mac app bundled at '$APP_TOP_DIR'"

119
installer/macos/mac_app_path.sh Executable file
View file

@ -0,0 +1,119 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# https://gitlab.com/inkscape/inkscape/-/blob/master/packaging/macos/bash_d/lib_.sh
# examples:
# lib_change_path \
# @executable_path/../Resources/lib/lib2geom.1.0.0.dylib \
# $APP_LIB_DIR/inkscape/libinkscape_base.dylib \
# $APP_EXE_DIR/inkscape
#
#lib_change_paths \
# @executable_path/../lib \
# $APP_LIB_DIR \
# $APP_BIN_DIR/gs
#
# lib_change_siblings $APP_LIB_DIR dylib
# lib_change_siblings $APP_LIB_DIR so
# include_guard
### includes ###################################################################
# Nothing here.
### variables ##################################################################
# Nothing here.
### functions ##################################################################
function lib_change_path
{
# This is a simple wrapper around install_name_tool to reduce the
# number of arguments (like $source does not have to be provided
# here as it can be deducted from $target).
# Also, the requested change can be applied to multiple binaries
# at once since 2-n arguments can be supplied.
local target=$1 # new path to dynamically linked library
local binaries=${*:2} # binaries to modify
local source_lib=${target##*/} # get library filename from target location
for binary in $binaries; do # won't work with spaces in paths
if [[ $binary == *.so ]] || [[ $binary == *.dylib ]]; then
lib_reset_id $binary
fi
local source=$(otool -L $binary | grep $source_lib | awk '{ print $1 }')
install_name_tool -change $source $target $binary
done
}
function lib_change_paths
{
# This is a slightly more advanced wrapper around install_name_tool.
# Given a directory $lib_dir that contains the libraries, all libraries
# linked in $binary can be changed at once to a specified $target path.
local target=$1 # new path to dynamically linked library
local lib_dir=$2
local binaries=${*:3}
for binary in $binaries; do
if [[ $binary == *.so ]] || [[ $binary == *.dylib ]]; then
lib_reset_id $binary
fi
for linked_lib in $(otool -L $binary | tail -n +2 | awk '{ print $1 }'); do
if [ "$(basename $binary)" != "$(basename $linked_lib)" ] &&
[ -f $lib_dir/$(basename $linked_lib) ]; then
lib_change_path $target/$(basename $linked_lib) $binary
fi
done
done
}
function lib_change_siblings
{
# This is a slightly more advanced wrapper around install_name_tool.
# All libraries inside a given $dir that are linked to libraries present
# in that $dir can be automatically adjusted.
local dir=$1
local target=$2
for lib in $dir/*.dylib; do
lib_reset_id $lib
for linked_lib in $(otool -L $lib | tail -n +2 | awk '{ print $1 }'); do
if [ "$(basename $lib)" != "$(basename $linked_lib)" ] &&
[ -f $dir/$(basename $linked_lib) ]; then
lib_change_path $target/$(basename $linked_lib) $lib
fi
done
done
if ls $dir/*.so 1> /dev/null 2>&1; then
for lib in $dir/*.so; do
lib_reset_id $lib
for linked_lib in $(otool -L $lib | tail -n +2 | awk '{ print $1 }'); do
if [ "$(basename $lib)" != "$(basename $linked_lib)" ] &&
[ -f $dir/$(basename $linked_lib) ]; then
lib_change_path $target/$(basename $linked_lib) $lib
fi
done
done
fi
}
function lib_reset_id
{
local lib=$1
install_name_tool -id $(basename $lib) $lib
}
### aliases ####################################################################
# Nothing here.
### main #######################################################################
# Nothing here.

170
installer/macos/mac_launcher.sh Executable file
View file

@ -0,0 +1,170 @@
#!/bin/sh
if test "x$GTK_DEBUG_LAUNCHER" != x; then
set -x
fi
if test "x$GTK_DEBUG_GDB" != x; then
EXEC="gdb --args"
else
EXEC=exec
fi
name=`basename "$0"`
bundle_app="$( cd "$( dirname "$0" )/../.." >/dev/null 2>&1 && pwd )"
bundle_contents="$bundle_app"/Contents
bundle_res="$bundle_contents"/Resources
bundle_lib="$bundle_res"/lib
bundle_libexec="$bundle_res"/libexec
bundle_bin="$bundle_res"/bin
bundle_data="$bundle_res"/share
bundle_etc="$bundle_res"/etc
export DYLD_LIBRARY_PATH="$bundle_lib"
export XDG_CONFIG_DIRS="$bundle_etc"/xdg
export XDG_DATA_DIRS="$bundle_data"
export GTK_DATA_PREFIX="$bundle_res"
export GTK_EXE_PREFIX="$bundle_res"
export GTK_PATH="$bundle_res"
export GST_PLUGIN_SCANNER="$bundle_libexec/gstreamer-1.0/gst-plugin-scanner"
export GIO_EXTRA_MODULES="$bundle_lib/gio/modules"
# GIO modules
export GIO_MODULE_DIR="$bundle_lib/gio/modules"
#GStreamer plugins
export GST_PLUGIN_PATH="$bundle_lib/gstreamer-1.0"
APP=$name
I18NDIR="$bundle_data/locale"
# Set the locale-related variables appropriately:
unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE
# Has a language ordering been set?
# If so, set LC_MESSAGES and LANG accordingly; otherwise skip it.
# First step uses sed to clean off the quotes and commas, to change - to _, and change the names for the chinese scripts from "Hans" to CN and "Hant" to TW.
APPLELANGUAGES=`defaults read .GlobalPreferences AppleLanguages | sed -En -e 's/\-/_/' -e 's/Hant/TW/' -e 's/Hans/CN/' -e 's/[[:space:]]*\"?([[:alnum:]_]+)\"?,?/\1/p' `
if test "$APPLELANGUAGES"; then
# A language ordering exists.
# Test, item per item, to see whether there is an corresponding locale.
for L in $APPLELANGUAGES; do
#test for exact matches:
if test -f "$I18NDIR/${L}/LC_MESSAGES/$APP.mo"; then
export LANG=$L
break
fi
#This is a special case, because often the original strings are in US
#English and there is no translation file.
if test "x$L" == "xen_US"; then
export LANG=$L
break
fi
#OK, now test for just the first two letters:
if test -f "$I18NDIR/${L:0:2}/LC_MESSAGES/$APP.mo"; then
export LANG=${L:0:2}
break
fi
#Same thing, but checking for any english variant.
if test "x${L:0:2}" == "xen"; then
export LANG=$L
break
fi;
done
fi
unset APPLELANGUAGES L
# If we didn't get a language from the language list, try the Collation preference, in case it's the only setting that exists.
APPLECOLLATION=`defaults read .GlobalPreferences AppleCollationOrder`
if test -z ${LANG} -a -n $APPLECOLLATION; then
if test -f "$I18NDIR/${APPLECOLLATION:0:2}/LC_MESSAGES/$APP.mo"; then
export LANG=${APPLECOLLATION:0:2}
fi
fi
if test ! -z $APPLECOLLATION; then
export LC_COLLATE=$APPLECOLLATION
fi
unset APPLECOLLATION
# Continue by attempting to find the Locale preference.
APPLELOCALE=`defaults read .GlobalPreferences AppleLocale`
if test -f "$I18NDIR/${APPLELOCALE:0:5}/LC_MESSAGES/$APP.mo"; then
if test -z $LANG; then
export LANG="${APPLELOCALE:0:5}"
fi
elif test -z $LANG -a -f "$I18NDIR/${APPLELOCALE:0:2}/LC_MESSAGES/$APP.mo"; then
export LANG="${APPLELOCALE:0:2}"
fi
#Next we need to set LC_MESSAGES. If at all possible, we want a full
#5-character locale to avoid the "Locale not supported by C library"
#warning from Gtk -- even though Gtk will translate with a
#two-character code.
if test -n $LANG; then
#If the language code matches the applelocale, then that's the message
#locale; otherwise, if it's longer than two characters, then it's
#probably a good message locale and we'll go with it.
if test $LANG == ${APPLELOCALE:0:5} -o $LANG != ${LANG:0:2}; then
export LC_MESSAGES=$LANG
#Next try if the Applelocale is longer than 2 chars and the language
#bit matches $LANG
elif test $LANG == ${APPLELOCALE:0:2} -a $APPLELOCALE > ${APPLELOCALE:0:2}; then
export LC_MESSAGES=${APPLELOCALE:0:5}
#Fail. Get a list of the locales in $PREFIX/share/locale that match
#our two letter language code and pick the first one, special casing
#english to set en_US
elif test $LANG == "en"; then
export LC_MESSAGES="en_US"
else
LOC=`find $PREFIX/share/locale -name $LANG???`
for L in $LOC; do
export LC_MESSAGES=$L
done
fi
else
#All efforts have failed, so default to US english
export LANG="en_US"
export LC_MESSAGES="en_US"
fi
CURRENCY=`echo $APPLELOCALE | sed -En 's/.*currency=([[:alpha:]]+).*/\1/p'`
if test "x$CURRENCY" != "x"; then
#The user has set a special currency. Gtk doesn't install LC_MONETARY files, but Apple does in /usr/share/locale, so we're going to look there for a locale to set LC_CURRENCY to.
if test -f /usr/local/share/$LC_MESSAGES/LC_MONETARY; then
if test -a `cat /usr/local/share/$LC_MESSAGES/LC_MONETARY` == $CURRENCY; then
export LC_MONETARY=$LC_MESSAGES
fi
fi
if test -z "$LC_MONETARY"; then
FILES=`find /usr/share/locale -name LC_MONETARY -exec grep -H $CURRENCY {} \;`
if test -n "$FILES"; then
export LC_MONETARY=`echo $FILES | sed -En 's%/usr/share/locale/([[:alpha:]_]+)/LC_MONETARY.*%\1%p'`
fi
fi
fi
#No currency value means that the AppleLocale governs:
if test -z "$LC_MONETARY"; then
LC_MONETARY=${APPLELOCALE:0:5}
fi
#For Gtk, which only looks at LC_ALL:
export LC_ALL=$LC_MESSAGES
unset APPLELOCALE FILES LOC
if test -f "$bundle_lib/charset.alias"; then
export CHARSETALIASDIR="$bundle_lib"
fi
# Extra arguments can be added in environment.sh.
EXTRA_ARGS=
if test -f "$bundle_res/environment.sh"; then
source "$bundle_res/environment.sh"
fi
# Strip out the argument added by the OS.
if /bin/expr "x$1" : '^x-psn_' > /dev/null; then
shift 1
fi
$EXEC "$bundle_contents/MacOS/gst-pipeline-studio-real" "$@" $EXTRA_ARGS

94
installer/wix/LICENSE.rtf Normal file
View file

@ -0,0 +1,94 @@
{\rtf1\ansi\deff3\adeflang1025
{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset128 Liberation Serif{\*\falt Times New Roman};}{\f4\fswiss\fprq2\fcharset128 Liberation Sans{\*\falt Arial};}{\f5\froman\fprq2\fcharset128 Times New Roman;}{\f6\froman\fprq0\fcharset128 Times New Roman;}{\f7\fnil\fprq2\fcharset128 Droid Sans;}{\f8\fnil\fprq2\fcharset128 FreeSans;}{\f9\fswiss\fprq0\fcharset128 FreeSans;}}
{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031 Normal;}
{\s15\sbasedon0\snext16\sb240\sa120\keepn\hich\af7\dbch\af8\afs28\loch\f4\fs28 Heading;}
{\s16\sbasedon0\snext16\sb0\sa120 Text body;}
{\s17\sbasedon16\snext17\sb0\sa120\dbch\af9 List;}
{\s18\sbasedon0\snext18\sb120\sa120\noline\i\dbch\af9\afs24\ai\fs24 Caption;}
{\s19\sbasedon0\snext19\noline\dbch\af9 Index;}
}{\info{\creatim\yr0\mo0\dy0\hr0\min0}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern3500}}\deftab720
{\*\pgdsctbl
{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\pgdscnxt0 Default;}}
\formshade{\*\pgdscno0}\paperh15840\paperw12240\margl1800\margr1800\margt1440\margb1440\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\fs44\lang255\loch\f6
}{\b\rtlch \ltrch\loch\fs44\lang255\loch\f6
Installer, default installation}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
The installer (Microsoft Windows and MacOSX) and the default installation (GNU/Linux) contain and install the minimal default installation. At install time or later, the downloading of optional components is also possible, but read on for certain legal cautions you might want to take. All downloads are from the freedesktop.org website.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs44\lang255\loch\f6
Licensing GStreamer}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
Gstreamer minimal default installation only contains packages which are licensed under the GNU LGPL license v2.1. This license gives you the Freedom to use, modify, make copies of the software either in the original or in a modified form, provided that the software you redistribute is licensed under the same licensing terms. This only extends to the software itself and modified versions of it, but you are free to link the LGPL software as a library used by other software under whichever license. In other words, it is a weak copyleft license.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
Therefore, it is possible to use GStreamer to build applications that are then distributed under a different license, including a proprietary one, provided that reverse engineering is not prohibited for debugging modifications purposes. Only the pieces of GStreamer that are under the LGPL need to be kept under the LGPL, and the corresponding source code must be distributed along with the application (or an irrevocable offer to do so for at least three years from distribution). Please consult section 6 of the LGPL for further details as to what the corresponding source code must contain.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
Some portions of the minimal default installation may be under different licenses, which are both more liberal than the LGPL (they are less strict conditions for granting the license) and compatible with the LGPL. This is advised locally.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs44\lang255\loch\f6
Optional packages}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
There are two types of optional packages, which are under a different license or have other issues concerning patentability (or both).}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs36\lang255\loch\f6
GPL code}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
Part of the optional packages are under the GNU GPL v2 or v3. This means that you cannot link the GPL software in a program unless the same program is also under the GPL, but you are invited to seek competent advice on how this works in your precise case and design choices. GPL is called \uc3 \u8220\'e2\'80\'9cstrong copyleft\u8221\'e2\'80\'9d because the condition to distributed under the same license has the largest possible scope and extends to all derivative works.\uc1 }
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs36\lang255\loch\f6
Patents}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
Certain software, and in particular software that implements multimedia standard formats such as Mp3, MPEG 2 video and audio, h.264, MPEG 4 audio and video, AC3, etc, can have patent issues. In certain countries patents are granted on software and even software-only solution are by and large considered patentable and are patented (such as in the United States). In certain others, patents on pure software solutions are formally prohibited, but granted (this is the case of Europe), and in others again are neither allowed nor granted.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
It is up to you to make sure that in the countries where GStreamer is used, products are made using it and product are distributed, a license from the applicable patent holders is required or not. Receiving GStreamer \uc3 \u8211\'e2\'80\'93 or links to other downloadable software \u8211\'e2\'80\'93 does not provide any license expressed or implied over these patents, except in very limited conditions where the license so provides. No representation is made.\uc1 }
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
In certain cases, the optional packages are distributed only as source code. It is up the receiver to make sure that in the applicable circumstances compiling the same code for a given platform or distributing the object code is an act that infringes one or more patents.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs44\lang255\loch\f6
Software is as-is}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
All software and GStreamer is provided as-is, without any warranty whatsoever. The individual licenses have particular language disclaiming liability: we invite you to read all of them. Should you need a warranty on the fact that software works as intended or have any kind of indemnification, you have the option to subscribe a software maintenance agreement with a company or entity that is in that business. Fluendo and Collabora, as well as some other companies, provide software maintenance agreements under certain conditions, you are invited to contact them in order to receive further details and discuss of the commercial terms.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs44\lang255\loch\f6
Data protection}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
This website might use cookies and HTTP logs for statistical analysis and on an aggregate basis only.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs44\lang255\loch\f6
Frequently Asked Questions}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs36\lang255\loch\f6
What licenses are there?}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
GStreamer containst software under various licenses. See above.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs36\lang255\loch\f6
How does this relate to the packaging system?}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
The packaging is only a more convenient way to install software and decide what's good for you. GStreamer is meant to be modular, making use of different modules, or plugins, that perform different activities.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
We provide some of them by default. Others are provided as an additional download, should you elect to do so. You could do the same by finding and downloading the same packages for your own platform. So it is entirely up to you to decide what to do.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
Also, we note that GStreamer elements are divided into different packages, roughly following the licensing conditions attached to the same. For instance, the codecs-gpl package contains GPL licensed codecs. All the packages installed by default, conversely, are licensed under the LGPL or a more liberal license. This division is provided only for ease of reference, but we cannot guarantee that our selection is 100% correct, so it is up to the user to verify the actual licensing conditions before distributing works that utilize GStreamer.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs36\lang255\loch\f6
Can I / must I distribute GStreamer along with my application?}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
You surely can. All software is Free/Open Source software, and can be distributed freely. You are not required to distribute it. Only, be reminded that one of the conditions for you to use software under certain licenses to make a work containing such software, is that you also distribute the complete source code of the original code (or of the modified code, if you have modified it). There are alternative ways to comply with this obligation, some of them do not require any actual distribution of source code, but since GStreamer contains the entire source code, you might want to include it (or the directories containing the source code) with your application as a safe way to comply with this requirement of the license.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs36\lang255\loch\f6
What happens when I modify the GStreamer's source code?}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
You are invited to do so, as the licenses (unless you are dealing with proprietary bits, but in that case you will not find the corresponding source code) so permit. Be reminded though that in that case you need to also provide the complete corresponding source code (and to preserve the same license, of course). You might also consider to push your modifications upstream, so that they are merged into the main branch of development if they are worth it and will be maintained by the GStreamer project and not by you individually. We invite you not to fork the code, if at all possible.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs36\lang255\loch\f6
How does licensing relate to software patents? What about software patents in general?}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
This is a tricky question. We believe software patents should not exist, so that by distributing and using software on a general purpose machine you would not violate any of them. But the inconvenient truth is that they do exist.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
Software patents are widely available in the USA. Despite they are formally prohibited in the European Union, they indeed are granted by the thousand by the European Patent Office, and also some national patent offices follow the same path. In other countries they are not available.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
Since patent protection is a national state-granted monopoly, distributing software that violates patents in a given country could be entirely safe if done in another country. Fair use exceptions also exist. So we cannot advice you whether the software we provide would be considered violating patents in your country or in any other country, but that can be said for virtually all kinds of software. Only, since we deal with audio-video standards, and these standards are by and large designed to use certain patented technologies, it is common wisdom that the pieces of software that implement these standards are sensitive in this respect.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
This is why GStreamer has taken a modular approach, so that you can use a Free plugins or a proprietary, patent royalty bearing, plugin for a given standard.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b\rtlch \ltrch\loch\fs36\lang255\loch\f6
What about static vs. dynamic linking and copyleft?}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
We cannot provide one single answer to that question. Since copyright in software works as copyright in literature, static linking means basically that the programmer includes bits of code of the original library in the bytecode at compile time. This amounts to make derivative code of the library without conceivable exceptions, so you need a permission from the copyright holders of the library to do this.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
A widespread line of thinking says that dynamic linking is conversely not relevant to the copyleft effect, since the mingling of code in a larger work is done at runtime. However, another equally authoritative line of thought says that only certain type of dynamic linking is not copyright relevant. Therefore, using a library that is specifically designed to be loaded into a particular kind of software, even through API, requires permission by the copyright holder of the library when the two pieces are distributed together.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
In all cases, since most of the software we include in GStreamer is under the LGPL, this permission is granted once for all, subject to compliance with the conditions set out by it. Therefore, the problem only arises when you want to use GPL libraries to make non-GPL applications, and you need to audit your software in that case to make sure that what you do is not an infringement. This is why we have put the GPL libraries in a separate set of optional components, so you have a clearer view of what is safely clear for use, and what might need better investigation on a case-by-case basis.}
\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af7\langfe2052\dbch\af8\afs24\alang1081\loch\f3\fs24\lang1031\sl276\slmult1\sb0\sa200{\b0\rtlch \ltrch\loch\fs24\lang255\loch\f6
Please be reminded that even for LGPL, the recipient of the software must be in a position to replace the current library with a modified one, and to that effect some conditions apply, among which that for static linking you must also provide the complete toolchain required to relink the library (\uc3 \u8220\'e2\'80\'9cany data and utility programs needed for reproducing the executable from it\u8221\'e2\'80\'9d, except the \u8220\'e2\'80\'9cmajor components\u8221\'e2\'80\'9d) and that the license of the conditions of the resulting program must allow decompilation to debug modifications to the library.\uc1 }
\par }

View file

@ -0,0 +1,79 @@
# Check wix installation
$wixInstalledFolder = "C:\Program Files (x86)\WiX Toolset v3.11\bin"
if(Test-Path $wixInstalledFolder)
{
$wixFolder = $wixInstalledFolder
}
else
{
$prepareWix = Join-Path $PSScriptRoot -ChildPath prepare_wix.ps1
& "$prepareWix"
$wixFolder = Join-Path $PSScriptRoot -ChildPath 'wix/'
}
$candleToolPath = Join-Path $wixFolder -ChildPath candle.exe
$lightToolPath = Join-Path $wixFolder -ChildPath light.exe
$heatToolPath = Join-Path $wixFolder -ChildPath heat.exe
$GPSUpgradeCode = "9B87C8FF-599C-4F20-914E-AF5E68CB3DC0"
$GPSVersion = Get-Content $PSScriptRoot\..\..\VERSION -Raw
Write-Output $GPSVersion
try
{
Push-Location $PSScriptRoot
if(-not (Test-Path $wixFolder))
{
throw "Folder $wixFolder does not exist. Start DownloadAndExtractWix.ps1 script to create it."
}
if((-not (Test-Path $candleToolPath)) -or (-not (Test-Path $lightToolPath)))
{
throw "Tools required to build installer (candle.exe and light.exe) do not exist in wix folder."
}
# GST and GTK are installed in this folder by prepare_gstreamer.ps1.
# GST and GTK are built by the docker image.
$gstreamerInstallDir="c:\gst-install-clean"
$gstreamerBinInstallDir= Join-Path $gstreamerInstallDir -ChildPath "bin"
$gstreamerPluginInstallDir= Join-Path $gstreamerInstallDir -ChildPath "lib"
$gstreamerShareInstallDir= Join-Path $gstreamerInstallDir -ChildPath "share"
& "$heatToolPath" dir "$gstreamerBinInstallDir" -gg -sfrag -template:fragment -out gstreamer-1.0.wxs -cg "_gstreamer" -var var.gstreamerBinInstallDir -dr INSTALLFOLDER
& "$heatToolPath" dir "$gstreamerPluginInstallDir" -gg -sfrag -template:fragment -out gstreamer-plugins-1.0.wxs -cg "_gstreamer_plugins" -var var.gstreamerPluginInstallDir -dr INSTALLFOLDER
& "$heatToolPath" dir "$gstreamerShareInstallDir" -v -ke -gg -sfrag -template:fragment -out gstreamer-share-1.0.wxs -cg "_gstreamer_share" -var var.gstreamerShareInstallDir -dr INSTALLFOLDER
$files = "gps gstreamer-1.0 gstreamer-plugins-1.0 gstreamer-share-1.0"
$wxs_files = @()
$obj_files = @()
foreach ($f in $files.split(" ")){
$wxs_files += "$f.wxs"
$obj_files += "$f.wixobj"
}
Write-Output $wxs_files
Write-Output $obj_files
# compiling wxs file into wixobj
$msiFileName = "GstPipelineStudio-$GPSVersion.msi"
foreach ($f in $wxs_files){
& "$candleToolPath" "$f" -dPlatform=x64 -dGPSUpgradeCode="$GPSUpgradeCode" -dGPSVersion="$GPSVersion" -dgstreamerBinInstallDir="$gstreamerBinInstallDir" -dgstreamerPluginInstallDir="$gstreamerPluginInstallDir" -dgstreamerShareInstallDir="$gstreamerShareInstallDir"
if($LASTEXITCODE -ne 0)
{
throw "Compilation of $wxsFileName failed with exit code $LASTEXITCODE"
}
}
$AllArgs = $obj_files + @('-out', $msiFileName)
& $lightToolPath $AllArgs -ext WixUIExtension
if($LASTEXITCODE -ne 0)
{
throw "Linking of $wixobjFileName failed with exit code $LASTEXITCODE"
}
}
catch
{
Write-Error $_
exit 1
}
finally
{
Pop-Location
}

8
installer/wix/gps.bat Normal file
View file

@ -0,0 +1,8 @@
@echo off
set MYDIR=%~dp0
setlocal
set PATH=%MYDIR%bin;%PATH%
echo %PATH%
set GST_PLUGIN_PATH=%MYDIR%\lib\gstreamer-1.0
echo %GST_PLUGIN_PATH%
gst-pipeline-studio.exe

69
installer/wix/gps.wxs Normal file
View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Language="1033"
Manufacturer="dabrain34"
Name="GstPipelineStudio"
UpgradeCode="$(var.GPSUpgradeCode)"
Version="$(var.GPSVersion)">
<Package InstallScope="perMachine" Compressed="yes" />
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
<WixVariable Id="WixUIBannerBmp" Value="wixbanner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="wixdialog.bmp" />
<MediaTemplate EmbedCab="yes" />
<UIRef Id="WixUI_InstallDir" />
<WixVariable Id="WixUILicenseRtf" Value="LICENSE.rtf" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramMenuFolder">
<Directory Id="GPSAppShortcuts" Name="GStreamer Pipeline Studio" />
</Directory>
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="GstPipelineStudio">
<Component Id="ProductComponent">
<File KeyPath="yes" Source="gps.bat">
<Shortcut Id="GPSAppShortcut"
Directory="GPSAppShortcuts"
Name="GPSApp"
WorkingDirectory="INSTALLFOLDER"
Advertise="yes"
Icon="icon.ico"
IconIndex="0"
>
</Shortcut>
</File>
<RemoveFolder Id="DeleteTheGPSAppShortcut"
Directory="GPSAppShortcuts"
On="uninstall" />
</Component>
</Directory>
</Directory>
</Directory>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"/>
<Icon Id="icon.ico" SourceFile="icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<Component Id="UninstallShortcut" Guid="*" Directory="GPSAppShortcuts">
<Shortcut Id="UninstallGPS"
Name="Uninstall GPS App"
Description="Uninstalls GPS App"
Target="[System64Folder]msiexec.exe"
Arguments="/x [ProductCode]" />
<RegistryValue Root="HKCU" Key="Software\GPS\GPSApp" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
<Feature Id="GPSFeature">
<ComponentRef Id="ProductComponent" />
<ComponentGroupRef Id="_gstreamer" />
<ComponentGroupRef Id="_gstreamer_plugins" />
<ComponentGroupRef Id="_gstreamer_share" />
<ComponentRef Id="UninstallShortcut" />
</Feature>
</Product>
</Wix>

BIN
installer/wix/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -0,0 +1,12 @@
# install gtk, gstreamer built within the docker image to a clean folder used by wix to generate the package.
Remove-Item -Recurse -Force c:\gst-install-clean
New-Item c:\gst-install-clean -ItemType Directory
New-Item c:\gst-install-clean\bin -ItemType Directory
Copy-Item -Path C:\gst-install\bin\*.dll -Destination c:\gst-install-clean\bin\
Copy-Item -Path C:\gst-install\bin\*.exe -Destination c:\gst-install-clean\bin\
New-Item c:\gst-install-clean\lib\gstreamer-1.0 -ItemType Directory
Copy-Item -Path C:\gst-install\lib\gstreamer-1.0\*.dll -Destination c:\gst-install-clean\lib\gstreamer-1.0
Copy-Item -Path C:\gst-install\share -Destination c:\gst-install-clean\ -Recurse

View file

@ -0,0 +1,40 @@
#FIXME: The latest gstreamer windows image contains wix.
$source = "https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip"
$destination = Join-Path $PSScriptRoot -ChildPath 'wix.zip'
$wixFolder = Join-Path $PSScriptRoot -ChildPath 'wix/'
try
{
Push-Location $PSScriptRoot
if(Test-Path $destination)
{
Write-Host "WiX already download at: $destination"
}
else
{
Write-Host "Downloading $source ..."
Invoke-WebRequest -Uri $source -OutFile $destination
Write-Host "Download finished" -ForegroundColor Green
}
if(Test-Path $wixFolder)
{
Write-Host "WiX already extracted at: $wixFolder"
}
else
{
Write-Host "Extracting $destination ..."
Expand-Archive -LiteralPath $destination -DestinationPath $wixFolder
Write-Host "Extraction finished" -ForegroundColor Green
}
}
catch
{
Write-Error $_
exit 1
}
finally
{
Pop-Location
}

BIN
installer/wix/wixbanner.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

BIN
installer/wix/wixdialog.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 KiB

View file

@ -1,19 +1,25 @@
project('gst_pipeline_studio',
version: '0.2.2',
meson_version: '>= 0.50.0',
project('gst-pipeline-studio',
version: '0.3.5',
meson_version: '>= 0.63.0',
default_options: [ 'warning_level=2',
],
license: 'GPL-3.0-or-later',
)
i18n = import('i18n')
host_system = host_machine.system()
python_mod = import('python')
python3 = python_mod.find_installation()
current_date = run_command(python3, '-c', 'import datetime; print(datetime.datetime.now().strftime("%Y-%m-%d"), end ="")').stdout()
i18n = import('i18n')
host_system = host_machine.system()
dependency('gstreamer-1.0', version: '>= 1.20', fallback: ['gstreamer-1.0'])
dependency('gstreamer-base-1.0', version: '>= 1.20', fallback: ['gstreamer-1.0'])
dependency('gstreamer-video-1.0', version: '>= 1.20', fallback: ['gstreamer-1.0'])
dependency('glib-2.0', version: '>= 2.66')
dependency('gio-2.0', version: '>= 2.66')
dependency('gtk4', version: '>= 4.0.0')
dependency('gstreamer-1.0', version: '>= 1.18')
dependency('gstreamer-base-1.0', version: '>= 1.18')
dependency('gstreamer-plugins-base-1.0', version: '>= 1.18')
dependency('gstreamer-plugins-bad-1.0', version: '>= 1.18')
dependency('gtk4', version: '>= 4.0.0', fallback: ['gtk'])
find_program('cargo', required: true)
find_program('glib-compile-resources', required: true)
@ -30,7 +36,7 @@ localedir = prefix / get_option('localedir')
datadir = prefix / get_option('datadir')
pkgdatadir = datadir / meson.project_name()
iconsdir = datadir / 'icons'
podir = meson.source_root () / 'po'
podir = meson.project_source_root () / 'po'
gettext_package = meson.project_name()
base_id = 'org.freedesktop.dabrain34.GstPipelineStudio'
@ -55,16 +61,18 @@ cargo_sources = files(
'Cargo.toml',
'Cargo.lock',
)
if host_system == 'linux'
subdir('data')
endif
subdir('src')
subdir('po')
meson.add_dist_script(
'build-aux/dist-vendor.sh',
meson.source_root(),
join_paths(meson.build_root(), 'meson-dist', meson.project_name() + '-' + version)
meson.project_source_root(),
join_paths(meson.project_build_root(), 'meson-dist', meson.project_name() + '-' + version)
)
meson.add_install_script('build-aux/meson/postinstall.py')
if host_system == 'linux'
meson.add_install_script('build-aux/meson/postinstall.py')
endif

View file

@ -1 +1,2 @@
fr
it

View file

@ -39,23 +39,6 @@ msgstr "GstPipelineStudio a pour but de fournir une interface utilisateur au log
msgid "A GUI for GStreamer"
msgstr "Une interface utilisateur pour GStreamer"
#: data/org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in:15
msgid "Player rendering video"
msgstr "Rendu video dans le lecteur"
#: data/org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in:26
msgid "Searching song using the mobile client"
msgstr ""
#: data/org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in:35
msgid "Guillaume Desmottes"
msgstr ""
#. Translators: Do NOT translate or transliterate this text (this is an icon file name)!
#: data/org.freedesktop.dabrain34.GstPipelineStudio.desktop.in:9
msgid "@icon@"
msgstr ""
#: src/app.rs:344
msgid "GPS is ready"
msgstr "GPS est prêt"

View file

@ -39,23 +39,6 @@ une interface intuitive pour ajouter des elements à un pipeline pour l'examiner
msgid "A GUI for GStreamer"
msgstr "Une interface utilisateur pour GStreamer"
#: data/org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in:15
msgid "Player rendering video"
msgstr "Rendu video dans le lecteur"
#: data/org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in:26
msgid "Searching song using the mobile client"
msgstr ""
#: data/org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in:35
msgid "Guillaume Desmottes"
msgstr ""
#. Translators: Do NOT translate or transliterate this text (this is an icon file name)!
#: data/org.freedesktop.dabrain34.GstPipelineStudio.desktop.in:9
msgid "@icon@"
msgstr ""
#: src/app.rs:344
msgid "GPS is ready"
msgstr "GPS est prêt"

45
po/it.po Normal file
View file

@ -0,0 +1,45 @@
# Italian translations for gps package.
# Copyright (C) 2022 THE gps'S COPYRIGHT HOLDER
# This file is distributed under the same license as the GstPipelineStudio package.
# Automatically generated, 2022.
# Albano Battistella <albano_battistella>, 2022.
#
msgid ""
msgstr ""
"Project-Id-Version: gps\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-09-29 22:56+0200\n"
"PO-Revision-Date: 2022-02-08 20:46+0100\n"
"Last-Translator: Albano Battistella <albano_battistella@hotmail.com>\n"
"Language-Team: Italian\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: data/org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in:7
#: data/org.freedesktop.dabrain34.GstPipelineStudio.desktop.in:4
msgid "GstPipelineStudio"
msgstr "GstPipelineStudio"
#: data/org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in:8
msgid "Draw your own GStreamer pipeline..."
msgstr "Disegna la tua pipeline GStreamer..."
#: data/org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in:10
msgid ""
"GstPipelineStudio aims to provide a graphical user interface to the GStreamer framework. "
"From a first step in the framework with a simple pipeline to a complex pipeline debugging, "
"the tool provides a friendly interface to add elements to a pipeline and debug it."
msgstr "GstPipelineStudio mira a fornire un'interfaccia utente grafica al framework GStreamer. "
"Da un primo passaggio nel framework con una pipeline semplice a un debug di una pipeline complessa,"
"lo strumento fornisce un'interfaccia intuitiva per aggiungere elementi a una pipeline ed eseguirne il debug."
#: data/org.freedesktop.dabrain34.GstPipelineStudio.desktop.in.in:4
msgid "A GUI for GStreamer"
msgstr "Una interfaccia grafica per GStreamer"
#: src/app.rs:344
msgid "GPS is ready"
msgstr "GPS è pronto"

View file

@ -3,7 +3,22 @@
- Update to the given version:
- meson.build
- cargo.toml
- VERSION
- index.html
- And rebuild to regenerate the cargo.lock
- update the changelog in org.freedesktop.dabrain34.GstPipelineStudio.appdata.xml.in.in within release/description
- create a tag on gitlab
- meson builddir -Dbuildtype=release
- ninja -C buiddir dist
- upload the package and the sha256 to gitlab for Flatpak in the release notes
- Fetch the package from the `linux release` job or you can make it manually with:
- meson builddir -Dbuildtype=release
- ninja -C builddir dist
- Upload the package .xz file and the sha256 to gitlab release page in the release notes
see https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio/-/releases/0.3.2
# flathub
https://github.com/flathub/org.freedesktop.dabrain34.GstPipelineStudio
- Need to update the package and the sha256 from the release page, ie https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio/-/releases/0.3.2
- Create a pull request with the package update
- Wait at lest 2-3 hours after merging to get the update available.

View file

@ -2,33 +2,21 @@
//
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use glib::SignalHandlerId;
use glib::Value;
use gtk::gdk;
use gtk::prelude::*;
use gtk::{gio, gio::SimpleAction, glib, graphene};
use gtk::{
Application, ApplicationWindow, Builder, Button, FileChooserAction, FileChooserDialog, Paned,
PopoverMenu, ResponseType, Statusbar, Viewport, Widget,
PopoverMenu, ResponseType, Statusbar, Widget,
};
use log::error;
use once_cell::unsync::OnceCell;
use std::cell::RefCell;
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::fs::File;
use std::io::{Read, Write};
@ -36,11 +24,12 @@ use std::ops;
use std::rc::{Rc, Weak};
use crate::gps as GPS;
use crate::graphbook;
use crate::logger;
use crate::settings::Settings;
use crate::ui as GPSUI;
use crate::{GPS_DEBUG, GPS_ERROR, GPS_INFO, GPS_TRACE, GPS_WARN};
use crate::{GPS_DEBUG, GPS_ERROR, GPS_TRACE, GPS_WARN};
use crate::graphmanager as GM;
use crate::graphmanager::PropertyExt;
@ -48,9 +37,9 @@ use std::fmt;
#[derive(Debug)]
pub struct GPSAppInner {
pub window: gtk::ApplicationWindow,
pub graphview: RefCell<GM::GraphView>,
pub current_graphtab: Cell<u32>,
pub graphbook: RefCell<HashMap<u32, graphbook::GraphTab>>,
pub builder: Builder,
pub player: RefCell<GPS::Player>,
pub plugin_list_initialized: OnceCell<bool>,
pub signal_handlers: RefCell<HashMap<String, SignalHandlerId>>,
}
@ -66,7 +55,7 @@ pub enum AppState {
impl fmt::Display for AppState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
write!(f, "{self:?}",)
}
}
@ -79,7 +68,7 @@ impl ops::Deref for GPSApp {
type Target = GPSAppInner;
fn deref(&self) -> &GPSAppInner {
&*self.0
&self.0
}
}
@ -106,27 +95,24 @@ impl GPSApp {
window.set_application(Some(application));
window.set_title(Some("GStreamer Pipeline Studio"));
let player = GPS::Player::new().expect("Unable to initialize GStreamer subsystem");
let app = GPSApp(Rc::new(GPSAppInner {
window,
graphview: RefCell::new(GM::GraphView::new()),
current_graphtab: Cell::new(0),
graphbook: RefCell::new(HashMap::new()),
builder,
player: RefCell::new(player),
plugin_list_initialized: OnceCell::new(),
signal_handlers: RefCell::new(HashMap::new()),
}));
let app_weak = app.downgrade();
app.player.borrow().set_app(app_weak);
app.graphview.borrow_mut().set_id(0);
let settings = Settings::load_settings();
app.window
.set_default_size(settings.app_width, settings.app_height);
#[cfg(not(target_os = "macos"))]
if settings.app_maximized {
app.window.maximize();
} else {
app.window
.set_size_request(settings.app_width, settings.app_height);
}
app.set_paned_position(&settings, "graph_dashboard-paned", 100);
app.set_paned_position(&settings, "graph_logs-paned", 100);
app.set_paned_position(&settings, "elements_preview-paned", 100);
@ -164,7 +150,7 @@ impl GPSApp {
.insert(paned_name.to_string(), paned.position());
}
pub fn on_startup(application: &gtk::Application) {
pub fn on_startup(application: &gtk::Application, pipeline_desc: &String) {
// Create application and error out if that fails for whatever reason
let app = match GPSApp::new(application) {
Ok(app) => app,
@ -174,13 +160,7 @@ impl GPSApp {
}
};
// 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
let app_weak = app.downgrade();
application.connect_activate(glib::clone!(@weak application => move |_| {
let app = upgrade_weak!(app_weak);
app.build_ui(&application);
}));
app.build_ui(application, pipeline_desc);
let app_weak = app.downgrade();
let slider: gtk::Scale = app
@ -189,18 +169,20 @@ impl GPSApp {
.expect("Couldn't get status_bar");
let slider_update_signal_id = slider.connect_value_changed(move |slider| {
let app = upgrade_weak!(app_weak);
let player = app.player.borrow();
let value = slider.value() as u64;
GPS_TRACE!("Seeking to {} s", value);
if player.set_position(value).is_err() {
if graphbook::current_graphtab(&app)
.player()
.set_position(value)
.is_err()
{
GPS_ERROR!("Seeking to {} failed", value);
}
});
let app_weak = app.downgrade();
let timeout_id =
glib::timeout_add_local(std::time::Duration::from_millis(500), move || {
let app = upgrade_weak!(app_weak, glib::Continue(false));
let player = app.player.borrow();
let app = upgrade_weak!(app_weak, glib::ControlFlow::Break);
let label: gtk::Label = app
.builder
@ -210,19 +192,21 @@ impl GPSApp {
.builder
.object("scale-position")
.expect("Couldn't get status_bar");
let position = player.position();
let duration = player.duration();
let position = graphbook::current_graphtab(&app).player().position();
let duration = graphbook::current_graphtab(&app).player().duration();
slider.set_range(0.0, duration as f64 / 1000_f64);
slider.block_signal(&slider_update_signal_id);
slider.set_value(position as f64 / 1000_f64);
slider.unblock_signal(&slider_update_signal_id);
// Query the current playing position from the underlying player.
let position_desc = player.position_description();
let position_desc = graphbook::current_graphtab(&app)
.player()
.position_description();
// Display the playing position in the gui.
label.set_text(&position_desc);
// Tell the callback to continue calling this closure.
glib::Continue(true)
glib::ControlFlow::Continue
});
let timeout_id = RefCell::new(Some(timeout_id));
@ -239,8 +223,8 @@ impl GPSApp {
.expect("Couldn't get the main window");
let mut settings = Settings::load_settings();
settings.app_maximized = window.is_maximized();
settings.app_width = window.width();
settings.app_height = window.height();
settings.app_width = window.default_width();
settings.app_height = window.default_height();
app.save_paned_position(&mut settings, "graph_dashboard-paned");
app.save_paned_position(&mut settings, "graph_logs-paned");
app.save_paned_position(&mut settings, "elements_preview-paned");
@ -269,8 +253,13 @@ impl GPSApp {
application.add_action(&gio::SimpleAction::new("open", None));
application.set_accels_for_action("app.open", &["<primary>o"]);
application.add_action(&gio::SimpleAction::new("open_pipeline", None));
application.set_accels_for_action("app.open_pipeline", &["<primary>p"]);
application.add_action(&gio::SimpleAction::new("save_as", None));
application.add_action(&gio::SimpleAction::new("save", None));
application.set_accels_for_action("app.save", &["<primary>s"]);
application.add_action(&gio::SimpleAction::new("save_as", None));
application.add_action(&gio::SimpleAction::new("delete", None));
application.set_accels_for_action("app.delete", &["<primary>d", "Delete"]);
@ -283,7 +272,10 @@ impl GPSApp {
application.add_action(&gio::SimpleAction::new("favorite.remove", None));
application.add_action(&gio::SimpleAction::new("logger.clear", None));
application.add_action(&gio::SimpleAction::new("graph.check", None));
application.add_action(&gio::SimpleAction::new("graph.clear", None));
application.add_action(&gio::SimpleAction::new("graph.pipeline_details", None));
application.add_action(&gio::SimpleAction::new("port.delete", None));
@ -337,7 +329,7 @@ impl GPSApp {
.expect("Unable to dynamic cast to SimpleAction")
}
fn disconnect_app_menu_action(&self, action_name: &str) {
pub fn disconnect_app_menu_action(&self, action_name: &str) {
let action = self.app_menu_action(action_name);
if let Some(signal_handler_id) = self.signal_handlers.borrow_mut().remove(action_name) {
@ -426,7 +418,12 @@ impl GPSApp {
.builder
.object("notebook-preview")
.expect("Couldn't get box_preview");
if n_sink == 0 {
let mut n_video_sink = n_sink;
for tab in self.graphbook.borrow().values() {
n_video_sink += tab.player().n_video_sink();
}
if n_video_sink == 0 {
loop {
let i = notebook_preview.n_pages();
if i == 0 {
@ -441,32 +438,35 @@ impl GPSApp {
.valign(gtk::Align::Center)
.build();
box_preview.append(&picture);
let label = gtk::Label::new(Some(&format!("Preview{}", n_sink)));
let label = gtk::Label::new(Some(&format!("Preview{n_video_sink}")));
notebook_preview.insert_page(&box_preview, Some(&label), None);
notebook_preview.set_current_page(Some(n_video_sink as u32));
}
pub fn build_ui(&self, application: &Application) {
let drawing_area_window: Viewport = self
.builder
.object("drawing_area")
.expect("Couldn't get drawing_area");
drawing_area_window.set_child(Some(&*self.graphview.borrow()));
pub fn build_ui(&self, application: &Application, pipeline_desc: &String) {
graphbook::setup_graphbook(self);
graphbook::create_graphtab(self, 0, None);
let (ready_tx, ready_rx) = async_channel::unbounded::<(logger::LogType, String)>();
// Setup the logger to get messages into the TreeView
let (ready_tx, ready_rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
let app_weak = self.downgrade();
logger::init_logger(
ready_tx,
Settings::default_log_file_path()
ready_tx.clone(),
Settings::log_file_path()
.to_str()
.expect("Unable to convert log file path to a string"),
);
GPSUI::logger::setup_logger_list(self);
let _ = ready_rx.attach(None, move |msg: String| {
let app = upgrade_weak!(app_weak, glib::Continue(false));
GPSUI::logger::add_to_logger_list(&app, &msg);
glib::Continue(true)
logger::init_msg_logger(ready_tx);
GPSUI::logger::setup_logger_list(self, "treeview-app-logger", logger::LogType::App);
GPSUI::logger::setup_logger_list(self, "treeview-msg-logger", logger::LogType::Message);
GPSUI::logger::setup_logger_list(self, "treeview-gst-logger", logger::LogType::Gst);
let app_weak = self.downgrade();
glib::spawn_future_local(async move {
while let Ok(msg) = ready_rx.recv().await {
let app = upgrade_weak!(app_weak, glib::ControlFlow::Break);
GPSUI::logger::add_to_logger_list(&app, msg.0, &msg.1);
}
glib::ControlFlow::Continue
});
let window = &self.window;
@ -484,19 +484,59 @@ impl GPSApp {
let app_weak = self.downgrade();
self.connect_app_menu_action("new-window", move |_, _| {
let app = upgrade_weak!(app_weak);
app.clear_graph();
GPS_ERROR!("clear graph");
let id = graphbook::graphbook_get_new_graphtab_id(&app);
graphbook::create_graphtab(&app, id, None);
let graphbook: gtk::Notebook = app
.builder
.object("graphbook")
.expect("Couldn't get graphbook");
graphbook.set_current_page(Some(id));
});
let app_weak = self.downgrade();
self.connect_app_menu_action("open", move |_, _| {
let app = upgrade_weak!(app_weak);
GPSApp::get_file_from_dialog(&app, false, move |app, filename| {
app.load_graph(&filename)
app.load_graph(&filename, false)
.unwrap_or_else(|_| GPS_ERROR!("Unable to open file {}", filename));
});
});
let app_weak = self.downgrade();
self.connect_app_menu_action("open_pipeline", move |_, _| {
let app = upgrade_weak!(app_weak);
GPSUI::dialog::create_input_dialog(
"Enter pipeline description with gst-launch format",
"description",
&Settings::recent_pipeline_description(),
&app,
move |app, pipeline_desc| {
app.load_pipeline(&pipeline_desc).unwrap_or_else(|_| {
GPS_ERROR!("Unable to open pipeline description {}", pipeline_desc)
});
Settings::set_recent_pipeline_description(&pipeline_desc);
},
);
});
let app_weak = self.downgrade();
self.connect_app_menu_action("save", move |_, _| {
let app = upgrade_weak!(app_weak);
let gt = graphbook::current_graphtab(&app);
if gt.undefined() {
GPSApp::get_file_from_dialog(&app, true, move |app, filename| {
GPS_DEBUG!("Save file {}", filename);
app.save_graph(&filename)
.unwrap_or_else(|_| GPS_ERROR!("Unable to save file to {}", filename));
graphbook::current_graphtab_set_filename(&app, filename.as_str());
});
} else if gt.modified() {
let filename = gt.filename();
app.save_graph(&filename)
.unwrap_or_else(|_| GPS_ERROR!("Unable to save file to {}", filename));
graphbook::current_graphtab_set_filename(&app, filename.as_str());
}
});
let app_weak = self.downgrade();
self.connect_app_menu_action("save_as", move |_, _| {
let app = upgrade_weak!(app_weak);
@ -504,6 +544,7 @@ impl GPSApp {
GPS_DEBUG!("Save file {}", filename);
app.save_graph(&filename)
.unwrap_or_else(|_| GPS_ERROR!("Unable to save file to {}", filename));
graphbook::current_graphtab_set_filename(&app, filename.as_str());
});
});
@ -516,8 +557,9 @@ impl GPSApp {
let app_weak = self.downgrade();
self.connect_app_menu_action("delete", move |_, _| {
let app = upgrade_weak!(app_weak);
let graph_view = app.graphview.borrow();
graph_view.delete_selected();
graphbook::current_graphtab(&app)
.graphview()
.delete_selected();
});
let app_weak = self.downgrade();
@ -529,28 +571,28 @@ impl GPSApp {
let app_weak = self.downgrade();
self.connect_button_action("button-play", move |_| {
let app = upgrade_weak!(app_weak);
let graph_view = app.graphview.borrow();
let _ = app
.player
.borrow()
.start_pipeline(&graph_view, GPS::PipelineState::Playing);
let _ = graphbook::current_graphtab(&app).player().start_pipeline(
&graphbook::current_graphtab(&app).graphview(),
GPS::PipelineState::Playing,
);
});
let app_weak = self.downgrade();
self.connect_button_action("button-pause", move |_| {
let app = upgrade_weak!(app_weak);
let graph_view = app.graphview.borrow();
let _ = app
.player
.borrow()
.start_pipeline(&graph_view, GPS::PipelineState::Paused);
let _ = graphbook::current_graphtab(&app).player().start_pipeline(
&graphbook::current_graphtab(&app).graphview(),
GPS::PipelineState::Paused,
);
});
let app_weak = self.downgrade();
self.connect_button_action("button-stop", move |_| {
let app = upgrade_weak!(app_weak);
let player = app.player.borrow();
let _ = player.set_state(GPS::PipelineState::Stopped);
let _ = graphbook::current_graphtab(&app)
.player()
.set_state(GPS::PipelineState::Stopped);
});
let app_weak = self.downgrade();
@ -558,258 +600,27 @@ impl GPSApp {
let app = upgrade_weak!(app_weak);
app.clear_graph();
});
let app_weak = self.downgrade();
self.graphview.borrow().connect_local(
"node-added",
false,
glib::clone!(@weak application => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let graph_id = values[1].get::<u32>().expect("graph id in args[1]");
let node_id = values[2].get::<u32>().expect("node id in args[2]");
GPS_INFO!("Node added node id={} in graph id={}", node_id, graph_id);
if let Some(node) = app.graphview.borrow().node(node_id) {
let description = GPS::ElementInfo::element_description(&node.name()).ok();
node.set_tooltip_markup(description.as_deref());
for port in node.all_ports(GM::PortDirection::All) {
let caps = PropertyExt::property(&port,"_caps");
GPS_TRACE!("caps={} for port id {}", caps.clone().unwrap_or_else(|| "caps unknown".to_string()), port.id());
port.set_tooltip_markup(caps.as_deref());
}
}
None
}),
);
let app_weak = self.downgrade();
self.graphview.borrow().connect_local(
"port-added",
false,
glib::clone!(@weak application => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let graph_id = values[1].get::<u32>().expect("graph id in args[1]");
let node_id = values[2].get::<u32>().expect("node id in args[2]");
let port_id = values[3].get::<u32>().expect("port id in args[3]");
GPS_INFO!("Port added port id={} to node id={} in graph id={}", port_id, node_id, graph_id);
if let Some(node) = app.graphview.borrow().node(node_id) {
if let Some(port) = node.port(port_id) {
let caps = PropertyExt::property(&port, "_caps");
GPS_TRACE!("caps={} for port id {}", caps.clone().unwrap_or_else(|| "caps unknown".to_string()), port.id());
port.set_tooltip_markup(caps.as_deref());
}
}
None
}),
);
let app_weak = self.downgrade();
self.graphview.borrow().connect_local(
"graph-updated",
false,
glib::clone!(@weak application => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let id = values[1].get::<u32>().expect("id in args[1]");
GPS_TRACE!("Graph updated id={}", id);
let _ = app
.save_graph(
Settings::default_graph_file_path()
.to_str()
.expect("Unable to convert to string"),
)
.map_err(|e| GPS_WARN!("Unable to save file {}", e));
None
}),
);
// When user clicks on port with right button
let app_weak = self.downgrade();
self.graphview
.borrow()
.connect_local(
"graph-right-clicked",
false,
glib::clone!(@weak application => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let point = values[1].get::<graphene::Point>().expect("point in args[2]");
let pop_menu = app.app_pop_menu_at_position(&*app.graphview.borrow(), point.to_vec2().x() as f64, point.to_vec2().y() as f64);
let menu: gio::MenuModel = app
.builder
.object("graph_menu")
.expect("Couldn't graph_menu");
pop_menu.set_menu_model(Some(&menu));
let app_weak = app.downgrade();
app.connect_app_menu_action("graph.check",
move |_,_| {
let app = upgrade_weak!(app_weak);
let render_parse_launch = app.player.borrow().render_gst_launch(&app.graphview.borrow());
if app.player.borrow().create_pipeline(&render_parse_launch).is_ok() {
GPSUI::message::display_message_dialog(&render_parse_launch,gtk::MessageType::Info, |_| {});
} else {
GPSUI::message::display_error_dialog(false, &format!("Unable to render:\n\n{}", render_parse_launch));
}
}
);
let app_weak = app.downgrade();
app.connect_app_menu_action("graph.pipeline_details",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPSUI::properties::display_pipeline_details(&app);
}
);
pop_menu.show();
None
}),
);
// When user clicks on port with right button
let app_weak = self.downgrade();
self.graphview.borrow().connect_local(
"port-right-clicked",
false,
move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let port_id = values[1].get::<u32>().expect("port id args[1]");
let node_id = values[2].get::<u32>().expect("node id args[2]");
let point = values[3]
.get::<graphene::Point>()
.expect("point in args[3]");
let pop_menu = app.app_pop_menu_at_position(
&*app.graphview.borrow(),
point.to_vec2().x() as f64,
point.to_vec2().y() as f64,
);
let menu: gio::MenuModel = app
.builder
.object("port_menu")
.expect("Couldn't get menu model for port");
pop_menu.set_menu_model(Some(&menu));
if app.graphview.borrow().can_remove_port(node_id, port_id) {
let app_weak = app.downgrade();
app.connect_app_menu_action("port.delete", move |_, _| {
let app = upgrade_weak!(app_weak);
GPS_TRACE!("port.delete-link port {} node {}", port_id, node_id);
app.graphview.borrow().remove_port(node_id, port_id);
});
} else {
app.disconnect_app_menu_action("port.delete");
}
let app_weak = app.downgrade();
app.connect_app_menu_action("port.properties", move |_, _| {
let app = upgrade_weak!(app_weak);
GPS_TRACE!("port.properties port {} node {}", port_id, node_id);
let node = app.node(node_id);
let port = app.port(node_id, port_id);
GPSUI::properties::display_pad_properties(
&app,
&node.name(),
&port.name(),
node_id,
port_id,
);
});
pop_menu.show();
None
},
);
// When user clicks on node with right button
let app_weak = self.downgrade();
self.graphview
.borrow()
.connect_local(
"node-right-clicked",
false,
glib::clone!(@weak application => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let node_id = values[1].get::<u32>().expect("node id args[1]");
let point = values[2].get::<graphene::Point>().expect("point in args[2]");
let pop_menu = app.app_pop_menu_at_position(&*app.graphview.borrow(), point.to_vec2().x() as f64, point.to_vec2().y() as f64);
let menu: gio::MenuModel = app
.builder
.object("node_menu")
.expect("Couldn't get menu model for node");
pop_menu.set_menu_model(Some(&menu));
let app_weak = app.downgrade();
app.connect_app_menu_action("node.add-to-favorite",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.add-to-favorite {}", node_id);
if let Some(node) = app.graphview.borrow().node(node_id) {
GPSUI::elements::add_to_favorite_list(&app, node.name());
};
}
);
let app_weak = app.downgrade();
app.connect_app_menu_action("node.delete",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.delete {}", node_id);
app.graphview.borrow_mut().remove_node(node_id);
}
);
let node = app.node(node_id);
if let Some(input) = GPS::ElementInfo::element_supports_new_pad_request(&node.name(), GM::PortDirection::Input) {
let app_weak = app.downgrade();
app.connect_app_menu_action("node.request-pad-input",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.request-pad-input {}", node_id);
app.create_port_with_caps(node_id, GM::PortDirection::Input, GM::PortPresence::Sometimes, input.caps().to_string())
}
);
} else {
app.disconnect_app_menu_action("node.request-pad-input");
}
let node = app.node(node_id);
if let Some(output) = GPS::ElementInfo::element_supports_new_pad_request(&node.name(), GM::PortDirection::Output) {
let app_weak = app.downgrade();
app.connect_app_menu_action("node.request-pad-output",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.request-pad-output {}", node_id);
app.create_port_with_caps(node_id, GM::PortDirection::Output, GM::PortPresence::Sometimes, output.caps().to_string());
}
);
} else {
app.disconnect_app_menu_action("node.request-pad-output");
}
let app_weak = app.downgrade();
app.connect_app_menu_action("node.properties",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.properties {}", node_id);
let node = app.graphview.borrow().node(node_id).unwrap();
GPSUI::properties::display_plugin_properties(&app, &node.name(), node_id);
}
);
pop_menu.show();
None
}),
);
// Setup the favorite list
GPSUI::elements::setup_favorite_list(self);
// Setup the favorite list
GPSUI::elements::setup_elements_list(self);
let _ = self
.load_graph(
Settings::default_graph_file_path()
.to_str()
.expect("Unable to convert to string"),
)
.map_err(|_e| {
GPS_WARN!("Unable to load default graph");
if pipeline_desc.is_empty() {
let _ = self
.load_graph(
Settings::graph_file_path()
.to_str()
.expect("Unable to convert to string"),
true,
)
.map_err(|_e| {
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
@ -821,23 +632,22 @@ impl GPSApp {
fn drop(self) {}
pub fn add_new_element(&self, element_name: &str) {
let graphview = self.graphview.borrow();
let (inputs, outputs) = GPS::PadInfo::pads(element_name, false);
let node =
graphview.create_node(element_name, GPS::ElementInfo::element_type(element_name));
let node = graphbook::current_graphtab(self)
.graphview()
.create_node(element_name, GPS::ElementInfo::element_type(element_name));
let node_id = node.id();
if GPS::ElementInfo::element_is_uri_src_handler(element_name) {
GPSApp::get_file_from_dialog(self, false, move |app, filename| {
GPS_DEBUG!("Open file {}", filename);
let graphview = app.graphview.borrow();
let mut properties: HashMap<String, String> = HashMap::new();
properties.insert(String::from("location"), filename);
if let Some(node) = graphview.node(node_id) {
if let Some(node) = graphbook::current_graphtab(&app).graphview().node(node_id) {
node.update_properties(&properties);
}
});
}
graphview.add_node(node);
graphbook::current_graphtab(self).graphview().add_node(node);
for input in inputs {
self.create_port_with_caps(
node_id,
@ -856,16 +666,15 @@ impl GPSApp {
}
}
fn node(&self, node_id: u32) -> GM::Node {
let node = self
.graphview
.borrow()
pub fn node(&self, node_id: u32) -> GM::Node {
let node = graphbook::current_graphtab(self)
.graphview()
.node(node_id)
.unwrap_or_else(|| panic!("Unable to retrieve node with id {}", node_id));
node
}
fn port(&self, node_id: u32, port_id: u32) -> GM::Port {
pub fn port(&self, node_id: u32, port_id: u32) -> GM::Port {
let node = self.node(node_id);
node.port(port_id)
.unwrap_or_else(|| panic!("Unable to retrieve port with id {}", port_id))
@ -902,13 +711,13 @@ impl GPSApp {
properties
}
fn create_port_with_caps(
pub fn create_port_with_caps(
&self,
node_id: u32,
direction: GM::PortDirection,
presence: GM::PortPresence,
caps: String,
) {
) -> u32 {
let node = self.node(node_id);
let ports = node.all_ports(direction);
let port_name = match direction {
@ -916,36 +725,66 @@ impl GPSApp {
GM::PortDirection::Output => String::from("src_"),
_ => String::from("?"),
};
let graphview = self.graphview.borrow();
let port_name = format!("{}{}", port_name, ports.len());
let port = graphview.create_port(&port_name, direction, presence);
let port = graphbook::current_graphtab(self)
.graphview()
.create_port(&port_name, direction, presence);
let id = port.id();
let properties: HashMap<String, String> = HashMap::from([("_caps".to_string(), caps)]);
port.update_properties(&properties);
if let Some(mut node) = graphview.node(node_id) {
graphview.add_port_to_node(&mut node, port);
if let Some(mut node) = graphbook::current_graphtab(self).graphview().node(node_id) {
graphbook::current_graphtab(self)
.graphview()
.add_port_to_node(&mut node, port);
}
id
}
pub fn create_link(
&self,
node_from_id: u32,
node_to_id: u32,
port_from_id: u32,
port_to_id: u32,
) {
let graphtab = graphbook::current_graphtab(self);
let link =
graphtab
.graphview()
.create_link(node_from_id, node_to_id, port_from_id, port_to_id);
graphtab.graphview().add_link(link);
}
fn clear_graph(&self) {
let graph_view = self.graphview.borrow();
graph_view.clear();
graphbook::current_graphtab(self).graphview().clear();
}
fn save_graph(&self, filename: &str) -> anyhow::Result<()> {
let graph_view = self.graphview.borrow();
pub fn save_graph(&self, filename: &str) -> anyhow::Result<()> {
let mut file = File::create(filename)?;
let buffer = graph_view.render_xml()?;
let buffer = graphbook::current_graphtab(self).graphview().render_xml()?;
file.write_all(&buffer)?;
Ok(())
}
fn load_graph(&self, filename: &str) -> anyhow::Result<()> {
let graph_view = self.graphview.borrow();
fn load_graph(&self, filename: &str, untitled: bool) -> anyhow::Result<()> {
let mut file = File::open(filename)?;
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).expect("buffer overflow");
graph_view.load_from_xml(buffer)?;
let graphtab = graphbook::current_graphtab(self);
graphtab.graphview().load_from_xml(buffer)?;
if !untitled {
graphbook::current_graphtab_set_filename(self, filename);
}
Ok(())
}
fn load_pipeline(&self, pipeline_desc: &str) -> anyhow::Result<()> {
let graphtab = graphbook::current_graphtab(self);
let pd_parsed = pipeline_desc.replace('\\', "");
graphtab
.player()
.graphview_from_pipeline_description(&graphtab.graphview(), &pd_parsed);
Ok(())
}
}

View file

@ -2,28 +2,36 @@
//
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use anyhow::Result;
use gtk::glib;
pub fn init() -> Result<()> {
unsafe {
x11::xlib::XInitThreads();
}
std::env::set_var("GST_XINITTHREADS", "1");
gst::init()?;
#[cfg(feature = "gtk4-plugin")]
{
gstgtk4::plugin_register_static().expect("Failed to register gstgtk4 plugin");
}
gtk::init()?;
Ok(())
}
pub fn value_as_str(v: &glib::Value) -> Option<String> {
match v.type_() {
glib::Type::I8 => Some(str_some_value!(v, i8).to_string()),
glib::Type::U8 => Some(str_some_value!(v, u8).to_string()),
glib::Type::BOOL => Some(str_some_value!(v, bool).to_string()),
glib::Type::I32 => Some(str_some_value!(v, i32).to_string()),
glib::Type::U32 => Some(str_some_value!(v, u32).to_string()),
glib::Type::I64 => Some(str_some_value!(v, i64).to_string()),
glib::Type::U64 => Some(str_some_value!(v, u64).to_string()),
glib::Type::F32 => Some(str_some_value!(v, f32).to_string()),
glib::Type::F64 => Some(str_some_value!(v, f64).to_string()),
glib::Type::STRING => str_opt_value!(v, String),
_ => None,
}
}

View file

@ -1,3 +1,3 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pub static APP_ID: &str = @APP_ID@;
pub static VERSION: &str = @VERSION@;
pub static VERSION: &str = env!("CARGO_PKG_VERSION");

View file

@ -2,18 +2,7 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
@ -25,6 +14,7 @@ use crate::GPS_INFO;
use gst::glib;
use gst::prelude::*;
use std::collections::HashMap;
use std::fmt::Write as _;
#[derive(Debug, Default, Eq, Ord, PartialEq, PartialOrd)]
pub struct ElementInfo {
@ -56,6 +46,19 @@ impl ElementInfo {
Ok(elements)
}
pub fn element_factory_exists(element_name: &str) -> bool {
match ElementInfo::element_feature(element_name) {
Some(_feature) => {
GPS_DEBUG!("Found element factory name {}", element_name);
true
}
None => {
GPS_ERROR!("Unable to find element factory name {}", element_name);
false
}
}
}
pub fn element_feature(element_name: &str) -> Option<gst::PluginFeature> {
let registry = gst::Registry::get();
gst::Registry::find_feature(&registry, element_name, gst::ElementFactory::static_type())
@ -70,61 +73,67 @@ impl ElementInfo {
pub fn element_description(element_name: &str) -> anyhow::Result<String> {
let mut desc = String::from("");
let feature = ElementInfo::element_feature(element_name)
.ok_or_else(|| glib::bool_error!("Failed get element feature"))?;
let rank = feature.rank();
if let Ok(factory) = feature.downcast::<gst::ElementFactory>() {
if !ElementInfo::element_factory_exists(element_name) {
desc.push_str("<b>Factory details:</b>\n");
desc.push_str("<b>Rank:</b>");
desc.push_str(&format!("{:?}", rank));
desc.push('\n');
desc.push_str("<b>Name:</b>");
desc.push_str(&factory.name());
desc.push_str(element_name);
desc.push('\n');
desc.push('\n');
desc.push_str("Factory unavailable.");
} else {
let feature = ElementInfo::element_feature(element_name)
.ok_or_else(|| glib::bool_error!("Failed get element feature"))?;
let rank = feature.rank();
if let Ok(factory) = feature.downcast::<gst::ElementFactory>() {
desc.push_str("<b>Factory details:</b>\n");
desc.push_str("<b>Rank:</b>");
let _ = write!(desc, "{rank:?}",);
desc.push('\n');
desc.push_str("<b>Name:</b>");
desc.push_str(&factory.name());
desc.push('\n');
let element_keys = factory.metadata_keys();
for key in element_keys {
let val = factory.metadata(&key);
if let Some(val) = val {
desc.push_str("<b>");
desc.push_str(&key);
desc.push_str("</b>:");
desc.push_str(&gtk::glib::markup_escape_text(val).to_string());
desc.push('\n');
let element_keys = factory.metadata_keys();
for key in element_keys {
let val = factory.metadata(&key);
if let Some(val) = val {
desc.push_str("<b>");
desc.push_str(&key);
desc.push_str("</b>:");
desc.push_str(&gtk::glib::markup_escape_text(val));
desc.push('\n');
}
}
}
let feature = factory.upcast::<gst::PluginFeature>();
let plugin = gst::PluginFeature::plugin(&feature);
if let Some(plugin) = plugin {
desc.push('\n');
desc.push_str("<b>Plugin details:</b>");
desc.push('\n');
desc.push_str("<b>Name:");
desc.push_str("</b>");
desc.push_str(gst::Plugin::plugin_name(&plugin).as_str());
desc.push('\n');
desc.push_str("<b>Description:");
desc.push_str("</b>");
desc.push_str(&gtk::glib::markup_escape_text(&plugin.description()).to_string());
desc.push('\n');
desc.push_str("<b>Filename:");
desc.push_str("</b>");
desc.push_str(
&gtk::glib::markup_escape_text(
let feature = factory.upcast::<gst::PluginFeature>();
let plugin = gst::PluginFeature::plugin(&feature);
if let Some(plugin) = plugin {
desc.push('\n');
desc.push_str("<b>Plugin details:</b>");
desc.push('\n');
desc.push_str("<b>Name:");
desc.push_str("</b>");
desc.push_str(gst::Plugin::plugin_name(&plugin).as_str());
desc.push('\n');
desc.push_str("<b>Description:");
desc.push_str("</b>");
desc.push_str(&gtk::glib::markup_escape_text(&plugin.description()));
desc.push('\n');
desc.push_str("<b>Filename:");
desc.push_str("</b>");
desc.push_str(&gtk::glib::markup_escape_text(
&plugin
.filename()
.unwrap_or_default()
.as_path()
.display()
.to_string(),
)
.to_string(),
);
desc.push('\n');
desc.push_str("<b>Version:");
desc.push_str("</b>");
desc.push_str(&gtk::glib::markup_escape_text(&plugin.version()).to_string());
desc.push('\n');
));
desc.push('\n');
desc.push_str("<b>Version:");
desc.push_str("</b>");
desc.push_str(&gtk::glib::markup_escape_text(&plugin.version()));
desc.push('\n');
}
}
}
Ok(desc)
@ -145,44 +154,87 @@ impl ElementInfo {
element_type
}
pub fn element_property(element_name: &str, property_name: &str) -> anyhow::Result<String> {
let feature = ElementInfo::element_feature(element_name).expect("Unable to get feature");
pub fn element_property(element: &gst::Element, property_name: &str) -> anyhow::Result<String> {
let value = element.property_value(property_name);
if value.type_().is_a(glib::Type::ENUM) {
let value = value.get::<&glib::EnumValue>().unwrap().nick().to_string();
Ok(value)
} else if value.type_().is_a(glib::Type::FLAGS) {
let value = value.get::<Vec<&glib::FlagsValue>>().unwrap();
let flags = value.iter().copied().fold(0, |acc, val| acc | val.value());
Ok(flags.to_string())
} else if value.type_().is_a(glib::Type::F64) || value.type_().is_a(glib::Type::F32) {
let value = value
.transform::<String>()
.expect("Unable to transform to string")
.get::<String>()
.unwrap()
.replace(',', ".");
Ok(value)
} else {
let value = value
.transform::<String>()
.expect("Unable to transform to string")
.get::<String>()
.unwrap_or_default()
.to_lowercase();
Ok(value)
}
}
pub fn element_property_by_feature_name(
element_name: &str,
property_name: &str,
) -> anyhow::Result<String> {
let feature = ElementInfo::element_feature(element_name).expect("Unable to get feature");
let factory = feature
.downcast::<gst::ElementFactory>()
.expect("Unable to get the factory from the feature");
let element = factory.create(None)?;
let value = element
.try_property::<String>(property_name)
.unwrap_or_default();
Ok(value)
let element = factory.create().build()?;
ElementInfo::element_property(&element, property_name)
}
pub fn element_properties(
element_name: &str,
element: &gst::Element,
) -> anyhow::Result<HashMap<String, glib::ParamSpec>> {
let mut properties_list = HashMap::new();
let params = element.list_properties();
for param in params.iter() {
GPS_INFO!("Property_name {}", param.name());
if param.flags().contains(glib::ParamFlags::READABLE) {
match element.property_value(param.name()).transform::<String>() {
Ok(value) => {
GPS_INFO!(
"Property_name {}={} type={:?}",
param.name(),
value.get::<String>().unwrap_or_default(),
param.type_()
);
properties_list.insert(String::from(param.name()), param.clone());
}
Err(_e) => {
GPS_ERROR!("Unable to convert the param {} to string ", param.name())
}
}
} else {
GPS_ERROR!("The param {} is not readable", param.name())
}
}
Ok(properties_list)
}
pub fn element_properties_by_feature_name(
element_name: &str,
) -> anyhow::Result<HashMap<String, glib::ParamSpec>> {
let feature = ElementInfo::element_feature(element_name).expect("Unable to get feature");
let factory = feature
.downcast::<gst::ElementFactory>()
.expect("Unable to get the factory from the feature");
let element = factory.create(None)?;
let params = element.class().list_properties();
for param in params.iter() {
let value = element
.try_property::<String>(param.name())
.unwrap_or_default();
GPS_INFO!(
"Property_name {}={} type={:?}",
param.name(),
value,
param.type_()
);
properties_list.insert(String::from(param.name()), param.clone());
}
Ok(properties_list)
let element = factory.create().build()?;
ElementInfo::element_properties(&element)
}
pub fn element_is_uri_src_handler(element_name: &str) -> bool {
@ -192,7 +244,8 @@ impl ElementInfo {
.downcast::<gst::ElementFactory>()
.expect("Unable to get the factory from the feature");
let element = factory
.create(None)
.create()
.build()
.expect("Unable to create an element from the feature");
match element.dynamic_cast::<gst::URIHandler>() {
Ok(uri_handler) => uri_handler.uri_type() == gst::URIType::Src,
@ -223,15 +276,15 @@ impl ElementInfo {
None
}
pub fn search_fo_element(bin: &gst::Bin, element_name: &str) -> Vec<gst::Element> {
pub fn search_for_element(bin: &gst::Bin, element_name: &str) -> Vec<gst::Element> {
let mut iter = bin.iterate_elements();
let mut elements: Vec<gst::Element> = Vec::new();
let elements = loop {
elements = loop {
match iter.next() {
Ok(Some(element)) => {
if element.is::<gst::Bin>() {
let bin = element.dynamic_cast::<gst::Bin>().unwrap();
let mut bin_elements = ElementInfo::search_fo_element(&bin, element_name);
let mut bin_elements = ElementInfo::search_for_element(&bin, element_name);
elements.append(&mut bin_elements);
} else {
GPS_INFO!("Found factory: {}", element.factory().unwrap().name());

View file

@ -2,18 +2,7 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
@ -24,7 +13,7 @@ use crate::graphmanager::{PortDirection, PortPresence};
use gst::prelude::*;
#[derive(Debug, PartialOrd, PartialEq)]
#[derive(Debug, PartialOrd, PartialEq, Eq)]
pub struct PadInfo {
name: Option<String>,
element_name: Option<String>,
@ -54,7 +43,6 @@ impl PadInfo {
gst::PadPresence::Always => PortPresence::Always,
gst::PadPresence::Sometimes => PortPresence::Sometimes,
gst::PadPresence::Request => PortPresence::Sometimes,
_ => PortPresence::Unknown,
}
}
@ -63,41 +51,43 @@ impl PadInfo {
}
pub fn pads(element_name: &str, include_on_request: bool) -> (Vec<PadInfo>, Vec<PadInfo>) {
let feature = ElementInfo::element_feature(element_name).expect("Unable to get feature");
let mut input = vec![];
let mut output = vec![];
if let Ok(factory) = feature.downcast::<gst::ElementFactory>() {
if factory.num_pad_templates() > 0 {
let pads = factory.static_pad_templates();
for pad in pads {
GPS_TRACE!("Found a pad name {}", pad.name_template());
if pad.presence() == gst::PadPresence::Always
|| (include_on_request
&& (pad.presence() == gst::PadPresence::Request
|| pad.presence() == gst::PadPresence::Sometimes))
{
if pad.direction() == gst::PadDirection::Src {
output.push(PadInfo {
name: Some(pad.name_template().to_string()),
element_name: Some(element_name.to_string()),
direction: PortDirection::Output,
presence: PadInfo::pad_to_port_presence(pad.presence()),
caps: Some(pad.caps().to_string()),
});
} else if pad.direction() == gst::PadDirection::Sink {
input.push(PadInfo {
name: Some(pad.name_template().to_string()),
element_name: Some(element_name.to_string()),
direction: PortDirection::Input,
presence: PadInfo::pad_to_port_presence(pad.presence()),
caps: Some(pad.caps().to_string()),
});
if let Some(feature) = ElementInfo::element_feature(element_name) {
if let Ok(factory) = feature.downcast::<gst::ElementFactory>() {
if factory.num_pad_templates() > 0 {
let pads = factory.static_pad_templates();
for pad in pads {
GPS_TRACE!("Found a pad name {}", pad.name_template());
if pad.presence() == gst::PadPresence::Always
|| (include_on_request
&& (pad.presence() == gst::PadPresence::Request
|| pad.presence() == gst::PadPresence::Sometimes))
{
if pad.direction() == gst::PadDirection::Src {
output.push(PadInfo {
name: Some(pad.name_template().to_string()),
element_name: Some(element_name.to_string()),
direction: PortDirection::Output,
presence: PadInfo::pad_to_port_presence(pad.presence()),
caps: Some(pad.caps().to_string()),
});
} else if pad.direction() == gst::PadDirection::Sink {
input.push(PadInfo {
name: Some(pad.name_template().to_string()),
element_name: Some(element_name.to_string()),
direction: PortDirection::Input,
presence: PadInfo::pad_to_port_presence(pad.presence()),
caps: Some(pad.caps().to_string()),
});
}
}
}
}
}
(input, output)
} else {
(input, output)
}
(input, output)
}
}

View file

@ -2,24 +2,15 @@
//
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use crate::app::{AppState, GPSApp, GPSAppWeak};
use crate::graphmanager::{GraphView, Node, NodeType, PortDirection, PropertyExt};
use crate::graphmanager as GM;
use crate::graphmanager::PropertyExt;
use crate::common;
use crate::gps::ElementInfo;
use crate::logger;
use crate::settings;
@ -31,10 +22,11 @@ use gtk::gdk;
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::fmt;
use std::fmt::Write as _;
use std::ops;
use std::rc::{Rc, Weak};
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PipelineState {
Playing,
Paused,
@ -44,7 +36,7 @@ pub enum PipelineState {
impl fmt::Display for PipelineState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}
@ -56,7 +48,7 @@ impl ops::Deref for Player {
type Target = PlayerInner;
fn deref(&self) -> &PlayerInner {
&*self.0
&self.0
}
}
@ -69,12 +61,35 @@ impl PlayerWeak {
}
}
fn gst_log_handler(
category: gst::DebugCategory,
level: gst::DebugLevel,
file: &glib::GStr,
function: &glib::GStr,
line: u32,
_obj: Option<&gst::LoggedObject>,
message: &gst::DebugMessage,
) {
let log_message = format!(
"{}\t{}\t{}:{}:{}\t{}",
level,
category.name(),
line,
file.as_str(),
function.as_str(),
message.get().unwrap().as_str()
);
GPS_GST_LOG!("{}", log_message);
}
#[derive(Debug)]
pub struct PlayerInner {
app: RefCell<Option<GPSApp>>,
pipeline: RefCell<Option<gst::Pipeline>>,
current_state: Cell<PipelineState>,
n_video_sink: Cell<usize>,
bus_watch_guard: RefCell<Option<gst::bus::BusWatchGuard>>,
}
impl Player {
@ -84,15 +99,16 @@ impl Player {
pipeline: RefCell::new(None),
current_state: Cell::new(PipelineState::Stopped),
n_video_sink: Cell::new(0),
bus_watch_guard: RefCell::new(None),
}));
#[cfg(feature = "gtk4-plugin")]
{
gstgtk4::plugin_register_static().expect("Failed to register gstgtk4 plugin");
}
gst::log::add_log_function(gst_log_handler);
Ok(pipeline)
}
pub fn get_version() -> String {
gst::version_string().to_string()
}
pub fn set_app(&self, app: GPSAppWeak) {
*self.app.borrow_mut() = Some(app.upgrade().unwrap());
}
@ -107,38 +123,40 @@ impl Player {
.parse::<bool>()
.expect("Should a boolean value")
{
ElementInfo::element_update_rank("gtk4paintablesink", gst::Rank::Primary);
ElementInfo::element_update_rank("gtk4paintablesink", gst::Rank::PRIMARY);
} else {
ElementInfo::element_update_rank("gtk4paintablesink", gst::Rank::Marginal);
ElementInfo::element_update_rank("gtk4paintablesink", gst::Rank::MARGINAL);
}
gst::log::set_threshold_from_string(settings::Settings::gst_log_level().as_str(), true);
// Create pipeline from the description
let pipeline = gst::parse_launch(&description.to_string())?;
let pipeline = gst::parse::launch(description)?;
let pipeline = pipeline.downcast::<gst::Pipeline>();
/* start playing */
if pipeline.is_err() {
GPS_ERROR!("Can not create a proper pipeline from gstreamer parse_launch");
return Err(anyhow::anyhow!(
"Unable to create a pipeline from the given parse launch {"
"Unable to create a pipeline from the given parse launch"
));
}
self.check_for_gtk4sink(pipeline.as_ref().unwrap());
// GPSApp is not Send(trait) ready , so we use a channel to exchange the given data with the main thread and use
// GPSApp.
let (ready_tx, ready_rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
let (ready_tx, ready_rx) = async_channel::unbounded::<gst::Element>();
let player_weak = self.downgrade();
let _ = ready_rx.attach(None, move |element: gst::Element| {
let player = upgrade_weak!(player_weak, glib::Continue(false));
let paintable = element.property::<gdk::Paintable>("paintable");
let n_sink = player.n_video_sink.get();
player
.app
.borrow()
.as_ref()
.expect("App should be available")
.set_app_preview(&paintable, n_sink);
player.n_video_sink.set(n_sink + 1);
glib::Continue(true)
glib::spawn_future_local(async move {
while let Ok(element) = ready_rx.recv().await {
let player = upgrade_weak!(player_weak, glib::ControlFlow::Break);
let paintable = element.property::<gdk::Paintable>("paintable");
let n_sink = player.n_video_sink.get();
player
.app
.borrow()
.as_ref()
.expect("App should be available")
.set_app_preview(&paintable, n_sink);
player.n_video_sink.set(n_sink + 1);
}
glib::ControlFlow::Continue
});
let bin = pipeline.unwrap().dynamic_cast::<gst::Bin>();
if let Ok(bin) = bin.as_ref() {
@ -146,7 +164,7 @@ impl Player {
if let Some(factory) = element.factory() {
GPS_INFO!("Received the signal deep element added {}", factory.name());
if factory.name() == "gtk4paintablesink" {
let _ = ready_tx.send(element.clone());
let _ = ready_tx.try_send(element.clone());
}
}
});
@ -157,7 +175,7 @@ impl Player {
pub fn check_for_gtk4sink(&self, pipeline: &gst::Pipeline) {
let bin = pipeline.clone().dynamic_cast::<gst::Bin>().unwrap();
let gtksinks = ElementInfo::search_fo_element(&bin, "gtk4paintablesink");
let gtksinks = ElementInfo::search_for_element(&bin, "gtk4paintablesink");
for (first_sink, gtksink) in gtksinks.into_iter().enumerate() {
let paintable = gtksink.property::<gdk::Paintable>("paintable");
@ -171,25 +189,26 @@ impl Player {
pub fn start_pipeline(
&self,
graphview: &GraphView,
graphview: &GM::GraphView,
new_state: PipelineState,
) -> anyhow::Result<PipelineState> {
if self.state() == PipelineState::Stopped || self.state() == PipelineState::Error {
let pipeline = self
.create_pipeline(&self.render_gst_launch(graphview))
.create_pipeline(&self.pipeline_description_from_graphview(graphview))
.map_err(|err| {
GPS_ERROR!("Unable to start a pipeline: {}", err);
GPS_ERROR!("Unable to create a pipeline: {}", err);
err
})?;
let bus = pipeline.bus().expect("Pipeline had no bus");
let pipeline_weak = self.downgrade();
bus.add_watch_local(move |_bus, msg| {
let pipeline = upgrade_weak!(pipeline_weak, glib::Continue(false));
let bus_watch_guard = bus.add_watch_local(move |_bus, msg| {
let pipeline = upgrade_weak!(pipeline_weak, glib::ControlFlow::Break);
pipeline.on_pipeline_message(msg);
glib::Continue(true)
glib::ControlFlow::Continue
})?;
*self.pipeline.borrow_mut() = Some(pipeline);
*self.bus_watch_guard.borrow_mut() = Some(bus_watch_guard);
}
self.set_state(new_state).map_err(|error| {
@ -207,6 +226,7 @@ impl Player {
PipelineState::Paused => pipeline.set_state(gst::State::Paused)?,
PipelineState::Stopped | PipelineState::Error => {
pipeline.set_state(gst::State::Null)?;
self.n_video_sink.set(0);
gst::StateChangeSuccess::Success
}
};
@ -276,6 +296,9 @@ impl Player {
pub fn playing(&self) -> bool {
self.state() == PipelineState::Playing || self.state() == PipelineState::Paused
}
pub fn n_video_sink(&self) -> usize {
self.n_video_sink.get()
}
pub fn downgrade(&self) -> PlayerWeak {
PlayerWeak(Rc::downgrade(&self.0))
@ -283,6 +306,9 @@ impl Player {
fn on_pipeline_message(&self, msg: &gst::MessageRef) {
use gst::MessageView;
if let Some(message) = msg.structure() {
GPS_MSG_LOG!("{:?}", message);
}
match msg.view() {
MessageView::Eos(_) => {
GPS_INFO!("EOS received");
@ -321,7 +347,7 @@ impl Player {
.unwrap()
.dynamic_cast::<gst::Bin>()
.unwrap();
let elements_name: Vec<String> = ElementInfo::search_fo_element(&bin, "")
let elements_name: Vec<String> = ElementInfo::search_for_element(&bin, "")
.iter()
.map(|e| e.factory().unwrap().name().to_string())
.collect();
@ -331,45 +357,51 @@ impl Player {
}
// Render graph methods
#[allow(clippy::only_used_in_recursion)]
fn process_gst_node(
&self,
graphview: &GraphView,
node: &Node,
graphview: &GM::GraphView,
node: &GM::Node,
elements: &mut HashMap<String, String>,
mut description: String,
) -> String {
let unique_name = node.unique_name();
description.push_str(&format!("{} name={} ", node.name(), unique_name));
let _ = write!(description, "{} name={} ", node.name(), unique_name);
elements.insert(unique_name.clone(), unique_name.clone());
// Node properties
for (name, value) in node.properties().iter() {
//This allow to have an index in front of a property such as an enum.
if !node.hidden_property(name) {
description.push_str(&format!("{}={} ", name, value));
let _ = write!(description, "{name}={value} ");
}
}
//Port properties
let ports = node.all_ports(PortDirection::All);
let ports = node.all_ports(GM::PortDirection::All);
for port in ports {
for (name, value) in port.properties().iter() {
if !port.hidden_property(name) {
description.push_str(&format!("{}::{}={} ", port.name(), name, value));
let _ = write!(description, "{}::{}={} ", port.name(), name, value);
}
}
}
let ports = node.all_ports(PortDirection::Output);
let ports = node.all_ports(GM::PortDirection::Output);
let n_ports = ports.len();
for port in ports {
if let Some((_port_to, node_to)) = graphview.port_connected_to(port.id()) {
if n_ports > 1 {
description.push_str(&format!("{}. ! ", unique_name));
let _ = write!(description, "{unique_name}. ! ");
} else {
if let Some(link) = graphview.port_link(port.id()) {
if !link.name().is_empty() {
let _ = write!(description, "! {} ", link.name());
}
}
description.push_str("! ");
}
if let Some(node) = graphview.node(node_to) {
if elements.contains_key(&node.unique_name()) {
description.push_str(&format!("{}. ", node.unique_name()));
let _ = write!(description, "{}. ", node.unique_name());
} else {
description =
self.process_gst_node(graphview, &node, elements, description.clone());
@ -380,8 +412,8 @@ impl Player {
description
}
pub fn render_gst_launch(&self, graphview: &GraphView) -> String {
let source_nodes = graphview.all_nodes(NodeType::Source);
pub fn pipeline_description_from_graphview(&self, graphview: &GM::GraphView) -> String {
let source_nodes = graphview.all_nodes(GM::NodeType::Source);
let mut elements: HashMap<String, String> = HashMap::new();
let mut description = String::from("");
for source_node in source_nodes {
@ -390,19 +422,146 @@ impl Player {
}
description
}
pub fn create_links_for_element(&self, element: &gst::Element, graphview: &GM::GraphView) {
let mut iter = element.iterate_pads();
let node = graphview
.node_by_unique_name(&element.name())
.expect("node should exists");
loop {
match iter.next() {
Ok(Some(pad)) => {
GPS_INFO!("Found pad: {}", pad.name());
if pad.direction() == gst::PadDirection::Src {
let port = node
.port_by_name(&pad.name())
.expect("The port should exist here");
if let Some(peer_pad) = pad.peer() {
if let Some(peer_element) = peer_pad.parent_element() {
let peer_node = graphview
.node_by_unique_name(&peer_element.name())
.expect("The node should exists here");
let peer_port = peer_node
.port_by_name(&peer_pad.name())
.expect("The port should exists here");
self.app.borrow().as_ref().unwrap().create_link(
node.id(),
peer_node.id(),
port.id(),
peer_port.id(),
);
}
}
}
}
Err(gst::IteratorError::Resync) => iter.resync(),
_ => break,
}
}
}
pub fn create_pads_for_element(&self, element: &gst::Element, node: &GM::Node) {
let mut iter = element.iterate_pads();
loop {
match iter.next() {
Ok(Some(pad)) => {
let pad_name = pad.name().to_string();
GPS_INFO!("Found pad: {}", pad_name);
let mut port_direction = GM::PortDirection::Input;
if pad.direction() == gst::PadDirection::Src {
port_direction = GM::PortDirection::Output;
}
let port_id = self.app.borrow().as_ref().unwrap().create_port_with_caps(
node.id(),
port_direction,
GM::PortPresence::Always,
pad.current_caps()
.unwrap_or_else(|| pad.query_caps(None))
.to_string(),
);
if let Some(port) = node.port(port_id) {
port.set_name(&pad_name);
}
}
Err(gst::IteratorError::Resync) => iter.resync(),
_ => break,
}
}
}
pub fn create_properties_for_element(&self, element: &gst::Element, node: &GM::Node) {
let properties = ElementInfo::element_properties(element)
.unwrap_or_else(|_| panic!("Couldn't get properties for {}", node.name()));
for (property_name, property_value) in properties {
if property_name == "name"
|| property_name == "parent"
|| (property_value.flags() & glib::ParamFlags::READABLE)
!= glib::ParamFlags::READABLE
{
continue;
}
if let Ok(value_str) = ElementInfo::element_property(element, &property_name) {
let default_value_str =
common::value_as_str(property_value.default_value()).unwrap_or_default();
GPS_DEBUG!(
"property name {} value_str '{}' default '{}'",
property_name,
value_str,
default_value_str
);
if !value_str.is_empty() && value_str != default_value_str {
node.add_property(&property_name, &value_str);
}
}
}
}
pub fn graphview_from_pipeline_description(
&self,
graphview: &GM::GraphView,
pipeline_desc: &str,
) {
graphview.clear();
if let Ok(pipeline) = self.create_pipeline(pipeline_desc) {
let mut iter = pipeline.iterate_elements();
let mut elements: Vec<gst::Element> = Vec::new();
let elements = loop {
match iter.next() {
Ok(Some(element)) => {
GPS_INFO!("Found element: {}", element.name());
let element_factory_name = element.factory().unwrap().name().to_string();
let node = graphview.create_node(
&element_factory_name,
ElementInfo::element_type(&element_factory_name),
);
node.set_unique_name(&element.name());
graphview.add_node(node.clone());
self.create_pads_for_element(&element, &node);
self.create_properties_for_element(&element, &node);
elements.push(element);
}
Err(gst::IteratorError::Resync) => iter.resync(),
_ => break elements,
}
};
for element in elements {
self.create_links_for_element(&element, graphview);
}
} else {
GPS_ERROR!("Unable to create a pipeline: {}", pipeline_desc);
}
}
}
impl Drop for PlayerInner {
fn drop(&mut self) {
// TODO: If a recording is currently running we would like to finish that first
// before quitting the pipeline and shutting down the pipeline.
if let Some(pipeline) = self.pipeline.borrow().to_owned() {
// We ignore any errors here
let _ = pipeline.set_state(gst::State::Null);
// Remove the message watch from the bus
let bus = pipeline.bus().expect("Pipeline had no bus");
let _ = bus.remove_watch();
}
}
}

58
src/gps/test.rs Normal file
View file

@ -0,0 +1,58 @@
use crate::gps::player::Player;
use crate::graphmanager as GM;
#[cfg(test)]
fn test_synced<F, R>(function: F) -> R
where
F: FnOnce() -> R + Send + std::panic::UnwindSafe + 'static,
R: Send + 'static,
{
/// No-op.
macro_rules! skip_assert_initialized {
() => {};
}
skip_assert_initialized!();
use futures_channel::oneshot;
use std::panic;
let (tx, rx) = oneshot::channel();
TEST_THREAD_WORKER
.push(move || {
tx.send(panic::catch_unwind(function))
.unwrap_or_else(|_| panic!("Failed to return result from thread pool"));
})
.expect("Failed to schedule a test call");
futures_executor::block_on(rx)
.expect("Failed to receive result from thread pool")
.unwrap_or_else(|e| std::panic::resume_unwind(e))
}
#[cfg(test)]
static TEST_THREAD_WORKER: once_cell::sync::Lazy<gtk::glib::ThreadPool> =
once_cell::sync::Lazy::new(|| {
let pool = gtk::glib::ThreadPool::exclusive(1).unwrap();
pool.push(move || {
gtk::init().expect("Tests failed to initialize gtk");
})
.expect("Failed to schedule a test call");
pool
});
#[cfg(test)]
mod player_test {
use super::*;
fn check_pipeline(pipeline_desc: &str) {
let player = Player::new().expect("Not able to create the player");
let graphview = GM::GraphView::new();
player.graphview_from_pipeline_description(&graphview, pipeline_desc);
}
#[test]
fn pipeline_creation() {
test_synced(|| {
println!("coucou");
//check_pipeline("videotestsrc ! autovideosink");
});
}
}

499
src/graphbook.rs Normal file
View file

@ -0,0 +1,499 @@
// graphbook.rs
//
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use crate::app::{GPSApp, GPSAppWeak};
use crate::gps as GPS;
use crate::graphmanager as GM;
use crate::graphmanager::PropertyExt;
use crate::logger;
use crate::settings::Settings;
use crate::ui as GPSUI;
use crate::{GPS_DEBUG, GPS_TRACE, GPS_WARN};
use glib::Value;
use gtk::prelude::*;
use gtk::{gio, glib, graphene};
use std::cell::{Cell, Ref, RefCell};
use std::path::Path;
#[derive(Debug, Clone, Copy, PartialEq)]
enum TabState {
Undefined = 0,
Modified,
Saved,
}
#[derive(Debug, Clone)]
pub struct GraphTab {
graphview: RefCell<GM::GraphView>,
player: RefCell<GPS::Player>,
id: Cell<u32>,
name: gtk::Label,
filename: RefCell<String>,
state: Cell<TabState>,
}
impl GraphTab {
pub fn new(app: GPSAppWeak, id: u32, filename: &str) -> Self {
let label = gtk::Label::new(Some("Untitled*"));
let graphtab = GraphTab {
id: Cell::new(id),
graphview: RefCell::new(GM::GraphView::new()),
player: RefCell::new(
GPS::Player::new().expect("Unable to initialize GStreamer subsystem"),
),
name: label,
filename: RefCell::new(filename.to_string()),
state: Cell::new(TabState::Undefined),
};
graphtab
.graphview
.borrow()
.set_id(graphbook_get_new_graphview_id(&app));
graphtab.player.borrow().set_app(app);
graphtab
}
pub fn id(&self) -> u32 {
self.id.get()
}
pub fn widget_label(&self) -> &gtk::Label {
&self.name
}
pub fn graphview(&self) -> Ref<GM::GraphView> {
self.graphview.borrow()
}
pub fn player(&self) -> Ref<GPS::Player> {
self.player.borrow()
}
pub fn set_name(&self, name: &str) {
self.name.set_text(name);
}
pub fn basename(&self) -> String {
Path::new(&self.filename.borrow().as_str())
.file_name()
.unwrap()
.to_str()
.unwrap()
.to_string()
}
pub fn set_filename(&self, filename: &str) {
self.filename.replace(filename.to_string());
self.set_name(self.basename().as_str());
self.set_modified(false);
}
pub fn filename(&self) -> String {
self.filename.borrow().clone()
}
pub fn set_modified(&self, modified: bool) {
let name = self.basename();
if modified {
self.set_name(&(name + "*"));
self.state.set(TabState::Modified);
} else {
self.set_name(name.as_str());
self.state.set(TabState::Saved);
}
}
pub fn undefined(&self) -> bool {
self.state.get() == TabState::Undefined
}
pub fn modified(&self) -> bool {
self.state.get() == TabState::Modified
}
}
pub fn graphtab(app: &GPSApp, id: u32) -> GraphTab {
app.graphbook
.borrow()
.get(&id)
.cloned()
.expect("the current graphtab should be ok")
}
pub fn graphbook_get_new_graphview_id(app_weak: &GPSAppWeak) -> u32 {
let app = app_weak.upgrade();
let mut graphview_id: u32 = 0;
for tab in app.unwrap().graphbook.borrow().values() {
if tab.graphview().id() > graphview_id {
graphview_id = tab.graphview().id()
}
}
graphview_id + 1
}
pub fn graphbook_get_new_graphtab_id(app: &GPSApp) -> u32 {
let mut graphtab_id: u32 = 0;
for tab in app.graphbook.borrow().values() {
if tab.id() > graphtab_id {
graphtab_id = tab.id()
}
}
graphtab_id + 1
}
pub fn current_graphtab(app: &GPSApp) -> GraphTab {
graphtab(app, app.current_graphtab.get())
}
pub fn current_graphtab_set_filename(app: &GPSApp, filename: &str) {
app.graphbook
.borrow()
.get(&app.current_graphtab.get())
.expect("the graphtab is available")
.set_filename(filename);
}
pub fn current_graphtab_set_modified(app: &GPSApp, modified: bool) {
app.graphbook
.borrow()
.get(&app.current_graphtab.get())
.expect("the graphtab is available")
.set_modified(modified);
}
pub fn setup_graphbook(app: &GPSApp) {
let graphbook: gtk::Notebook = app
.builder
.object("graphbook")
.expect("Couldn't get the graphbook");
let app_weak = app.downgrade();
graphbook.connect_switch_page(move |_book, widget, page| {
let graphview = widget
.first_child()
.expect("Unable to get the child from the graphbook, ie the graphview");
if let Ok(graphview) = graphview.dynamic_cast::<GM::GraphView>() {
let app = upgrade_weak!(app_weak);
GPS_TRACE!("graphview.id() {} graphbook page {}", graphview.id(), page);
app.current_graphtab.set(page);
}
});
}
pub fn create_graphtab(app: &GPSApp, id: u32, name: Option<&str>) {
let graph_tab = GraphTab::new(app.downgrade(), id, name.unwrap_or("Untitled"));
let gt = graph_tab.clone();
app.graphbook.borrow_mut().insert(id, graph_tab);
let graphbook: gtk::Notebook = app
.builder
.object("graphbook")
.expect("Couldn't get graphbook");
let drawing_area_window: gtk::Viewport = gtk::Viewport::builder().build();
drawing_area_window.set_child(Some(&*graphtab(app, id).graphview()));
let tab_box = gtk::Box::new(gtk::Orientation::Horizontal, 0);
let label = gt.widget_label();
tab_box.append(label);
let icon = gtk::Image::from_icon_name("window-close-symbolic");
let close_button = gtk::Button::builder().build();
close_button.set_child(Some(&icon));
close_button.add_css_class("small-button");
close_button.add_css_class("image-button");
close_button.add_css_class("flat");
let app_weak = app.downgrade();
close_button.connect_clicked(glib::clone!(@weak graphbook => move |_| {
let app = upgrade_weak!(app_weak);
graphbook.remove_page(Some(current_graphtab(&app).id()));
}));
tab_box.append(&close_button);
graphbook.append_page(&drawing_area_window, Some(&tab_box));
graphbook.set_tab_reorderable(&drawing_area_window, true);
let app_weak = app.downgrade();
gt.graphview().connect_local(
"graph-updated",
false,
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let id = values[1].get::<u32>().expect("id in args[1]");
GPS_DEBUG!("Graph updated id={}", id);
let _ = app
.save_graph(
Settings::graph_file_path()
.to_str()
.expect("Unable to convert to string"),
)
.map_err(|e| GPS_WARN!("Unable to save file {}", e));
current_graphtab_set_modified(&app, true);
None
}),
);
let app_weak = app.downgrade();
gt.graphview().connect_local(
"node-added",
false,
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let graph_id = values[1].get::<u32>().expect("graph id in args[1]");
let node_id = values[2].get::<u32>().expect("node id in args[2]");
GPS_DEBUG!("Node added node id={} in graph id={}", node_id, graph_id);
if let Some(node) = current_graphtab(&app).graphview().node(node_id) {
let description = GPS::ElementInfo::element_description(&node.name()).ok();
node.set_tooltip_markup(description.as_deref());
if !GPS::ElementInfo::element_factory_exists(&node.name()) {
node.set_light(true);
}
for port in node.all_ports(GM::PortDirection::All) {
let caps = PropertyExt::property(&port,"_caps");
GPS_DEBUG!("caps={} for port id {}", caps.clone().unwrap_or_else(|| "caps unknown".to_string()), port.id());
port.set_tooltip_markup(caps.as_deref());
}
}
None
}),
);
let app_weak = app.downgrade();
gt.graphview().connect_local(
"port-added",
false,
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let graph_id = values[1].get::<u32>().expect("graph id in args[1]");
let node_id = values[2].get::<u32>().expect("node id in args[2]");
let port_id = values[3].get::<u32>().expect("port id in args[3]");
GPS_DEBUG!("Port added port id={} to node id={} in graph id={}", port_id, node_id, graph_id);
if let Some(node) = current_graphtab(&app).graphview().node(node_id) {
if let Some(port) = node.port(port_id) {
let caps = PropertyExt::property(&port, "_caps");
GPS_DEBUG!("caps={} for port id {}", caps.clone().unwrap_or_else(|| "caps unknown".to_string()), port.id());
port.set_tooltip_markup(caps.as_deref());
}
}
None
}),
);
// When user clicks on port with right button
let app_weak = app.downgrade();
gt.graphview()
.connect_local(
"graph-right-clicked",
false,
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let point = values[1].get::<graphene::Point>().expect("point in args[2]");
let pop_menu = app.app_pop_menu_at_position(&*current_graphtab(&app).graphview(), point.to_vec2().x() as f64, point.to_vec2().y() as f64);
let menu: gio::MenuModel = app
.builder
.object("graph_menu")
.expect("Couldn't graph_menu");
pop_menu.set_menu_model(Some(&menu));
let app_weak = app.downgrade();
app.connect_app_menu_action("graph.clear",
move |_,_| {
let app = upgrade_weak!(app_weak);
current_graphtab(&app).graphview().clear();
}
);
let app_weak = app.downgrade();
app.connect_app_menu_action("graph.check",
move |_,_| {
let app = upgrade_weak!(app_weak);
let render_parse_launch = current_graphtab(&app).player().pipeline_description_from_graphview(&current_graphtab(&app).graphview());
if current_graphtab(&app).player().create_pipeline(&render_parse_launch).is_ok() {
GPSUI::message::display_message_dialog(&render_parse_launch,gtk::MessageType::Info, |_| {});
} else {
GPSUI::message::display_error_dialog(false, &format!("Unable to render:\n\n{render_parse_launch}"));
}
}
);
let app_weak = app.downgrade();
app.connect_app_menu_action("graph.pipeline_details",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPSUI::properties::display_pipeline_details(&app);
}
);
pop_menu.show();
None
}),
);
// When user clicks on port with right button
let app_weak = app.downgrade();
gt.graphview()
.connect_local("port-right-clicked", false, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let port_id = values[1].get::<u32>().expect("port id args[1]");
let node_id = values[2].get::<u32>().expect("node id args[2]");
let point = values[3]
.get::<graphene::Point>()
.expect("point in args[3]");
let pop_menu = app.app_pop_menu_at_position(
&*current_graphtab(&app).graphview(),
point.to_vec2().x() as f64,
point.to_vec2().y() as f64,
);
let menu: gio::MenuModel = app
.builder
.object("port_menu")
.expect("Couldn't get menu model for port");
pop_menu.set_menu_model(Some(&menu));
if current_graphtab(&app)
.graphview()
.can_remove_port(node_id, port_id)
{
let app_weak = app.downgrade();
app.connect_app_menu_action("port.delete", move |_, _| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("port.delete-link port id {} node id {}", port_id, node_id);
current_graphtab(&app)
.graphview()
.remove_port(node_id, port_id);
});
} else {
app.disconnect_app_menu_action("port.delete");
}
let app_weak = app.downgrade();
app.connect_app_menu_action("port.properties", move |_, _| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("port.properties port id {} node id {}", port_id, node_id);
let node = app.node(node_id);
let port = app.port(node_id, port_id);
GPSUI::properties::display_pad_properties(
&app,
&node.name(),
&port.name(),
node_id,
port_id,
);
});
pop_menu.show();
None
});
// When user clicks on node with right button
let app_weak = app.downgrade();
gt.graphview()
.connect_local(
"node-right-clicked",
false,
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let node_id = values[1].get::<u32>().expect("node id args[1]");
let node = current_graphtab(&app).graphview().node(node_id).unwrap();
let element_exists = GPS::ElementInfo::element_factory_exists(&node.name());
let point = values[2].get::<graphene::Point>().expect("point in args[2]");
let pop_menu = app.app_pop_menu_at_position(&*current_graphtab(&app).graphview(), point.to_vec2().x() as f64, point.to_vec2().y() as f64);
let menu: gio::MenuModel = app
.builder
.object("node_menu")
.expect("Couldn't get menu model for node");
pop_menu.set_menu_model(Some(&menu));
let app_weak = app.downgrade();
app.connect_app_menu_action("node.delete",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.delete id: {}", node_id);
current_graphtab(&app).graphview().remove_node(node_id);
}
);
if element_exists {
let app_weak = app.downgrade();
app.connect_app_menu_action("node.add-to-favorite",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.add-to-favorite id: {}", node_id);
if let Some(node) = current_graphtab(&app).graphview().node(node_id) {
GPSUI::elements::add_to_favorite_list(&app, node.name());
};
}
);
let node = app.node(node_id);
if let Some(input) = GPS::ElementInfo::element_supports_new_pad_request(&node.name(), GM::PortDirection::Input) {
let app_weak = app.downgrade();
app.connect_app_menu_action("node.request-pad-input",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.request-pad-input id: {}", node_id);
app.create_port_with_caps(node_id, GM::PortDirection::Input, GM::PortPresence::Sometimes, input.caps().to_string());
}
);
} else {
app.disconnect_app_menu_action("node.request-pad-input");
}
let node = app.node(node_id);
if let Some(output) = GPS::ElementInfo::element_supports_new_pad_request(&node.name(), GM::PortDirection::Output) {
let app_weak = app.downgrade();
app.connect_app_menu_action("node.request-pad-output",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.request-pad-output id: {}", node_id);
app.create_port_with_caps(node_id, GM::PortDirection::Output, GM::PortPresence::Sometimes, output.caps().to_string());
}
);
} else {
app.disconnect_app_menu_action("node.request-pad-output");
}
let app_weak = app.downgrade();
app.connect_app_menu_action("node.properties",
move |_,_| {
let app = upgrade_weak!(app_weak);
GPS_DEBUG!("node.properties id {}", node_id);
let node = current_graphtab(&app).graphview().node(node_id).unwrap();
GPSUI::properties::display_plugin_properties(&app, &node.name(), node_id);
}
);
}
pop_menu.show();
None
}),
);
let app_weak = app.downgrade();
gt.graphview().connect_local(
"node-double-clicked",
false,
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let node_id = values[1].get::<u32>().expect("node id args[1]");
GPS_TRACE!("Node double clicked id={}", node_id);
let node = current_graphtab(&app).graphview().node(node_id).unwrap();
if GPS::ElementInfo::element_factory_exists(&node.name()) {
GPSUI::properties::display_plugin_properties(&app, &node.name(), node_id);
}
None
}),
);
let app_weak = app.downgrade();
gt.graphview().connect_local(
"link-double-clicked",
false,
glib::clone!(@weak graphbook => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let link_id = values[1].get::<u32>().expect("link id args[1]");
GPS_TRACE!("link double clicked id={}", link_id);
let link = current_graphtab(&app).graphview().link(link_id).unwrap();
GPSUI::dialog::create_input_dialog(
"Enter caps filter description",
"description",
&link.name(),
&app,
move |app, link_desc| {
current_graphtab(&app).graphview().set_link_name(link.id(), link_desc.as_str());
GPS_DEBUG!("link double clicked id={} name={}", link.id(), link.name());
},
);
None
}),
);
}

674
src/graphmanager/LICENSE Normal file
View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View file

@ -14,6 +14,10 @@ button.node-selected {
background: rgb(170, 255, 170);
}
button.node-light {
border-style: dashed;
}
button.port {
color: rgb(0, 0, 255);
border-width: 2px;
@ -44,4 +48,4 @@ button.port-always {
graphview {
background: #d0d2d4;
}
}

View file

@ -3,18 +3,7 @@
// Copyright 2021 Tom A. Wagner <tom.a.wagner@protonmail.com>
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GraphManager
//
// SPDX-License-Identifier: GPL-3.0-only
@ -48,6 +37,7 @@ use std::cell::RefMut;
use std::{cmp::Ordering, collections::HashMap};
static GRAPHVIEW_STYLE: &str = include_str!("graphview.css");
pub static GRAPHVIEW_XML_VERSION: &str = "0.1";
mod imp {
use super::*;
@ -85,8 +75,9 @@ mod imp {
}
impl ObjectImpl for GraphView {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
let obj = self.obj();
self.parent_constructed();
let drag_state = Rc::new(RefCell::new(None));
let drag_controller = gtk::GestureDrag::new();
@ -142,8 +133,6 @@ mod imp {
),
);
obj.add_controller(&drag_controller);
let gesture = gtk::GestureClick::new();
gesture.set_button(0);
gesture.connect_pressed(
@ -155,7 +144,7 @@ mod imp {
let target = widget.pick(x, y, gtk::PickFlags::DEFAULT).expect("port pick() did not return a widget");
if let Some(target) = target.ancestor(Port::static_type()) {
let port = target.dynamic_cast::<Port>().expect("click event is not on the Port");
let node = port.ancestor(Node::static_type()).expect("Unable to reach parent").dynamic_cast::<Node>().expect("Unable to cast to Node");
let node = port.ancestor(Node::static_type()).expect("Unable to reach parent").dynamic_cast::<Node>().expect("Unable to cast to Node");
obj.emit_by_name::<()>("port-right-clicked", &[&port.id(), &node.id(), &graphene::Point::new(x as f32,y as f32)]);
} else if let Some(target) = target.ancestor(Node::static_type()) {
let node = target.dynamic_cast::<Node>().expect("click event is not on the Node");
@ -187,7 +176,7 @@ mod imp {
}),
);
gesture.connect_released(clone!(@weak gesture, @weak drag_controller => move |_gesture, _n_press, x, y| {
gesture.connect_released(clone!(@weak gesture, @weak obj, @weak drag_controller => move |_gesture, _n_press, x, y| {
if gesture.current_button() == BUTTON_PRIMARY {
let widget = drag_controller
.widget()
@ -215,7 +204,6 @@ mod imp {
node_to.id(),
port_from.id(),
port_to.id(),
true,
));
}
widget.set_selected_port(None);
@ -227,14 +215,28 @@ mod imp {
// click to a linked port
widget.set_selected_port(None);
}
} else {
}
else {
if let Some(target) = target.ancestor(Node::static_type()) {
let node = target.dynamic_cast::<Node>().expect("click event is not on the Node");
info!(" node id {}", node.id());
if _n_press % 2 == 0 {
info!("double clicked node id {}", node.id());
obj.emit_by_name::<()>("node-double-clicked", &[&node.id(), &graphene::Point::new(x as f32,y as f32)]);
}
} else if _n_press % 2 == 0 {
if let Some(link) = widget.point_on_link(&graphene::Point::new(x.floor() as f32,y.floor() as f32)) {
info!("double clicked link id {}", link.id());
obj.emit_by_name::<()>("link-double-clicked", &[&link.id(), &graphene::Point::new(x as f32,y as f32)]);
}
}
// Click to something else than a port
widget.set_selected_port(None);
}
}
}
}));
obj.add_controller(&gesture);
let event_motion = gtk::EventControllerMotion::new();
event_motion.connect_motion(glib::clone!(@weak obj => move |_e, x, y| {
@ -245,10 +247,13 @@ mod imp {
}
}));
obj.add_controller(&event_motion);
obj.add_controller(drag_controller);
obj.add_controller(gesture);
obj.add_controller(event_motion);
}
fn dispose(&self, _obj: &Self::Type) {
fn dispose(&self) {
self.nodes
.borrow()
.values()
@ -258,56 +263,40 @@ mod imp {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
vec![
Signal::builder(
"port-right-clicked",
&[
u32::static_type().into(),
u32::static_type().into(),
graphene::Point::static_type().into(),
],
<()>::static_type().into(),
)
.build(),
Signal::builder(
"node-right-clicked",
&[
u32::static_type().into(),
graphene::Point::static_type().into(),
],
<()>::static_type().into(),
)
.build(),
Signal::builder(
"graph-right-clicked",
&[graphene::Point::static_type().into()],
<()>::static_type().into(),
)
.build(),
Signal::builder(
"graph-updated",
// returns graph ID
&[u32::static_type().into()],
<()>::static_type().into(),
)
.build(),
Signal::builder(
"node-added",
// returns graph ID and Node ID
&[u32::static_type().into(), u32::static_type().into()],
<()>::static_type().into(),
)
.build(),
Signal::builder(
"port-added",
// returns graph ID, Node ID, Port ID
&[
u32::static_type().into(),
u32::static_type().into(),
u32::static_type().into(),
],
<()>::static_type().into(),
)
.build(),
Signal::builder("port-right-clicked")
.param_types([
u32::static_type(),
u32::static_type(),
graphene::Point::static_type(),
])
.build(),
Signal::builder("node-right-clicked")
.param_types([u32::static_type(), graphene::Point::static_type()])
.build(),
Signal::builder("node-double-clicked")
.param_types([u32::static_type(), graphene::Point::static_type()])
.build(),
Signal::builder("graph-right-clicked")
.param_types([graphene::Point::static_type()])
.build(),
Signal::builder("graph-updated")
.param_types(
// returns graph ID
[u32::static_type()],
)
.build(),
Signal::builder("node-added")
.param_types(
// returns graph ID and Node ID
[u32::static_type(), u32::static_type()],
)
.build(),
Signal::builder("port-added")
.param_types([u32::static_type(), u32::static_type(), u32::static_type()])
.build(),
Signal::builder("link-double-clicked")
.param_types([u32::static_type(), graphene::Point::static_type()])
.build(),
]
});
SIGNALS.as_ref()
@ -315,7 +304,7 @@ mod imp {
}
impl WidgetImpl for GraphView {
fn snapshot(&self, _widget: &Self::Type, snapshot: &gtk::Snapshot) {
fn snapshot(&self, snapshot: &gtk::Snapshot) {
/* FIXME: A lot of hardcoded values in here.
Try to use relative units (em) and colours from the theme as much as possible. */
@ -323,14 +312,15 @@ mod imp {
self.nodes
.borrow()
.values()
.for_each(|node| self.instance().snapshot_child(node, snapshot));
.for_each(|node| self.obj().snapshot_child(node, snapshot));
for link in self.links.borrow().values() {
if let Some((from_x, from_y, to_x, to_y)) = self.link_coordinates(link) {
self.draw_link(
snapshot,
link.active,
link.active(),
link.selected(),
link.name().as_str(),
link.thickness as f64,
&graphene::Point::new(from_x as f32, from_y as f32),
&graphene::Point::new(to_x as f32, to_y as f32),
@ -354,6 +344,7 @@ mod imp {
snapshot,
false,
false,
"",
2.0,
&graphene::Point::new(from_x as f32, from_y as f32),
&graphene::Point::new(to_x as f32, to_y as f32),
@ -368,7 +359,7 @@ mod imp {
let from_node = nodes
.get(&node_from)
.unwrap_or_else(|| panic!("Unable to get node from {}", node_from));
.unwrap_or_else(|| (panic!("Unable to get node from {}", node_from)));
let from_port = from_node
.port(port_from)
@ -422,17 +413,18 @@ mod imp {
let (to_x, to_y) = self.link_to_coordinates(link.node_to, link.port_to);
Some((from_x, from_y, to_x, to_y))
}
#[allow(clippy::too_many_arguments)]
fn draw_link(
&self,
snapshot: &gtk::Snapshot,
active: bool,
selected: bool,
name: &str,
thickness: f64,
point_from: &graphene::Point,
point_to: &graphene::Point,
) {
let alloc = self.instance().allocation();
let alloc = self.obj().allocation();
let link_cr = snapshot.append_cairo(&graphene::Rect::new(
0.0,
@ -460,6 +452,13 @@ mod imp {
if let Err(e) = link_cr.stroke() {
warn!("Failed to draw graphview links: {}", e);
};
trace!("the link name is {}", name);
if !name.is_empty() {
let x = (point_from.x() + point_to.x()) / 2.0 + 20.0;
let y = (point_from.y() + point_to.y()) / 2.0 + 20.0;
link_cr.move_to(x as f64, y as f64);
let _ = link_cr.show_text(name);
}
}
}
}
@ -477,26 +476,26 @@ impl GraphView {
pub fn new() -> Self {
// Load CSS from the STYLE variable.
let provider = gtk::CssProvider::new();
provider.load_from_data(GRAPHVIEW_STYLE.as_bytes());
gtk::StyleContext::add_provider_for_display(
provider.load_from_data(GRAPHVIEW_STYLE);
gtk::style_context_add_provider_for_display(
&gtk::gdk::Display::default().expect("Error initializing gtk css provider."),
&provider,
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
);
glib::Object::new(&[]).expect("Failed to create GraphView")
glib::Object::new::<Self>()
}
/// Set graphview id
///
pub fn set_id(&self, id: u32) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
private.id.set(id)
}
/// Retrives the graphview id
/// Retrieves the graphview id
///
pub fn id(&self) -> u32 {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
private.id.get()
}
@ -542,10 +541,10 @@ impl GraphView {
/// Add node to the graphview without port
///
pub fn add_node(&self, node: Node) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
node.set_parent(self);
// Place widgets in colums of 3, growing down
// Place widgets in columns of 3, growing down
let x = if let Some(node_type) = node.node_type() {
match node_type {
NodeType::Source => 20.0,
@ -585,7 +584,7 @@ impl GraphView {
/// Remove node from the graphview
///
pub fn remove_node(&self, id: u32) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let mut nodes = private.nodes.borrow_mut();
if let Some(node) = nodes.remove(&id) {
while let Some(link_id) = self.node_is_linked(node.id()) {
@ -594,7 +593,7 @@ impl GraphView {
}
node.unparent();
} else {
warn!("Tried to remove non-existant node (id={}) from graph", id);
warn!("Tried to remove non-existent node (id={}) from graph", id);
}
self.queue_draw();
}
@ -603,7 +602,7 @@ impl GraphView {
///
/// Returns a vector of nodes
pub fn all_nodes(&self, node_type: NodeType) -> Vec<Node> {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let nodes = private.nodes.borrow();
let nodes_list: Vec<_> = nodes
.iter()
@ -619,14 +618,27 @@ impl GraphView {
///
/// Returns `None` if the node is not in the graphview.
pub fn node(&self, id: u32) -> Option<Node> {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
private.nodes.borrow().get(&id).cloned()
}
/// Get the node with the specified node name inside the graphview.
///
/// Returns `None` if the node is not in the graphview.
pub fn node_by_unique_name(&self, unique_name: &str) -> Option<Node> {
let private = imp::GraphView::from_obj(self);
for node in private.nodes.borrow().values() {
if node.unique_name() == unique_name {
return Some(node.clone());
}
}
None
}
/// Remove all the nodes from the graphview
///
pub fn remove_all_nodes(&self) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let nodes_list = self.all_nodes(NodeType::All);
for node in nodes_list {
self.remove_node(node.id());
@ -641,7 +653,7 @@ impl GraphView {
///
/// Returns Some(link id) or `None` if the node is not linked.
pub fn node_is_linked(&self, node_id: u32) -> Option<u32> {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
for (key, link) in private.links.borrow().iter() {
if link.node_from == node_id || link.node_to == node_id {
return Some(*key);
@ -689,7 +701,7 @@ impl GraphView {
/// Add the port with id from node with id.
///
pub fn add_port_to_node(&self, node: &mut Node, port: Port) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let port_id = port.id();
node.add_port(port);
@ -700,7 +712,7 @@ impl GraphView {
///
/// Return true if the port presence is not always.
pub fn can_remove_port(&self, node_id: u32, port_id: u32) -> bool {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let nodes = private.nodes.borrow();
if let Some(node) = nodes.get(&node_id) {
return node.can_remove_port(port_id);
@ -712,7 +724,7 @@ impl GraphView {
/// Remove the port with id from node with id.
///
pub fn remove_port(&self, node_id: u32, port_id: u32) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let nodes = private.nodes.borrow();
if let Some(node) = nodes.get(&node_id) {
if let Some(link_id) = self.port_is_linked(port_id) {
@ -726,7 +738,7 @@ impl GraphView {
///
/// Returns Some(link id) or `None` if the port is not linked.
pub fn port_is_linked(&self, port_id: u32) -> Option<u32> {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
for (key, link) in private.links.borrow().iter() {
if link.port_from == port_id || link.port_to == port_id {
return Some(*key);
@ -745,7 +757,6 @@ impl GraphView {
node_to_id: u32,
port_from_id: u32,
port_to_id: u32,
active: bool,
) -> Link {
self.create_link_with_id(
self.next_link_id(),
@ -753,14 +764,13 @@ impl GraphView {
node_to_id,
port_from_id,
port_to_id,
active,
)
}
/// Add a link to the graphView
///
pub fn add_link(&self, link: Link) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
if !self.link_exists(&link) {
private.links.borrow_mut().insert(link.id, link);
self.graph_updated();
@ -770,9 +780,9 @@ impl GraphView {
/// Set the link state with ink id and link state (boolean)
///
pub fn set_link_state(&self, link_id: u32, active: bool) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
if let Some(link) = private.links.borrow_mut().get_mut(&link_id) {
link.active = active;
link.set_active(active);
self.queue_draw();
} else {
warn!("Link state changed on unknown link (id={})", link_id);
@ -783,20 +793,45 @@ impl GraphView {
///
/// Returns a vector of links
pub fn all_links(&self, link_state: bool) -> Vec<Link> {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let links = private.links.borrow();
let links_list: Vec<_> = links
.iter()
.filter(|(_, link)| link.active == link_state)
.filter(|(_, link)| link.active() == link_state)
.map(|(_, node)| node.clone())
.collect();
links_list
}
/// Get the link with the specified link id inside the graphview.
///
/// Returns `None` if the link is not in the graphview.
pub fn link(&self, id: u32) -> Option<Link> {
let private = imp::GraphView::from_obj(self);
private.links.borrow().get(&id).cloned()
}
/// Set the link state with ink id and link state (boolean)
///
pub fn set_link_name(&self, link_id: u32, name: &str) {
let private = imp::GraphView::from_obj(self);
let mut updated = false;
if let Some(link) = private.links.borrow_mut().get_mut(&link_id) {
link.set_name(name);
self.queue_draw();
updated = true;
} else {
warn!("Link name changed on unknown link (id={})", link_id);
}
if updated {
self.graph_updated();
}
}
/// Retrieves the node/port id connected to the input port id
///
pub fn port_connected_to(&self, port_id: u32) -> Option<(u32, u32)> {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
for (_id, link) in private.links.borrow().iter() {
if port_id == link.port_from {
return Some((link.port_to, link.node_to));
@ -805,10 +840,22 @@ impl GraphView {
None
}
/// Retrieves the link connected to the port id
///
pub fn port_link(&self, port_id: u32) -> Option<Link> {
let private = imp::GraphView::from_obj(self);
for (_id, link) in private.links.borrow().iter() {
if port_id == link.port_from {
return Some(link.clone());
}
}
None
}
/// Delete the selected element (link, node, port)
///
pub fn delete_selected(&self) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let mut link_id = None;
let mut node_id = None;
for link in private.links.borrow_mut().values() {
@ -834,15 +881,18 @@ impl GraphView {
/// Render the graph with XML format in a buffer
///
pub fn render_xml(&self) -> anyhow::Result<Vec<u8>> {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let mut buffer = Vec::new();
let mut writer = EmitterConfig::new()
.perform_indent(true)
.create_writer(&mut buffer);
writer
.write(XMLWEvent::start_element("Graph").attr("id", &private.id.get().to_string()))?;
writer.write(
XMLWEvent::start_element("Graph")
.attr("id", &private.id.get().to_string())
.attr("version", GRAPHVIEW_XML_VERSION),
)?;
//Get the nodes
let nodes = self.all_nodes(NodeType::All);
@ -853,7 +903,8 @@ impl GraphView {
.attr("id", &node.id().to_string())
.attr("type", &node.node_type().unwrap().to_string())
.attr("pos_x", &node.position().0.to_string())
.attr("pos_y", &node.position().1.to_string()),
.attr("pos_y", &node.position().1.to_string())
.attr("light", &node.light().to_string()),
)?;
for port in node.ports().values() {
writer.write(
@ -893,7 +944,8 @@ impl GraphView {
.attr("node_to", &link.node_to.to_string())
.attr("port_from", &link.port_from.to_string())
.attr("port_to", &link.port_to.to_string())
.attr("active", &link.active.to_string()),
.attr("name", &link.name())
.attr("active", &link.active().to_string()),
)?;
writer.write(XMLWEvent::end_element())?;
}
@ -931,6 +983,11 @@ impl GraphView {
if let Some(id) = attrs.get::<String>(&String::from("id")) {
self.set_id(id.parse::<u32>().expect("id should be an u32"));
}
if let Some(version) = attrs.get::<String>(&"version".to_string()) {
info!("Found file format version: {}", version);
} else {
warn!("No file format version found");
}
}
"Node" => {
let id = attrs
@ -949,6 +1006,10 @@ impl GraphView {
let pos_y: &String = attrs
.get::<String>(&String::from("pos_y"))
.unwrap_or(&default_value);
let default_value = String::from("false");
let light: &String = attrs
.get::<String>(&String::from("light"))
.unwrap_or(&default_value);
let node = self.create_node_with_id(
id.parse::<u32>().unwrap(),
name,
@ -958,6 +1019,7 @@ impl GraphView {
pos_x.parse::<f32>().unwrap(),
pos_y.parse::<f32>().unwrap(),
);
node.set_light(light.parse::<bool>().unwrap());
current_node = Some(node);
}
"Property" => {
@ -1014,14 +1076,21 @@ impl GraphView {
let active: &String = attrs
.get::<String>(&String::from("active"))
.expect("Unable to find link state");
current_link = Some(self.create_link_with_id(
let default_value = String::from("");
let name: &String = attrs
.get::<String>(&String::from("name"))
.unwrap_or(&default_value);
let link = self.create_link_with_id(
id.parse::<u32>().unwrap(),
node_from.parse::<u32>().unwrap(),
node_to.parse::<u32>().unwrap(),
port_from.parse::<u32>().unwrap(),
port_to.parse::<u32>().unwrap(),
active.parse::<bool>().unwrap(),
));
);
link.set_active(active.parse::<bool>().unwrap());
link.set_name(name.parse::<String>().unwrap().as_str());
current_link = Some(link);
}
_ => warn!("name unknown: {}", name),
}
@ -1105,21 +1174,12 @@ impl GraphView {
node_to_id: u32,
port_from_id: u32,
port_to_id: u32,
active: bool,
) -> Link {
Link::new(
link_id,
node_from_id,
node_to_id,
port_from_id,
port_to_id,
active,
false,
)
Link::new(link_id, node_from_id, node_to_id, port_from_id, port_to_id)
}
fn remove_link(&self, id: u32) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
let mut links = private.links.borrow_mut();
links.remove(&id);
@ -1127,14 +1187,14 @@ impl GraphView {
}
fn update_current_link_id(&self, link_id: u32) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
if link_id > private.current_link_id.get() {
private.current_link_id.set(link_id);
}
}
fn link_exists(&self, new_link: &Link) -> bool {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
for link in private.links.borrow().values() {
if (new_link.port_from == link.port_from && new_link.port_to == link.port_to)
@ -1161,8 +1221,7 @@ impl GraphView {
let transform = gsk::Transform::new()
// Nodes should not be able to be dragged out of the view, so we use `max(coordinate, 0.0)` to prevent that.
.translate(&graphene::Point::new(f32::max(x, 0.0), f32::max(y, 0.0)))
.unwrap();
.translate(&graphene::Point::new(f32::max(x, 0.0), f32::max(y, 0.0)));
layout_manager
.layout_child(widget)
@ -1176,7 +1235,7 @@ impl GraphView {
}
fn unselect_nodes(&self) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
for node in private.nodes.borrow_mut().values() {
node.set_selected(false);
node.unselect_all_ports();
@ -1184,14 +1243,14 @@ impl GraphView {
}
fn update_current_node_id(&self, node_id: u32) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
if node_id > private.current_node_id.get() {
private.current_node_id.set(node_id);
}
}
fn unselect_links(&self) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
for link in private.links.borrow_mut().values() {
link.set_selected(false);
}
@ -1204,7 +1263,7 @@ impl GraphView {
}
fn point_on_link(&self, point: &graphene::Point) -> Option<Link> {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
self.unselect_all();
for link in private.links.borrow_mut().values() {
if let Some((from_x, from_y, to_x, to_y)) = private.link_coordinates(link) {
@ -1226,13 +1285,13 @@ impl GraphView {
}
fn graph_updated(&self) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
self.queue_draw();
self.emit_by_name::<()>("graph-updated", &[&private.id.get()]);
}
fn next_node_id(&self) -> u32 {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
private
.current_node_id
.set(private.current_node_id.get() + 1);
@ -1240,7 +1299,7 @@ impl GraphView {
}
fn next_port_id(&self) -> u32 {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
private
.current_port_id
.set(private.current_port_id.get() + 1);
@ -1248,7 +1307,7 @@ impl GraphView {
}
fn next_link_id(&self) -> u32 {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
private
.current_link_id
.set(private.current_link_id.get() + 1);
@ -1259,17 +1318,17 @@ impl GraphView {
if port.is_some() {
self.unselect_all();
}
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
*private.port_selected.borrow_mut() = port.cloned();
}
fn selected_port(&self) -> RefMut<Option<Port>> {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
private.port_selected.borrow_mut()
}
fn set_mouse_position(&self, x: f64, y: f64) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
private.mouse_position.set((x, y));
}
@ -1298,7 +1357,7 @@ impl GraphView {
}
fn update_current_port_id(&self, port_id: u32) {
let private = imp::GraphView::from_instance(self);
let private = imp::GraphView::from_obj(self);
if port_id > private.current_port_id.get() {
private.current_port_id.set(port_id);
}

View file

@ -3,23 +3,12 @@
// Copyright 2021 Tom A. Wagner <tom.a.wagner@protonmail.com>
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GraphManager
//
// SPDX-License-Identifier: GPL-3.0-only
use super::SelectionExt;
use std::cell::Cell;
use std::cell::{Cell, RefCell};
#[derive(Debug, Clone)]
pub struct Link {
@ -28,44 +17,49 @@ pub struct Link {
pub node_to: u32,
pub port_from: u32,
pub port_to: u32,
pub active: bool,
pub active: Cell<bool>,
pub selected: Cell<bool>,
pub thickness: u32,
pub name: RefCell<String>,
}
impl Link {
pub fn name(&self) -> String {
self.name.borrow().clone()
}
pub fn set_name(&self, name: &str) {
self.name.replace(name.to_string());
}
pub fn id(&self) -> u32 {
self.id
}
pub fn active(&self) -> bool {
self.active.get()
}
pub fn set_active(&self, active: bool) {
self.active.set(active)
}
}
pub trait LinkExt {
/// Create a new link
///
fn new(
id: u32,
node_from: u32,
node_to: u32,
port_from: u32,
port_to: u32,
active: bool,
selected: bool,
) -> Self;
fn new(id: u32, node_from: u32, node_to: u32, port_from: u32, port_to: u32) -> Self;
}
impl LinkExt for Link {
fn new(
id: u32,
node_from: u32,
node_to: u32,
port_from: u32,
port_to: u32,
active: bool,
selected: bool,
) -> Self {
fn new(id: u32, node_from: u32, node_to: u32, port_from: u32, port_to: u32) -> Self {
Self {
id,
node_from,
node_to,
port_from,
port_to,
active,
selected: Cell::new(selected),
active: Cell::new(true),
selected: Cell::new(false),
thickness: 4,
name: RefCell::new("".to_string()),
}
}
}

View file

@ -6,7 +6,6 @@ mod property;
mod selection;
pub use graphview::GraphView;
pub use link::Link;
pub use node::Node;
pub use node::NodeType;
pub use port::Port;
@ -104,11 +103,15 @@ mod test {
// Ports have been created by create_node_with_port
//Create link between node1 and node 2
let link = graphview.create_link(1, 2, 1, 2, true);
let link = graphview.create_link(1, 2, 1, 2);
assert_eq!(&link.name(), "");
assert!(&link.active());
link.set_name("link1");
assert_eq!(&link.name(), "link1");
graphview.add_link(link);
//Create link between node2 and node 3
let link = graphview.create_link(2, 3, 3, 4, true);
let link = graphview.create_link(2, 3, 3, 4);
graphview.add_link(link);
// Save the graphview in XML into a buffer

View file

@ -3,20 +3,10 @@
// Copyright 2021 Tom A. Wagner <tom.a.wagner@protonmail.com>
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GraphManager
//
// SPDX-License-Identifier: GPL-3.0-only
use gtk::glib;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
@ -28,8 +18,9 @@ use std::cell::{Cell, Ref, RefCell};
use std::collections::HashMap;
use std::fmt;
use std::fmt::Write as _;
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum NodeType {
Source,
Transform,
@ -40,7 +31,7 @@ pub enum NodeType {
impl fmt::Display for NodeType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}
@ -59,6 +50,7 @@ impl NodeType {
mod imp {
use super::*;
use once_cell::unsync::OnceCell;
#[derive(Default)]
pub struct Node {
pub(super) layoutgrid: gtk::Grid,
pub(super) name: gtk::Label,
@ -71,7 +63,9 @@ mod imp {
// Properties are different from GObject properties
pub(super) properties: RefCell<HashMap<String, String>>,
pub(super) selected: Cell<bool>,
pub(super) light: Cell<bool>,
pub(super) position: Cell<(f32, f32)>,
pub(super) unique_name: RefCell<String>,
}
#[glib::object_subclass]
@ -110,25 +104,19 @@ mod imp {
layoutgrid,
name,
description,
id: OnceCell::new(),
node_type: OnceCell::new(),
ports: RefCell::new(HashMap::new()),
num_ports_in: Cell::new(0),
num_ports_out: Cell::new(0),
properties: RefCell::new(HashMap::new()),
selected: Cell::new(false),
position: Cell::new((0.0, 0.0)),
..Default::default()
}
}
}
impl ObjectImpl for Node {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
self.layoutgrid.set_parent(obj);
fn constructed(&self) {
let obj = self.obj();
self.parent_constructed();
self.layoutgrid.set_parent(&*obj);
}
fn dispose(&self, _obj: &Self::Type) {
fn dispose(&self) {
self.layoutgrid.unparent();
}
}
@ -145,10 +133,13 @@ impl Node {
/// Create a new node
///
pub fn new(id: u32, name: &str, node_type: NodeType) -> Self {
let res: Self = glib::Object::new(&[]).expect("Failed to create Node");
let private = imp::Node::from_instance(&res);
let res = glib::Object::new::<Self>();
let private = imp::Node::from_obj(&res);
private.id.set(id).expect("Node id is already set");
res.set_name(name);
let mut unique_name = private.name.text().to_string();
unique_name.push_str(&id.to_string());
private.unique_name.replace(unique_name);
res.add_css_class("node");
private
.node_type
@ -160,7 +151,7 @@ impl Node {
/// Add a new port to the node
///
pub fn add_port(&mut self, port: Port) {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
match port.direction() {
PortDirection::Input => {
private
@ -182,7 +173,7 @@ impl Node {
/// Retrieves all ports as an hashmap
///
pub fn ports(&self) -> Ref<HashMap<u32, Port>> {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
private.ports.borrow()
}
@ -201,14 +192,27 @@ impl Node {
/// Retrieves the port with id
///
pub fn port(&self, id: u32) -> Option<super::port::Port> {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
private.ports.borrow().get(&id).cloned()
}
/// Get the port with the specified port name inside the node.
///
/// Returns `None` if the node is not in the graphview.
pub fn port_by_name(&self, name: &str) -> Option<Port> {
let private = imp::Node::from_obj(self);
for port in private.ports.borrow().values() {
if port.name() == name {
return Some(port.clone());
}
}
None
}
/// Check if we can remove a port dependending on PortPrensence attribute
///
pub fn can_remove_port(&self, id: u32) -> bool {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
if let Some(port) = private.ports.borrow().get(&id) {
if port.presence() != PortPresence::Always {
return true;
@ -220,7 +224,7 @@ impl Node {
/// Removes a port id from the given node
///
pub fn remove_port(&self, id: u32) {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
if let Some(port) = private.ports.borrow_mut().remove(&id) {
match port.direction() {
PortDirection::Input => private.num_ports_in.set(private.num_ports_in.get() - 1),
@ -234,37 +238,42 @@ impl Node {
/// Retrieves the node id
///
pub fn id(&self) -> u32 {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
private.id.get().copied().expect("Node id is not set")
}
/// Retrieves the node name
///
pub fn name(&self) -> String {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
private.name.text().to_string()
}
/// Retrieves the unique name composed with the node name and its id
///
pub fn unique_name(&self) -> String {
let private = imp::Node::from_instance(self);
let mut unique_name = private.name.text().to_string();
unique_name.push_str(&self.id().to_string());
unique_name
let private = imp::Node::from_obj(self);
private.unique_name.borrow().clone()
}
/// Update the unique name
///
pub fn set_unique_name(&self, unique_name: &str) {
let private = imp::Node::from_obj(self);
private.unique_name.replace(unique_name.to_string());
}
/// Retrieves the NodeType
///
pub fn node_type(&self) -> Option<&NodeType> {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
private.node_type.get()
}
/// Unselect all the ports of the given node.
///
pub fn unselect_all_ports(&self) {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
for port in private.ports.borrow_mut().values() {
port.set_selected(false);
}
@ -273,7 +282,7 @@ impl Node {
/// Set coordinates for the drawn node.
///
pub fn set_position(&self, x: f32, y: f32) {
imp::Node::from_instance(self).position.set((x, y));
imp::Node::from_obj(self).position.set((x, y));
}
/// Get coordinates for the drawn node.
@ -281,28 +290,43 @@ impl Node {
/// # Returns
/// `(x, y)`
pub fn position(&self) -> (f32, f32) {
imp::Node::from_instance(self).position.get()
imp::Node::from_obj(self).position.get()
}
pub fn set_light(&self, light: bool) {
let self_ = imp::Node::from_obj(self);
self_.light.set(light);
if light {
self.add_css_class("node-light");
} else {
self.remove_css_class("node-light");
}
}
pub fn light(&self) -> bool {
let self_ = imp::Node::from_obj(self);
self_.light.get()
}
//Private
fn set_name(&self, name: &str) {
let self_ = imp::Node::from_instance(self);
let self_ = imp::Node::from_obj(self);
self_.name.set_text(name);
}
fn set_description(&self, description: &str) {
let self_ = imp::Node::from_instance(self);
let self_ = imp::Node::from_obj(self);
self_.description.set_text(description);
trace!("Node description is {}", description);
}
fn update_description(&self) {
let self_ = imp::Node::from_instance(self);
let self_ = imp::Node::from_obj(self);
let mut description = String::from("");
for (name, value) in self_.properties.borrow().iter() {
if !self.hidden_property(name) {
description.push_str(&format!("{}:{}", name, value));
let _ = write!(description, "{name}:{value}");
description.push('\n');
}
}
@ -316,7 +340,7 @@ impl SelectionExt for Node {
}
fn set_selected(&self, selected: bool) {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
private.selected.set(selected);
if selected {
self.add_css_class("node-selected");
@ -326,7 +350,7 @@ impl SelectionExt for Node {
}
fn selected(&self) -> bool {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
private.selected.get()
}
}
@ -335,7 +359,7 @@ impl PropertyExt for Node {
/// Add a node property with a name and a value.
///
fn add_property(&self, name: &str, value: &str) {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
trace!("property name={} updated with value={}", name, value);
private
.properties
@ -347,7 +371,7 @@ impl PropertyExt for Node {
/// Remove a port property with a name.
///
fn remove_property(&self, name: &str) {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
trace!("property name={} removed", name);
private.properties.borrow_mut().remove(name);
self.update_description();
@ -356,7 +380,7 @@ impl PropertyExt for Node {
/// Retrieves node properties.
///
fn properties(&self) -> Ref<HashMap<String, String>> {
let private = imp::Node::from_instance(self);
let private = imp::Node::from_obj(self);
private.properties.borrow()
}
}

View file

@ -3,20 +3,10 @@
// Copyright 2021 Tom A. Wagner <tom.a.wagner@protonmail.com>
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GraphManager
//
// SPDX-License-Identifier: GPL-3.0-only
use gtk::{
glib::{self},
prelude::*,
@ -30,7 +20,7 @@ use std::fmt;
use super::{PropertyExt, SelectionExt};
#[derive(Debug, Clone, PartialOrd, PartialEq, Copy)]
#[derive(Debug, Clone, PartialOrd, PartialEq, Eq, Copy)]
pub enum PortDirection {
Input,
Output,
@ -40,7 +30,7 @@ pub enum PortDirection {
impl fmt::Display for PortDirection {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}
@ -56,9 +46,9 @@ impl PortDirection {
}
/// Port's presence
#[derive(Debug, Clone, PartialEq, PartialOrd, Copy)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Copy)]
pub enum PortPresence {
/// Can not be removed from his parent independantly
/// Can not be removed from his parent independently
Always,
/// Can be removed from a node
Sometimes,
@ -67,7 +57,7 @@ pub enum PortPresence {
impl fmt::Display for PortPresence {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}
@ -86,7 +76,7 @@ mod imp {
use once_cell::unsync::OnceCell;
/// Graphical representation of a port.
#[derive(Default, Clone)]
#[derive(Default)]
pub struct Port {
pub(super) label: gtk::Label,
pub(super) id: OnceCell<u32>,
@ -123,11 +113,12 @@ mod imp {
}
impl ObjectImpl for Port {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
self.label.set_parent(obj);
fn constructed(&self) {
let obj = self.obj();
self.parent_constructed();
self.label.set_parent(&*obj);
}
fn dispose(&self, _obj: &Self::Type) {
fn dispose(&self) {
self.label.unparent()
}
}
@ -144,9 +135,9 @@ impl Port {
///
pub fn new(id: u32, name: &str, direction: PortDirection, presence: PortPresence) -> Self {
// Create the widget and initialize needed fields
let port: Self = glib::Object::new(&[]).expect("Failed to create Port");
let port: Self = glib::Object::new::<Self>();
port.add_css_class("port");
let private = imp::Port::from_instance(&port);
let private = imp::Port::from_obj(&port);
private.id.set(id).expect("Port id already set");
private.selected.set(false);
private
@ -175,35 +166,35 @@ impl Port {
/// Retrieves the port id
///
pub fn id(&self) -> u32 {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
private.id.get().copied().expect("Port id is not set")
}
/// Retrieves the port name
///
pub fn name(&self) -> String {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
private.label.text().to_string()
}
/// Set the port name
///
pub fn set_name(&self, name: &str) {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
private.label.set_text(name);
}
/// Retrieves the port direction
///
pub fn direction(&self) -> PortDirection {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
*private.direction.get().expect("Port direction is not set")
}
/// Retrieves the port presence
///
pub fn presence(&self) -> PortPresence {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
*private.presence.get().expect("Port presence is not set")
}
}
@ -214,7 +205,7 @@ impl SelectionExt for Port {
}
fn set_selected(&self, selected: bool) {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
private.selected.set(selected);
if selected {
self.add_css_class("port-selected");
@ -224,7 +215,7 @@ impl SelectionExt for Port {
}
fn selected(&self) -> bool {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
private.selected.get()
}
}
@ -233,7 +224,7 @@ impl PropertyExt for Port {
/// Add a port property with a name and a value.
///
fn add_property(&self, name: &str, value: &str) {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
trace!("property name={} updated with value={}", name, value);
private
.properties
@ -244,7 +235,7 @@ impl PropertyExt for Port {
/// Remove a port property with a name.
///
fn remove_property(&self, name: &str) {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
trace!("property name={} removed", name);
private.properties.borrow_mut().remove(name);
}
@ -252,7 +243,7 @@ impl PropertyExt for Port {
/// Retrieves node properties.
///
fn properties(&self) -> Ref<HashMap<String, String>> {
let private = imp::Port::from_instance(self);
let private = imp::Port::from_obj(self);
private.properties.borrow()
}
}

View file

@ -2,20 +2,10 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GraphManager
//
// SPDX-License-Identifier: GPL-3.0-only
use log::info;
use std::cell::Ref;
use std::collections::HashMap;

View file

@ -2,18 +2,7 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GraphManager
//
// SPDX-License-Identifier: GPL-3.0-only

View file

@ -1,4 +1,11 @@
use gtk::glib::Sender;
// logger.rs
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use log::{debug, error, info, trace, warn};
use simplelog::*;
use std::fmt;
@ -6,18 +13,48 @@ use std::io;
use std::fs::File;
use chrono::Local;
use std::sync::Mutex;
lazy_static::lazy_static! {
static ref MSG_LOGGER: Mutex<Option<MessageLogger>> = Mutex::new(None);
}
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum LogLevel {
Off,
Error,
Warning,
Info,
Debug,
Trace,
}
#[derive(Debug, Clone, PartialEq)]
pub enum LogType {
App,
Gst,
Message,
}
impl LogLevel {
pub fn from_u32(value: u32) -> LogLevel {
match value {
0 => LogLevel::Off,
1 => LogLevel::Error,
2 => LogLevel::Warning,
3 => LogLevel::Info,
4 => LogLevel::Debug,
5 => LogLevel::Trace,
_ => panic!("Unknown value: {}", value),
}
}
}
impl fmt::Display for LogLevel {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}
@ -25,7 +62,7 @@ impl fmt::Display for LogLevel {
macro_rules! GPS_ERROR (
() => ($crate::print!("\n"));
($($arg:tt)*) => ({
logger::print_log(logger::LogLevel::Error, format_args!($($arg)*).to_string());
logger::print_log(logger::LogLevel::Error, format!("{}\t{}",glib::function_name!(),format_args!($($arg)*).to_string()));
})
);
@ -33,7 +70,7 @@ macro_rules! GPS_ERROR (
macro_rules! GPS_WARN (
() => ($crate::print!("\n"));
($($arg:tt)*) => ({
logger::print_log(logger::LogLevel::Warning, format_args!($($arg)*).to_string());
logger::print_log(logger::LogLevel::Warning, format!("{}\t{}",glib::function_name!(),format_args!($($arg)*).to_string()));
})
);
@ -41,7 +78,7 @@ macro_rules! GPS_WARN (
macro_rules! GPS_INFO (
() => ($crate::print!("\n"));
($($arg:tt)*) => ({
logger::print_log(logger::LogLevel::Info, format_args!($($arg)*).to_string());
logger::print_log(logger::LogLevel::Info, format!("{}\t{}",glib::function_name!(),format_args!($($arg)*).to_string()));
})
);
@ -49,7 +86,23 @@ macro_rules! GPS_INFO (
macro_rules! GPS_DEBUG (
() => ($crate::print!("\n"));
($($arg:tt)*) => ({
logger::print_log(logger::LogLevel::Debug, format_args!($($arg)*).to_string());
logger::print_log(logger::LogLevel::Debug, format!("{}\t{}",glib::function_name!(),format_args!($($arg)*).to_string()));
})
);
#[macro_export]
macro_rules! GPS_MSG_LOG (
() => ($crate::print!("\n"));
($($arg:tt)*) => ({
logger::print_msg_logger(logger::LogType::Message, format_args!($($arg)*).to_string());
})
);
#[macro_export]
macro_rules! GPS_GST_LOG (
() => ($crate::print!("\n"));
($($arg:tt)*) => ({
logger::print_msg_logger(logger::LogType::Gst, format_args!($($arg)*).to_string());
})
);
@ -62,7 +115,7 @@ macro_rules! GPS_TRACE (
);
struct WriteAdapter {
sender: Sender<String>,
sender: async_channel::Sender<(LogType, String)>,
buffer: String,
}
@ -73,8 +126,8 @@ impl io::Write for WriteAdapter {
.push_str(&String::from_utf8(buf.to_vec()).unwrap());
if self.buffer.ends_with('\n') {
self.buffer.pop();
self.sender.send(self.buffer.clone()).unwrap();
self.buffer = String::from("");
let _ = self.sender.try_send((LogType::App, self.buffer.clone()));
self.buffer.clear();
}
Ok(buf.len())
@ -87,6 +140,7 @@ impl io::Write for WriteAdapter {
fn translate_to_simple_logger(log_level: LogLevel) -> LevelFilter {
match log_level {
LogLevel::Off => LevelFilter::Off,
LogLevel::Error => LevelFilter::Error,
LogLevel::Warning => LevelFilter::Warn,
LogLevel::Info => LevelFilter::Info,
@ -95,12 +149,12 @@ fn translate_to_simple_logger(log_level: LogLevel) -> LevelFilter {
}
}
pub fn init_logger(sender: Sender<String>, log_file: &str) {
pub fn init_logger(sender: async_channel::Sender<(LogType, String)>, log_file: &str) {
simplelog::CombinedLogger::init(vec![
WriteLogger::new(
translate_to_simple_logger(LogLevel::Trace),
Config::default(),
File::create(log_file).unwrap(),
File::create(log_file).unwrap_or_else(|_| panic!("Unable to create log {}", log_file)),
),
WriteLogger::new(
translate_to_simple_logger(LogLevel::Debug),
@ -120,6 +174,10 @@ pub fn init_logger(sender: Sender<String>, log_file: &str) {
.unwrap();
}
pub fn set_log_level(level: LogLevel) {
log::set_max_level(translate_to_simple_logger(level));
}
pub fn print_log(log_level: LogLevel, msg: String) {
match log_level {
LogLevel::Error => {
@ -137,5 +195,39 @@ pub fn print_log(log_level: LogLevel, msg: String) {
LogLevel::Trace => {
trace!("{}", msg);
}
_ => {}
};
}
#[derive(Debug, Clone)]
pub struct MessageLogger {
sender: async_channel::Sender<(LogType, String)>,
}
impl MessageLogger {
pub fn new(sender: async_channel::Sender<(LogType, String)>) -> Self {
Self { sender }
}
pub fn print_log(&self, log_type: LogType, msg: String) {
let to_send = format!("{}\t{}", Local::now().format("%H:%M:%S"), msg);
self.sender
.try_send((log_type, to_send))
.expect("Unable to send the log");
}
}
pub fn init_msg_logger(sender: async_channel::Sender<(LogType, String)>) {
let mut msg_logger = MSG_LOGGER.lock().unwrap();
if msg_logger.is_none() {
// Initialize the variable
*msg_logger = Some(MessageLogger::new(sender));
}
}
pub fn print_msg_logger(log_type: LogType, msg: String) {
let msg_logger = MSG_LOGGER.lock().unwrap();
if let Some(logger) = msg_logger.as_ref() {
logger.print_log(log_type, msg);
}
}

View file

@ -2,25 +2,16 @@
//
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
#[macro_use]
mod macros;
mod app;
mod common;
mod config;
mod graphbook;
mod graphmanager;
mod ui;
#[macro_use]
@ -31,14 +22,29 @@ use gtk::prelude::*;
use crate::app::GPSApp;
use crate::common::init;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
struct Command {
#[structopt(about = "Sets the pipeline description", default_value = "")]
pipeline: String,
}
fn main() {
// gio::resources_register_include!("compiled.gresource").unwrap();
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| {
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();
}

View file

@ -1,6 +1,5 @@
conf = configuration_data()
conf.set_quoted('APP_ID', application_id)
conf.set_quoted('VERSION', version + version_suffix)
configure_file(
input: 'config.rs.in',
@ -9,12 +8,7 @@ configure_file(
)
# Copy the config.rs output to the source directory.
run_command(
'cp',
join_paths(meson.build_root(), 'src', 'config.rs'),
join_paths(meson.source_root(), 'src', 'config.rs'),
check: true
)
run_command(python3, '-c', 'import shutil; shutil.copyfile("@0@", "@1@")'.format(join_paths(meson.project_build_root(), 'src', 'config.rs'), join_paths(meson.project_source_root(), 'src', 'config.rs')))
rust_sources = files(
'gps/player.rs',
@ -38,27 +32,32 @@ rust_sources = files(
'logger.rs',
'macros.rs',
'main.rs',
'settings.rs',
)
sources = [cargo_sources, rust_sources]
cargo_script = find_program(join_paths(meson.source_root(), 'build-aux/cargo.sh'))
cargo_script = find_program(join_paths(meson.project_source_root(), 'build-aux/cargo.py'))
app_name = meson.project_name()
if host_system == 'windows'
app_name += '.exe'
endif
cargo_release = custom_target(
'cargo-build',
build_by_default: true,
input: sources,
output: meson.project_name(),
output: app_name,
console: true,
install: true,
install_dir: get_option('bindir'),
command: [
cargo_script,
meson.build_root(),
meson.source_root(),
meson.project_build_root(),
meson.project_source_root(),
'@OUTPUT@',
get_option('buildtype'),
meson.project_name(),
app_name,
]
)

View file

@ -1,3 +1,11 @@
// settings.rs
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use gtk::glib;
use std::collections::HashMap;
use std::fs::create_dir_all;
@ -9,10 +17,12 @@ use crate::config;
use crate::logger;
#[derive(Debug, Serialize, Deserialize, Default)]
#[serde(default)]
pub struct Settings {
pub app_maximized: bool,
pub app_width: i32,
pub app_height: i32,
pub recent_pipeline: String,
// values must be emitted before tables
pub favorites: Vec<String>,
@ -21,44 +31,66 @@ pub struct Settings {
}
impl Settings {
fn settings_file_exist() {
let s = Settings::get_settings_file_path();
fn create_path_if_not(s: &PathBuf) {
if !s.exists() {
if let Some(parent_dir) = s.parent() {
if !parent_dir.exists() {
if let Err(e) = create_dir_all(parent_dir) {
GPS_ERROR!(
"Error while trying to build settings snapshot_directory '{}': {}",
parent_dir.display(),
e
);
}
}
if let Err(e) = create_dir_all(s) {
GPS_ERROR!(
"Error while trying to build settings snapshot_directory '{}': {}",
s.display(),
e
);
}
}
}
fn get_settings_file_path() -> PathBuf {
fn default_app_folder() -> PathBuf {
let mut path = glib::user_config_dir();
path.push(config::APP_ID);
path
}
fn settings_file_path() -> PathBuf {
let mut path = Settings::default_app_folder();
Settings::create_path_if_not(&path);
path.push("settings.toml");
path
}
// Public methods
pub fn default_graph_file_path() -> PathBuf {
let mut path = glib::user_config_dir();
path.push(config::APP_ID);
pub fn graph_file_path() -> PathBuf {
let mut path = Settings::default_app_folder();
Settings::create_path_if_not(&path);
path.push("default_graph.toml");
path
}
pub fn default_log_file_path() -> PathBuf {
let mut path = PathBuf::new();
pub fn log_file_path() -> PathBuf {
let mut path = Settings::default_app_folder();
Settings::create_path_if_not(&path);
path.push("gstpipelinestudio.log");
path
}
pub fn gst_log_level() -> String {
let settings = Settings::load_settings();
let binding = "0".to_string();
let level = settings
.preferences
.get("gst_log_level")
.unwrap_or(&binding);
level.clone()
}
pub fn set_recent_pipeline_description(pipeline: &str) {
let mut settings = Settings::load_settings();
settings.recent_pipeline = pipeline.to_string();
Settings::save_settings(&settings);
}
pub fn recent_pipeline_description() -> String {
let settings = Settings::load_settings();
settings.recent_pipeline
}
pub fn add_favorite(favorite: &str) {
let mut settings = Settings::load_settings();
settings.favorites.sort();
@ -72,7 +104,7 @@ impl Settings {
Settings::save_settings(&settings);
}
pub fn get_favorites_list() -> Vec<String> {
pub fn favorites_list() -> Vec<String> {
let mut favorites = Vec::new();
let settings = Settings::load_settings();
for fav in settings.favorites {
@ -83,8 +115,7 @@ impl Settings {
// Save the provided settings to the settings path
pub fn save_settings(settings: &Settings) {
Settings::settings_file_exist();
let s = Settings::get_settings_file_path();
let s = Settings::settings_file_path();
if let Err(e) = serde_any::to_file(&s, settings) {
GPS_ERROR!("Error while trying to save file: {} {}", s.display(), e);
}
@ -92,7 +123,7 @@ impl Settings {
// Load the current settings
pub fn load_settings() -> Settings {
let s = Settings::get_settings_file_path();
let s = Settings::settings_file_path();
if s.exists() && s.is_file() {
match serde_any::from_file::<Settings, _>(&s) {
Ok(s) => s,

View file

@ -2,25 +2,15 @@
//
// Copyright 2021 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use crate::app::GPSApp;
use crate::config;
use gettextrs::gettext;
use gtk::builders::AboutDialogBuilder;
use crate::gps as GPS;
use gtk::prelude::*;
use gtk::AboutDialog;
use gtk::ApplicationWindow;
@ -29,15 +19,19 @@ pub fn display_about_dialog(app: &GPSApp) {
.builder
.object("mainwindow")
.expect("Couldn't get window");
let about_dialog = AboutDialogBuilder::new()
let about_dialog = AboutDialog::builder()
.modal(true)
.program_name("GstPipelineStudio")
.version(config::VERSION)
.comments(&gettext("Draw your own GStreamer pipeline"))
.comments(format!(
"{}\n\n{}",
&"Draw your own GStreamer pipeline",
GPS::Player::get_version()
))
.website("https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio")
.authors(vec!["Stéphane Cerveau".to_string()])
.artists(vec!["Stéphane Cerveau".to_string()])
.translator_credits(&gettext("translator-credits"))
.translator_credits("translator-credits")
.logo_icon_name(config::APP_ID)
.license_type(gtk::License::Gpl30)
.transient_for(&window)

View file

@ -2,20 +2,10 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use crate::app::GPSApp;
use gtk::glib;
@ -53,3 +43,54 @@ pub fn create_dialog<F: Fn(GPSApp, gtk::Dialog) + 'static>(
dialog
}
pub fn create_input_dialog<F: Fn(GPSApp, String) + 'static>(
dialog_name: &str,
input_name: &str,
default_value: &str,
app: &GPSApp,
f: F,
) {
let dialog = gtk::Dialog::with_buttons(
Some(dialog_name),
Some(&app.window),
gtk::DialogFlags::MODAL,
&[("Ok", gtk::ResponseType::Apply)],
);
dialog.set_default_size(600, 100);
dialog.set_modal(true);
let label = gtk::Label::builder()
.label(input_name)
.hexpand(true)
.valign(gtk::Align::Center)
.halign(gtk::Align::Start)
.margin_start(4)
.build();
let entry = gtk::Entry::builder()
.width_request(400)
.valign(gtk::Align::Center)
.build();
entry.set_text(default_value);
let content_area = dialog.content_area();
content_area.set_orientation(gtk::Orientation::Horizontal);
content_area.set_vexpand(true);
content_area.set_margin_start(10);
content_area.set_margin_end(10);
content_area.set_margin_top(10);
content_area.set_margin_bottom(10);
content_area.append(&label);
content_area.append(&entry);
let app_weak = app.downgrade();
dialog.connect_response(glib::clone!(@weak entry => move |dialog, response_type| {
let app = upgrade_weak!(app_weak);
if response_type == gtk::ResponseType::Apply {
f(app, entry.text().to_string());
}
dialog.close()
}));
dialog.show();
}

View file

@ -2,18 +2,7 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
@ -30,7 +19,7 @@ use gtk::{gio, glib};
pub fn reset_favorite_list(favorite_list: &TreeView) {
let model = ListStore::new(&[String::static_type()]);
favorite_list.set_model(Some(&model));
let favorites = Settings::get_favorites_list();
let favorites = Settings::favorites_list();
for favorite in favorites {
model.insert_with_values(None, &[(0, &favorite)]);
}
@ -41,7 +30,7 @@ pub fn setup_favorite_list(app: &GPSApp) {
.builder
.object("treeview-favorites")
.expect("Couldn't get treeview-favorites");
treeview::add_column_to_treeview(app, "treeview-favorites", "Name", 0);
treeview::add_column_to_treeview(app, "treeview-favorites", "Name", 0, false);
reset_favorite_list(&favorite_list);
let app_weak = app.downgrade();
favorite_list.connect_row_activated(move |tree_view, _tree_path, _tree_column| {
@ -95,11 +84,11 @@ pub fn setup_favorite_list(app: &GPSApp) {
}
}),
);
favorite_list.add_controller(&gesture);
favorite_list.add_controller(gesture);
}
pub fn add_to_favorite_list(app: &GPSApp, element_name: String) {
let mut favorites = Settings::get_favorites_list();
let mut favorites = Settings::favorites_list();
favorites.sort();
if !favorites.contains(&element_name) {
let favorite_list: TreeView = app
@ -130,7 +119,7 @@ pub fn setup_elements_list(app: &GPSApp) {
.builder
.object("treeview-elements")
.expect("Couldn't get treeview-elements");
treeview::add_column_to_treeview(app, "treeview-elements", "Name", 0);
treeview::add_column_to_treeview(app, "treeview-elements", "Name", 0, false);
reset_elements_list(&tree);
let app_weak = app.downgrade();
tree.connect_row_activated(move |tree_view, _tree_path, _tree_column| {

View file

@ -11,12 +11,21 @@
<item>
<attribute name="label" translatable="yes" comments="Primary menu entry that opens the graph">_Open</attribute>
<attribute name="action">app.open</attribute>
<attribute name="accel">&lt;primary&gt;n</attribute>
<attribute name="accel">&lt;primary&gt;o</attribute>
</item>
<item>
<attribute name="label" translatable="yes" comments="Primary menu entry that opens a pipeline">_Open pipeline</attribute>
<attribute name="action">app.open_pipeline</attribute>
<attribute name="accel">&lt;primary&gt;p</attribute>
</item>
<item>
<attribute name="label" translatable="yes" comments="Primary menu entry that saves the graph">_Save</attribute>
<attribute name="action">app.save</attribute>
<attribute name="accel">&lt;primary&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes" comments="Primary menu entry that saves the graph">_Save As</attribute>
<attribute name="action">app.save_as</attribute>
<attribute name="accel">&lt;primary&gt;n</attribute>
</item>
<item>
<attribute name="label" translatable="yes" comments="Primary menu entry that open the preferences">_Preferences</attribute>
@ -43,6 +52,10 @@
</menu>
<menu id="graph_menu">
<section>
<item>
<attribute name="label" translatable="yes" comments="graph menu entry clear graph">_Clear graph</attribute>
<attribute name="action">app.graph.clear</attribute>
</item>
<item>
<attribute name="label" translatable="yes" comments="graph menu entry check graph">_Check graph</attribute>
<attribute name="action">app.graph.check</attribute>
@ -60,6 +73,14 @@
<attribute name="action">app.favorite.remove</attribute>
</item>
</section>
</menu>
<menu id="logger_menu">
<section>
<item>
<attribute name="label" translatable="yes" comments="logger menu entry clear the logs">_Clear</attribute>
<attribute name="action">app.logger.clear</attribute>
</item>
</section>
</menu>
<menu id="node_menu">
<section>
@ -192,7 +213,7 @@
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="child">
<object class="GtkViewport" id="drawing_area">
<object class="GtkNotebook" id="graphbook">
<child>
<placeholder/>
</child>
@ -201,11 +222,56 @@
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="child">
<object class="GtkTreeView" id="treeview-logger"/>
</property>
</object>
<object class="GtkNotebook" id="notebook-debug">
<child>
<object class="GtkNotebookPage">
<property name="child">
<object class="GtkScrolledWindow">
<property name="child">
<object class="GtkTreeView" id="treeview-app-logger"/>
</property>
</object>
</property>
<property name="tab">
<object class="GtkLabel" id="label-app-logger">
<property name="label" translatable="1">App</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkNotebookPage">
<property name="child">
<object class="GtkScrolledWindow">
<property name="child">
<object class="GtkTreeView" id="treeview-gst-logger"/>
</property>
</object>
</property>
<property name="tab">
<object class="GtkLabel" id="label-gst-logger">
<property name="label" translatable="1">GST</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkNotebookPage">
<property name="child">
<object class="GtkScrolledWindow">
<property name="child">
<object class="GtkTreeView" id="treeview-msg-logger"/>
</property>
</object>
</property>
<property name="tab">
<object class="GtkLabel" id="label-messages-logger">
<property name="label" translatable="1">Messages</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>

View file

@ -2,23 +2,15 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use crate::app::GPSApp;
use crate::logger;
use crate::ui::treeview;
use gtk::prelude::*;
use gtk::{gio, glib};
use gtk::{ListStore, TreeView};
@ -27,31 +19,117 @@ fn reset_logger_list(logger_list: &TreeView) {
String::static_type(),
String::static_type(),
String::static_type(),
String::static_type(),
String::static_type(),
]);
logger_list.set_model(Some(&model));
}
pub fn setup_logger_list(app: &GPSApp) {
treeview::add_column_to_treeview(app, "treeview-logger", "TIME", 0);
treeview::add_column_to_treeview(app, "treeview-logger", "LEVEL", 1);
treeview::add_column_to_treeview(app, "treeview-logger", "LOG", 2);
pub fn setup_logger_list(app: &GPSApp, logger_name: &str, log_type: logger::LogType) {
match log_type {
logger::LogType::App => {
treeview::add_column_to_treeview(app, logger_name, "TIME", 0, false);
treeview::add_column_to_treeview(app, logger_name, "LEVEL", 1, false);
treeview::add_column_to_treeview(app, logger_name, "LOG", 2, true);
}
logger::LogType::Gst => {
treeview::add_column_to_treeview(app, logger_name, "TIME", 0, false);
treeview::add_column_to_treeview(app, logger_name, "LEVEL", 1, false);
treeview::add_column_to_treeview(app, logger_name, "CATEGORY", 2, false);
treeview::add_column_to_treeview(app, logger_name, "FILE", 3, false);
treeview::add_column_to_treeview(app, logger_name, "LOG", 4, true);
}
logger::LogType::Message => {
treeview::add_column_to_treeview(app, logger_name, "TIME", 0, false);
treeview::add_column_to_treeview(app, logger_name, "LEVEL", 1, false);
treeview::add_column_to_treeview(app, logger_name, "LOG", 2, true);
}
}
let logger_list: TreeView = app
.builder
.object("treeview-logger")
.expect("Couldn't get treeview-logger");
.object(logger_name)
.expect("Couldn't get treeview-app-logger");
reset_logger_list(&logger_list);
let gesture = gtk::GestureClick::new();
gesture.set_button(0);
let app_weak = app.downgrade();
gesture.connect_pressed(
glib::clone!(@weak logger_list => move |gesture, _n_press, x, y| {
let app = upgrade_weak!(app_weak);
if gesture.current_button() == gtk::gdk::BUTTON_SECONDARY {
let pop_menu = app.app_pop_menu_at_position(&logger_list, x, y);
let menu: gio::MenuModel = app
.builder
.object("logger_menu")
.expect("Couldn't get fav_menu model");
pop_menu.set_menu_model(Some(&menu));
app.connect_app_menu_action("logger.clear",
move |_,_| {
reset_logger_list(&logger_list);
}
);
pop_menu.show();
}
}),
);
logger_list.add_controller(gesture);
}
pub fn add_to_logger_list(app: &GPSApp, log_entry: &str) {
fn log_tree_id_from_log_type(log_type: logger::LogType) -> String {
match log_type {
logger::LogType::App => String::from("treeview-app-logger"),
logger::LogType::Gst => String::from("treeview-gst-logger"),
logger::LogType::Message => String::from("treeview-msg-logger"),
}
}
pub fn add_to_logger_list(app: &GPSApp, log_type: logger::LogType, log_entry: &str) {
let log_tree_name = log_tree_id_from_log_type(log_type.clone());
let logger_list: TreeView = app
.builder
.object("treeview-logger")
.expect("Couldn't get treeview-logger");
.object(log_tree_name.as_str())
.expect("Couldn't get treeview");
if let Some(model) = logger_list.model() {
let list_store = model
.dynamic_cast::<ListStore>()
.expect("Could not cast to ListStore");
let log: Vec<&str> = log_entry.splitn(3, ' ').collect();
list_store.insert_with_values(None, &[(0, &log[0]), (1, &log[1]), (2, &log[2])]);
if log_type == logger::LogType::Gst {
let log: Vec<&str> = log_entry.splitn(5, '\t').collect();
list_store.insert_with_values(
Some(0),
&[
(0, &log[0]),
(1, &log[1]),
(2, &log[2]),
(3, &log[3]),
(4, &log[4]),
],
);
} else {
let log: Vec<&str> = log_entry.splitn(3, ' ').collect();
let mut indexed_vec: Vec<(u32, &dyn ToValue)> = Vec::new();
for (index, item) in log.iter().enumerate() {
indexed_vec.push((index as u32, item));
}
list_store.insert_with_values(Some(0), &indexed_vec);
}
// Scroll to the first element.
if let Some(model) = logger_list.model() {
if let Some(iter) = model.iter_first() {
let path = model.path(&iter);
logger_list.scroll_to_cell(
Some(&path),
None::<&gtk::TreeViewColumn>,
false,
0.0,
0.0,
);
}
}
}
}

View file

@ -2,18 +2,7 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
@ -64,7 +53,7 @@ pub fn display_message_dialog<F: Fn(Application) + 'static>(
#[allow(dead_code)]
pub fn display_error_dialog(fatal: bool, message: &str) {
display_message_dialog(
&format!("Error: {}", message),
&format!("Error: {message}"),
gtk::MessageType::Error,
move |app| {
if fatal {

View file

@ -1,21 +1,11 @@
// ui/mod.rs
// mod.rs
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
pub mod about;
pub mod dialog;
pub mod elements;

View file

@ -2,41 +2,37 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use crate::app::GPSApp;
use crate::logger;
use crate::settings;
use crate::ui as GPSUI;
use gtk::glib;
use gtk::prelude::*;
fn add_settings_widget(grid: &gtk::Grid, label_name: &str, widget: &gtk::Widget, row: i32) {
let label = gtk::Label::builder()
.label(label_name)
.hexpand(true)
.halign(gtk::Align::Start)
.margin_start(4)
.build();
grid.attach(&label, 0, row, 1, 1);
grid.attach(widget, 1, row, 1, 1);
}
pub fn display_settings(app: &GPSApp) {
let grid = gtk::Grid::new();
grid.set_column_spacing(4);
grid.set_row_spacing(4);
grid.set_margin_bottom(12);
let label = gtk::Label::builder()
.label("Use gtk4paintablesink element for video rendering:")
.hexpand(true)
.halign(gtk::Align::Start)
.margin_start(4)
.build();
let widget = gtk::CheckButton::new();
let settings = settings::Settings::load_settings();
let widget = gtk::CheckButton::new();
widget.set_active(
settings
.preferences
@ -51,12 +47,51 @@ pub fn display_settings(app: &GPSApp) {
settings::Settings::save_settings(&settings);
}));
grid.attach(&label, 0, 0, 1, 1);
grid.attach(&widget, 1, 0, 1, 1);
let widget = widget
.dynamic_cast::<gtk::Widget>()
.expect("Should be a widget");
add_settings_widget(
&grid,
"Use gtk4paintablesink element for video rendering:",
&widget,
0,
);
let widget = gtk::SpinButton::with_range(0.0, 5.0, 1.0);
widget.set_value(
settings
.preferences
.get("log_level")
.unwrap_or(&"0.0".to_string())
.parse::<f64>()
.expect("Should a f64 value"),
);
widget.connect_value_changed(glib::clone!(@weak widget => move |c| {
let mut settings = settings::Settings::load_settings();
settings.preferences.insert("log_level".to_string(), c.value().to_string());
logger::set_log_level(logger::LogLevel::from_u32(c.value() as u32));
settings::Settings::save_settings(&settings);
}));
let widget = widget
.dynamic_cast::<gtk::Widget>()
.expect("Should be a widget");
add_settings_widget(&grid, "Log level", &widget, 1);
let dialog = GPSUI::dialog::create_dialog("Preferences", app, &grid, move |_app, dialog| {
dialog.close();
});
let widget = gtk::Entry::new();
widget.set_text(settings::Settings::gst_log_level().as_str());
widget.connect_changed(glib::clone!(@weak widget => move |c| {
let mut settings = settings::Settings::load_settings();
settings.preferences.insert("gst_log_level".to_string(), c.text().to_string());
settings::Settings::save_settings(&settings);
}));
let widget = widget
.dynamic_cast::<gtk::Widget>()
.expect("Should be a widget");
add_settings_widget(&grid, "GST Log level", &widget, 2);
dialog.show();
}

View file

@ -2,22 +2,14 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use crate::app::GPSApp;
use crate::common;
use crate::gps as GPS;
use crate::graphbook;
use crate::logger;
use crate::ui as GPSUI;
use crate::{GPS_INFO, GPS_TRACE};
@ -28,22 +20,6 @@ use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
fn value_as_str(v: &glib::Value) -> Option<String> {
match v.type_() {
glib::Type::I8 => Some(str_some_value!(v, i8).to_string()),
glib::Type::U8 => Some(str_some_value!(v, u8).to_string()),
glib::Type::BOOL => Some(str_some_value!(v, bool).to_string()),
glib::Type::I32 => Some(str_some_value!(v, i32).to_string()),
glib::Type::U32 => Some(str_some_value!(v, u32).to_string()),
glib::Type::I64 => Some(str_some_value!(v, i64).to_string()),
glib::Type::U64 => Some(str_some_value!(v, u64).to_string()),
glib::Type::F32 => Some(str_some_value!(v, f32).to_string()),
glib::Type::F64 => Some(str_some_value!(v, f64).to_string()),
glib::Type::STRING => str_opt_value!(v, String),
_ => None,
}
}
pub fn property_to_widget<F: Fn(String, String) + 'static>(
app: &GPSApp,
node_id: u32,
@ -62,10 +38,12 @@ pub fn property_to_widget<F: Fn(String, String) + 'static>(
} else if (param.flags() & glib::ParamFlags::READABLE) == glib::ParamFlags::READABLE
|| (param.flags() & glib::ParamFlags::READWRITE) == glib::ParamFlags::READWRITE
{
if let Ok(value) = GPS::ElementInfo::element_property(element_name, param.name()) {
if let Ok(value) =
GPS::ElementInfo::element_property_by_feature_name(element_name, param.name())
{
check_button.set_active(value.parse::<bool>().unwrap_or(false));
}
} else if let Some(value) = value_as_str(param.default_value()) {
} else if let Some(value) = common::value_as_str(param.default_value()) {
check_button.set_active(value.parse::<bool>().unwrap_or(false));
}
check_button.connect_toggled(glib::clone!(@weak check_button => move |c| {
@ -79,6 +57,7 @@ pub fn property_to_widget<F: Fn(String, String) + 'static>(
glib::ParamSpecInt64::static_type(),
glib::ParamSpecUInt64::static_type(),
glib::ParamSpecString::static_type(),
glib::ParamSpecFloat::static_type(),
]
.contains(&t) =>
{
@ -91,10 +70,12 @@ pub fn property_to_widget<F: Fn(String, String) + 'static>(
} else if (param.flags() & glib::ParamFlags::READABLE) == glib::ParamFlags::READABLE
|| (param.flags() & glib::ParamFlags::READWRITE) == glib::ParamFlags::READWRITE
{
if let Ok(value) = GPS::ElementInfo::element_property(element_name, param.name()) {
if let Ok(value) =
GPS::ElementInfo::element_property_by_feature_name(element_name, param.name())
{
entry.set_text(&value);
}
} else if let Some(value) = value_as_str(param.default_value()) {
} else if let Some(value) = common::value_as_str(param.default_value()) {
entry.set_text(&value);
}
@ -133,7 +114,7 @@ pub fn property_to_widget<F: Fn(String, String) + 'static>(
let param = param
.clone()
.downcast::<glib::ParamSpecFlags>()
.expect("Should be a ParamSpecEnum");
.expect("Should be a ParamSpecFlags");
let flags = param.flags_class();
for value in flags.values() {
combo.append_text(&format!(
@ -150,7 +131,9 @@ pub fn property_to_widget<F: Fn(String, String) + 'static>(
} else if (param.flags() & glib::ParamFlags::READABLE) == glib::ParamFlags::READABLE
|| (param.flags() & glib::ParamFlags::READWRITE) == glib::ParamFlags::READWRITE
{
if let Ok(value) = GPS::ElementInfo::element_property(element_name, param.name()) {
if let Ok(value) =
GPS::ElementInfo::element_property_by_feature_name(element_name, param.name())
{
combo.set_active(Some(value.parse::<u32>().unwrap_or(0) + 1));
}
}
@ -181,7 +164,7 @@ pub fn property_to_widget<F: Fn(String, String) + 'static>(
pub fn display_plugin_properties(app: &GPSApp, element_name: &str, node_id: u32) {
let update_properties: Rc<RefCell<HashMap<String, String>>> =
Rc::new(RefCell::new(HashMap::new()));
let properties = GPS::ElementInfo::element_properties(element_name).unwrap();
let properties = GPS::ElementInfo::element_properties_by_feature_name(element_name).unwrap();
let grid = gtk::Grid::new();
grid.set_column_spacing(4);
@ -205,10 +188,12 @@ pub fn display_plugin_properties(app: &GPSApp, element_name: &str, node_id: u32)
}),
);
if let Some(widget) = widget {
let label = gtk::Label::new(Some(name));
label.set_hexpand(true);
label.set_halign(gtk::Align::Start);
label.set_margin_start(4);
let label = gtk::Label::builder()
.label(name)
.hexpand(true)
.halign(gtk::Align::Start)
.margin_start(4)
.build();
grid.attach(&label, 0, i, 1, 1);
grid.attach(&widget, 1, i, 1, 1);
i += 1;
@ -216,7 +201,7 @@ pub fn display_plugin_properties(app: &GPSApp, element_name: &str, node_id: u32)
}
let dialog = GPSUI::dialog::create_dialog(
&format!("{} properties", element_name),
&format!("{element_name} properties"),
app,
&grid,
glib::clone!(@strong update_properties => move |app, dialog| {
@ -246,10 +231,12 @@ pub fn display_pad_properties(
let mut i = 0;
let properties = app.pad_properties(node_id, port_id);
for (name, value) in properties {
let property_name = gtk::Label::new(Some(&name));
property_name.set_hexpand(true);
property_name.set_halign(gtk::Align::Start);
property_name.set_margin_start(4);
let property_name = gtk::Label::builder()
.label(&name)
.hexpand(true)
.halign(gtk::Align::Start)
.margin_start(4)
.build();
let property_value = gtk::Entry::new();
property_value.set_width_request(150);
property_value.set_text(&value);
@ -264,10 +251,12 @@ pub fn display_pad_properties(
}
// Add a new property allowing to set pads property.
let label = gtk::Label::new(Some("Add a new Property"));
label.set_hexpand(true);
label.set_halign(gtk::Align::Start);
label.set_margin_start(4);
let label = gtk::Label::builder()
.label("Add a new Property")
.hexpand(true)
.halign(gtk::Align::Start)
.margin_start(4)
.build();
let property_name = gtk::Entry::new();
property_name.set_width_request(150);
@ -292,7 +281,7 @@ pub fn display_pad_properties(
// Add all specific properties from the given element
let dialog = GPSUI::dialog::create_dialog(
&format!("{} properties from {}", port_name, element_name),
&format!("{port_name} properties from {element_name}"),
app,
&grid,
glib::clone!(@strong update_properties => move |app, dialog| {
@ -313,10 +302,13 @@ pub fn display_pipeline_details(app: &GPSApp) {
grid.set_row_spacing(4);
grid.set_margin_bottom(12);
if let Some(elements) = app.player.borrow().pipeline_elements() {
if let Some(elements) = graphbook::current_graphtab(app)
.player()
.pipeline_elements()
{
let elements_list = elements.join(" ");
let label = gtk::Label::builder()
.label(&format!("{} elements:", elements.len()))
.label(format!("{} elements:", elements.len()))
.hexpand(true)
.halign(gtk::Align::Start)
.valign(gtk::Align::Start)
@ -324,7 +316,7 @@ pub fn display_pipeline_details(app: &GPSApp) {
.build();
let value = gtk::Label::builder()
.label(&elements_list)
.label(elements_list)
.hexpand(true)
.halign(gtk::Align::Start)
.margin_start(4)

View file

@ -2,25 +2,21 @@
//
// Copyright 2022 Stéphane Cerveau <scerveau@collabora.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is part of GstPipelineStudio
//
// SPDX-License-Identifier: GPL-3.0-only
use crate::app::GPSApp;
use gtk::prelude::TreeViewExt;
use gtk::prelude::{Cast, CellLayoutExt, CellRendererTextExt, TreeViewExt};
use gtk::{CellRendererText, TreeView, TreeViewColumn};
pub fn add_column_to_treeview(app: &GPSApp, tree_name: &str, column_name: &str, column_n: i32) {
pub fn add_column_to_treeview(
app: &GPSApp,
tree_name: &str,
column_name: &str,
column_n: i32,
wrappable: bool,
) {
let treeview: TreeView = app
.builder
.object(tree_name)
@ -31,5 +27,11 @@ pub fn add_column_to_treeview(app: &GPSApp, tree_name: &str, column_name: &str,
// Association of the view's column with the model's `id` column.
column.add_attribute(&cell, "text", column_n);
column.set_title(column_name);
if wrappable {
column.set_sizing(gtk::TreeViewColumnSizing::Autosize);
let cell: gtk::CellRendererText = column.cells()[0].clone().downcast().unwrap();
cell.set_wrap_width(1024);
}
treeview.append_column(&column);
}

View file

@ -0,0 +1,8 @@
[wrap-git]
directory=gstreamer-1.0
url=https://gitlab.freedesktop.org/gstreamer/gstreamer.git
push-url=git@gitlab.freedesktop.org:gstreamer/gstreamer.git
revision=1.22
[provide]
dependency_names = gstreamer-1.0, gstreamer-base-1.0, gstreamer-sys-1.0, gstreamer-plugins-bad-1.0, gstreamer-video-1.0, gstreamer-player-1.0

9
subprojects/gtk.wrap Normal file
View file

@ -0,0 +1,9 @@
[wrap-git]
directory=gtk
url=https://gitlab.gnome.org/GNOME/gtk.git
push-url=ssh://git@gitlab.gnome.org:GNOME/gtk.git
revision=4.8.2
depth=1
[provide]
dependency_names=gtk4