├── .gitignore ├── docs ├── screenshot.png ├── making_a_release.md └── architecture.md ├── meson_options.txt ├── data ├── org.freedesktop.ryuukyu.Helvum.desktop.in ├── icons │ ├── meson.build │ ├── org.freedesktop.ryuukyu.Helvum-symbolic.svg │ └── org.freedesktop.ryuukyu.Helvum.svg ├── meson.build └── org.freedesktop.ryuukyu.Helvum.metainfo.xml.in ├── src ├── style.css ├── meson.build ├── view │ ├── mod.rs │ ├── node.rs │ ├── port.rs │ └── graph_view.rs ├── pipewire_connection │ └── state.rs ├── main.rs ├── application.rs └── pipewire_connection.rs ├── .github ├── flatpak.yml └── workflows │ └── flatpak.yml ├── Cargo.toml ├── meson.build ├── .gitlab-ci.yml ├── README.md ├── Cargo.lock └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /.flatpak-builder 2 | /.vscode 3 | /target 4 | -------------------------------------------------------------------------------- /docs/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/relulz/helvum/HEAD/docs/screenshot.png -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option( 2 | 'profile', 3 | type: 'combo', 4 | choices: [ 5 | 'default', 6 | 'development' 7 | ], 8 | value: 'default', 9 | description: 'The build profile for Helvum. One of "default" or "development".' 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /data/org.freedesktop.ryuukyu.Helvum.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Helvum 3 | GenericName=Patchbay 4 | Comment=A patchbay for pipewire 5 | Type=Application 6 | Exec=helvum 7 | Terminal=false 8 | Categories=AudioVideo;Audio;Video;Midi;Settings;GNOME;GTK; 9 | Icon=@icon@ -------------------------------------------------------------------------------- /data/icons/meson.build: -------------------------------------------------------------------------------- 1 | install_data( 2 | '@0@.svg'.format(base_id), 3 | install_dir: iconsdir / 'hicolor' / 'scalable' / 'apps' 4 | ) 5 | 6 | install_data( 7 | '@0@-symbolic.svg'.format(base_id), 8 | install_dir: iconsdir / 'hicolor' / 'symbolic' / 'apps', 9 | ) 10 | -------------------------------------------------------------------------------- /src/style.css: -------------------------------------------------------------------------------- 1 | @define-color audio rgb(50,100,240); 2 | @define-color video rgb(200,200,0); 3 | @define-color midi rgb(200,0,50); 4 | @define-color graphview-link #808080; 5 | 6 | .audio { 7 | background: @audio; 8 | color: black; 9 | } 10 | 11 | .video { 12 | background: @video; 13 | color: black; 14 | } 15 | 16 | .midi { 17 | background: @midi; 18 | color: black; 19 | } 20 | 21 | graphview { 22 | background: @text_view_bg; 23 | } -------------------------------------------------------------------------------- /data/icons/org.freedesktop.ryuukyu.Helvum-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.github/flatpak.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | name: "Flatpak" 7 | jobs: 8 | flatpak: 9 | name: "Flatpak" 10 | runs-on: ubuntu-latest 11 | container: 12 | image: bilelmoussaoui/flatpak-github-actions:gnome-41 13 | options: --privileged 14 | steps: 15 | - uses: actions/checkout@v2 16 | with: 17 | submodules: recursive 18 | - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4 19 | with: 20 | bundle: org.freedesktop.ryuukyu.Helvum.flatpak 21 | manifest-path: build-aux/org.freedesktop.ryuukyu.Helvum.json 22 | cache-key: flatpak-builder-${{ github.sha }} 23 | 24 | -------------------------------------------------------------------------------- /.github/workflows/flatpak.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | name: "Flatpak" 7 | jobs: 8 | flatpak: 9 | name: "Flatpak" 10 | runs-on: ubuntu-latest 11 | container: 12 | image: bilelmoussaoui/flatpak-github-actions:gnome-41 13 | options: --privileged 14 | steps: 15 | - uses: actions/checkout@v2 16 | with: 17 | submodules: recursive 18 | - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4 19 | with: 20 | bundle: org.freedesktop.ryuukyu.Helvum.flatpak 21 | manifest-path: build-aux/org.freedesktop.ryuukyu.Helvum.json 22 | cache-key: flatpak-builder-${{ github.sha }} 23 | 24 | -------------------------------------------------------------------------------- /src/meson.build: -------------------------------------------------------------------------------- 1 | rust_sources = files( 2 | 'application.rs', 3 | 'main.rs', 4 | 'pipewire_connection.rs', 5 | 'pipewire_connection/state.rs', 6 | 'style.css', 7 | 'view/graph_view.rs', 8 | 'view/mod.rs', 9 | 'view/node.rs', 10 | 'view/port.rs', 11 | ) 12 | 13 | custom_target( 14 | 'cargo-build', 15 | build_by_default: true, 16 | input: [ 17 | cargo_sources, 18 | rust_sources 19 | ], 20 | output: meson.project_name(), 21 | console: true, 22 | install: true, 23 | install_dir: bindir, 24 | command: [ 25 | cargo_script, 26 | meson.build_root(), 27 | meson.source_root(), 28 | '@OUTPUT@', 29 | get_option('profile'), 30 | meson.project_name(), 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "helvum" 3 | version = "0.3.2" 4 | authors = ["Tom A. Wagner "] 5 | edition = "2021" 6 | rust-version = "1.56" 7 | license = "GPL-3.0-only" 8 | description = "A GTK patchbay for pipewire" 9 | repository = "https://gitlab.freedesktop.org/ryuukyu/helvum" 10 | readme = "README.md" 11 | keywords = ["pipewire", "gtk", "patchbay", "gui", "utility"] 12 | categories = ["gui", "multimedia"] 13 | 14 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 15 | 16 | [dependencies] 17 | pipewire = "0.4" 18 | gtk = { version = "0.3", package = "gtk4" } 19 | glib = { version = "0.14", features = ["log"] } 20 | 21 | log = "0.4.11" 22 | 23 | once_cell = "1.7.2" 24 | -------------------------------------------------------------------------------- /data/meson.build: -------------------------------------------------------------------------------- 1 | subdir('icons') 2 | 3 | desktop_conf = configuration_data() 4 | desktop_conf.set('icon', base_id) 5 | desktop_file = configure_file( 6 | input: '@0@.desktop.in'.format(base_id), 7 | output: '@BASENAME@', 8 | configuration: desktop_conf 9 | ) 10 | 11 | if desktop_file_validate.found() 12 | test( 13 | 'validate-desktop', 14 | desktop_file_validate, 15 | args: [ 16 | desktop_file 17 | ], 18 | ) 19 | endif 20 | 21 | install_data( 22 | desktop_file, 23 | install_dir: datadir / 'applications' 24 | ) 25 | 26 | 27 | appdata_conf = configuration_data() 28 | appdata_conf.set('app-id', base_id) 29 | appdata_file = configure_file( 30 | input: '@0@.metainfo.xml.in'.format(base_id), 31 | output: '@BASENAME@', 32 | configuration: appdata_conf 33 | ) 34 | 35 | # Validate Appdata 36 | if appstream_util.found() 37 | test( 38 | 'validate-appdata', 39 | appstream_util, 40 | args: [ 41 | 'validate', '--nonet', appdata_file 42 | ], 43 | ) 44 | endif 45 | 46 | install_data( 47 | appdata_file, 48 | install_dir: datadir / 'metainfo' 49 | ) 50 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project( 2 | 'helvum', 3 | 'rust', 4 | version: '0.3.2', 5 | license: 'GPL-3.0', 6 | meson_version: '>=0.50.0' 7 | ) 8 | 9 | base_id = 'org.freedesktop.ryuukyu.Helvum' 10 | 11 | dependency('glib-2.0', version: '>= 2.66') 12 | dependency('gtk4', version: '>= 4.4.0') 13 | dependency('libpipewire-0.3') 14 | 15 | desktop_file_validate = find_program('desktop-file-validate', required: false) 16 | appstream_util = find_program('appstream-util', required: false) 17 | cargo = find_program('cargo', required: true) 18 | cargo_script = find_program('build-aux/cargo.sh') 19 | 20 | prefix = get_option('prefix') 21 | bindir = prefix / get_option('bindir') 22 | datadir = prefix / get_option('datadir') 23 | iconsdir = datadir / 'icons' 24 | 25 | meson.add_dist_script( 26 | 'build-aux/dist-vendor.sh', 27 | meson.build_root() / 'meson-dist' / meson.project_name() + '-' + meson.project_version(), 28 | meson.source_root() 29 | ) 30 | 31 | cargo_sources = files( 32 | 'Cargo.toml', 33 | 'Cargo.lock', 34 | ) 35 | 36 | subdir('src') 37 | subdir('data') 38 | 39 | meson.add_install_script('build-aux/meson_post_install.py') 40 | -------------------------------------------------------------------------------- /src/view/mod.rs: -------------------------------------------------------------------------------- 1 | // mod.rs 2 | // 3 | // Copyright 2021 Tom A. Wagner 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | 20 | //! The view presented to the user. 21 | //! 22 | //! This module contains gtk widgets needed to present the graphical user interface. 23 | 24 | mod graph_view; 25 | mod node; 26 | mod port; 27 | 28 | pub use graph_view::GraphView; 29 | pub use node::Node; 30 | pub use port::Port; 31 | -------------------------------------------------------------------------------- /docs/making_a_release.md: -------------------------------------------------------------------------------- 1 | # Making a release 2 | 3 | The following describes the process of making a new release: 4 | 5 | 1. In `data/org.freedesktop.ryuukyu.Helvum.metainfo.xml.in`, 6 | add a new `` tag to the releases section with the appropriate version and date. 7 | 8 | 2. In `meson.build` and `Cargo.toml`, bumb the projects version to the new version. 9 | 10 | 3. Ensure cargo dependencies are up-to-date by running `cargo outdated` (may require running `cargo install cargo-outdated`) and updating outdated dependencies (including the versions specified in `Cargo.lock`). 11 | 12 | 4. Commit the changes with the a message of the format "Release x.y.z" 13 | 14 | 5. Add a tag to the release with the new version and a description from describing the changes as a message (run `git tag -a x.y.z`, then write the message) 15 | 16 | 6. Make a **new** meson build directory and run `meson dist`. 17 | Two files should be created in a `meson-dist` subdirectory: 18 | 19 | `helvum-x.y.z.tar.xz` and 20 | `helvum-x.y.z.tar.xz.sha256sum` 21 | 22 | 7. Push the new commit and tag to upstream, then create a new release on gitlab from the new tag, the description from the tags message formatted as markdown, and also add the two files from step 6 to the description. 23 | -------------------------------------------------------------------------------- /data/org.freedesktop.ryuukyu.Helvum.metainfo.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @app-id@ 5 | CC-BY-SA-4.0 6 | GPL-3.0-only 7 | Helvum 8 | Patchbay for PipeWire 9 | 10 |

11 | Helvum is a graphical patchbay for PipeWire. 12 | It allows creating and removing connections between applications and/or devices to reroute 13 | flow of audio, video and MIDI data to where it is needed. 14 |

15 |
16 | 17 | 18 | https://gitlab.freedesktop.org/ryuukyu/helvum/-/raw/main/docs/screenshot.png 19 | 20 | 21 | @app-id@.desktop 22 | https://gitlab.freedesktop.org/ryuukyu/helvum 23 | https://gitlab.freedesktop.org/ryuukyu/helvum/-/issues 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | HiDpiIcon 35 | ModernToolkit 36 | 37 | Tom A. Wagner 38 | tom.a.wagner@protonmail.com 39 |
40 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: 2 | - project: 'freedesktop/ci-templates' # the project to include from 3 | ref: '34f4ade99434043f88e164933f570301fd18b125' # git ref of that project 4 | file: '/templates/fedora.yml' # the actual file to include 5 | 6 | stages: 7 | - prepare 8 | - lint 9 | - test 10 | - extras 11 | 12 | variables: 13 | FDO_UPSTREAM_REPO: 'ryuukyu/helvum' 14 | 15 | # Version and tag for our current container 16 | .fedora: 17 | variables: 18 | FDO_DISTRIBUTION_VERSION: '35' 19 | # Update this to trigger a container rebuild 20 | FDO_DISTRIBUTION_TAG: '2021-11-23.0' 21 | 22 | build-fedora-container: 23 | extends: 24 | - .fedora # our template job above 25 | - .fdo.container-build@fedora@x86_64 # the CI template 26 | stage: prepare 27 | variables: 28 | # clang-devel: required by rust bindgen 29 | FDO_DISTRIBUTION_PACKAGES: >- 30 | rust 31 | cargo 32 | rustfmt 33 | clippy 34 | pipewire-devel 35 | gtk4-devel 36 | clang-devel 37 | 38 | rustfmt: 39 | extends: 40 | - .fedora 41 | - .fdo.distribution-image@fedora 42 | stage: lint 43 | script: 44 | - cargo fmt --version 45 | - cargo fmt -- --color=always --check 46 | 47 | test-stable: 48 | extends: 49 | - .fedora 50 | - .fdo.distribution-image@fedora 51 | stage: test 52 | script: 53 | - rustc --version 54 | - cargo build --color=always --all-targets 55 | - cargo test --color=always 56 | 57 | rustdoc: 58 | extends: 59 | - .fedora 60 | - .fdo.distribution-image@fedora 61 | stage: extras 62 | variables: 63 | RUSTDOCFLAGS: '-Dwarnings' 64 | script: 65 | - rustdoc --version 66 | - cargo doc --no-deps 67 | 68 | clippy: 69 | extends: 70 | - .fedora 71 | - .fdo.distribution-image@fedora 72 | stage: extras 73 | script: 74 | - cargo clippy --version 75 | - cargo clippy --color=always --all-targets -- -D warnings 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Helvum is a GTK-based patchbay for pipewire, inspired by the JACK tool [catia](https://kx.studio/Applications:Catia). 2 | 3 | ![Screenshot](docs/screenshot.png) 4 | 5 | [![Packaging status](https://repology.org/badge/vertical-allrepos/helvum.svg)](https://repology.org/project/helvum/versions) 6 | 7 | 8 | # Features planned 9 | 10 | - Volume control 11 | - "Debug mode" that lets you view advanced information for nodes and ports 12 | 13 | More suggestions are welcome! 14 | 15 | # Building 16 | 17 | ## Via flatpak (recommended) 18 | The recommended way to build is using flatpak, which will take care of all dependencies and avoid any problems that may come from different system configurations. 19 | 20 | If you don't have the flathub repo in your remote-list for flatpak you will need to add that first: 21 | ```shell 22 | $ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo 23 | ``` 24 | 25 | Then install the required flatpak platform and SDK, if you dont have them already: 26 | ```shell 27 | $ flatpak install org.gnome.{Platform,Sdk}//41 org.freedesktop.Sdk.Extension.rust-stable//21.08 org.freedesktop.Sdk.Extension.llvm12//21.08 28 | ``` 29 | 30 | To compile and install as a flatpak, clone the project, change to the project directory, and run: 31 | ```shell 32 | $ flatpak-builder --install flatpak-build/ build-aux/org.freedesktop.ryuukyu.Helvum.json 33 | ``` 34 | 35 | You can then run the app via 36 | ```shell 37 | $ flatpak run org.freedesktop.ryuukyu.Helvum 38 | ``` 39 | 40 | ## Manually 41 | For compilation, you will need: 42 | 43 | - Meson 44 | - An up-to-date rust toolchain 45 | - `libclang-3.7` or higher 46 | - `gtk-4.0` and `pipewire-0.3` development headers 47 | 48 | To compile and install, run 49 | 50 | ```shell 51 | $ meson setup build && cd build 52 | $ meson compile 53 | $ meson install 54 | ``` 55 | 56 | in the repository root. 57 | This will install the compiled project files into `/usr/local`. 58 | 59 | # License 60 | Helvum is distributed under the terms of the GPL3 license. 61 | See LICENSE for more information. 62 | -------------------------------------------------------------------------------- /docs/architecture.md: -------------------------------------------------------------------------------- 1 | # Architecture 2 | If you want to understand the high-level architecture of helvum, 3 | this document is the right place. 4 | 5 | It provides a birds-eye view of the general architecture, and also goes into details on some 6 | components like the view. 7 | 8 | # Top Level Architecture 9 | Helvum uses an architecture with the components laid out like this: 10 | 11 | ``` 12 | ┌──────┐ 13 | │ GTK │ 14 | │ View │ 15 | └────┬─┘ 16 | Λ ┆ 17 | │<───── updates view ┌───────┐ 18 | │ ┆ │ State │ 19 | │ ┆<─ notifies of user input └───────┘ 20 | │ ┆ (using signals) Λ 21 | │ ┆ │ 22 | │ ┆ │<─── updates/reads state 23 | │ V notifies of remote changes │ 24 | ┌┴────────────┐ via messages ┌─────────┴─────────┐ 25 | │ Application │<╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ Seperate │ 26 | │ Object ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌>│ Pipewire Thread │ 27 | └─────────────┘ request changes to remote └───────────────────┘ 28 | via messages Λ 29 | ║ 30 | ║ 31 | V 32 | [ Remote Pipewire Server ] 33 | ``` 34 | The program is split between two cooperating threads. 35 | The GTK thread (displayed on the left side) will sit in a GTK event processing loop, while the pipewire thread (displayed on the right side) will sit in a pipewire event processing loop. 36 | 37 | The `Application` object inside the GTK thread communicates with the pipewire thread using two channels, 38 | where each message sent by one thread will trigger the loop of the other thread to invoke a callback 39 | with the received message. 40 | 41 | For each change on the remote pipewire server, the pipewire thread updates the state and notifies 42 | the `Application` in the GTK thread if changes are needed. 43 | The `Application` then updates the view to reflect those changes. 44 | 45 | Additionally, a user may also make changes using the view. 46 | For each change, the view notifies the `Application` by emitting a matching signal. 47 | The `Application` will then ask the pipewire thread to make those changes on the remote. \ 48 | These changes will then be applied to the view like any other remote changes as explained above. 49 | 50 | # View Architecture 51 | TODO -------------------------------------------------------------------------------- /src/pipewire_connection/state.rs: -------------------------------------------------------------------------------- 1 | // state.rs 2 | // 3 | // Copyright 2021 Tom A. Wagner 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | 20 | use std::collections::HashMap; 21 | 22 | use crate::MediaType; 23 | 24 | /// Any pipewire item we need to keep track of. 25 | /// These will be saved in the `State` struct associated with their id. 26 | pub(super) enum Item { 27 | Node { 28 | // Keep track of the nodes media type to color ports on it. 29 | media_type: Option, 30 | }, 31 | Port { 32 | // Save the id of the node this is on so we can remove the port from it 33 | // when it is deleted. 34 | node_id: u32, 35 | }, 36 | Link { 37 | port_from: u32, 38 | port_to: u32, 39 | }, 40 | } 41 | 42 | /// This struct keeps track of any relevant items and stores them under their IDs. 43 | /// 44 | /// Given two port ids, it can also efficiently find the id of the link that connects them. 45 | #[derive(Default)] 46 | pub(super) struct State { 47 | /// Map pipewire ids to items. 48 | items: HashMap, 49 | /// Map `(output port id, input port id)` tuples to the id of the link that connects them. 50 | links: HashMap<(u32, u32), u32>, 51 | } 52 | 53 | impl State { 54 | /// Create a new, empty state. 55 | pub fn new() -> Self { 56 | Self::default() 57 | } 58 | 59 | /// Add a new item under the specified id. 60 | pub fn insert(&mut self, id: u32, item: Item) { 61 | if let Item::Link { 62 | port_from, port_to, .. 63 | } = item 64 | { 65 | self.links.insert((port_from, port_to), id); 66 | } 67 | 68 | self.items.insert(id, item); 69 | } 70 | 71 | /// Get the item that has the specified id. 72 | pub fn get(&self, id: u32) -> Option<&Item> { 73 | self.items.get(&id) 74 | } 75 | 76 | /// Get the id of the link that links the two specified ports. 77 | pub fn get_link_id(&self, output_port: u32, input_port: u32) -> Option { 78 | self.links.get(&(output_port, input_port)).copied() 79 | } 80 | 81 | /// Remove the item with the specified id, returning it if it exists. 82 | pub fn remove(&mut self, id: u32) -> Option { 83 | let removed = self.items.remove(&id); 84 | 85 | if let Some(Item::Link { port_from, port_to }) = removed { 86 | self.links.remove(&(port_from, port_to)); 87 | } 88 | 89 | removed 90 | } 91 | 92 | /// Convenience function: Get the id of the node a port is on 93 | pub fn get_node_of_port(&self, port: u32) -> Option { 94 | if let Some(Item::Port { node_id }) = self.get(port) { 95 | Some(*node_id) 96 | } else { 97 | None 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | // main.rs 2 | // 3 | // Copyright 2021 Tom A. Wagner 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | 20 | mod application; 21 | mod pipewire_connection; 22 | mod view; 23 | 24 | use glib::PRIORITY_DEFAULT; 25 | use gtk::prelude::*; 26 | use pipewire::spa::Direction; 27 | 28 | /// Messages sent by the GTK thread to notify the pipewire thread. 29 | #[derive(Debug, Clone)] 30 | enum GtkMessage { 31 | /// Toggle a link between the two specified ports. 32 | ToggleLink { port_from: u32, port_to: u32 }, 33 | /// Quit the event loop and let the thread finish. 34 | Terminate, 35 | } 36 | 37 | /// Messages sent by the pipewire thread to notify the GTK thread. 38 | #[derive(Debug, Clone)] 39 | enum PipewireMessage { 40 | NodeAdded { 41 | id: u32, 42 | name: String, 43 | node_type: Option, 44 | }, 45 | PortAdded { 46 | id: u32, 47 | node_id: u32, 48 | name: String, 49 | direction: Direction, 50 | media_type: Option, 51 | }, 52 | LinkAdded { 53 | id: u32, 54 | node_from: u32, 55 | port_from: u32, 56 | node_to: u32, 57 | port_to: u32, 58 | active: bool, 59 | }, 60 | LinkStateChanged { 61 | id: u32, 62 | active: bool, 63 | }, 64 | NodeRemoved { 65 | id: u32, 66 | }, 67 | PortRemoved { 68 | id: u32, 69 | node_id: u32, 70 | }, 71 | LinkRemoved { 72 | id: u32, 73 | }, 74 | } 75 | 76 | #[derive(Debug, Clone)] 77 | pub enum NodeType { 78 | Input, 79 | Output, 80 | } 81 | 82 | #[derive(Debug, Copy, Clone)] 83 | pub enum MediaType { 84 | Audio, 85 | Video, 86 | Midi, 87 | } 88 | 89 | #[derive(Debug, Clone)] 90 | pub struct PipewireLink { 91 | pub node_from: u32, 92 | pub port_from: u32, 93 | pub node_to: u32, 94 | pub port_to: u32, 95 | } 96 | 97 | static GLIB_LOGGER: glib::GlibLogger = glib::GlibLogger::new( 98 | glib::GlibLoggerFormat::Structured, 99 | glib::GlibLoggerDomain::CrateTarget, 100 | ); 101 | 102 | fn init_glib_logger() { 103 | log::set_logger(&GLIB_LOGGER).expect("Failed to set logger"); 104 | 105 | // Glib does not have a "Trace" log level, so only print messages "Debug" or higher priority. 106 | log::set_max_level(log::LevelFilter::Debug); 107 | } 108 | 109 | fn main() -> Result<(), Box> { 110 | init_glib_logger(); 111 | gtk::init()?; 112 | 113 | // Aquire main context so that we can attach the gtk channel later. 114 | let ctx = glib::MainContext::default(); 115 | let _guard = ctx.acquire().unwrap(); 116 | 117 | // Start the pipewire thread with channels in both directions. 118 | let (gtk_sender, gtk_receiver) = glib::MainContext::channel(PRIORITY_DEFAULT); 119 | let (pw_sender, pw_receiver) = pipewire::channel::channel(); 120 | let pw_thread = 121 | std::thread::spawn(move || pipewire_connection::thread_main(gtk_sender, pw_receiver)); 122 | 123 | let app = application::Application::new(gtk_receiver, pw_sender.clone()); 124 | 125 | app.run(); 126 | 127 | pw_sender 128 | .send(GtkMessage::Terminate) 129 | .expect("Failed to send message"); 130 | 131 | pw_thread.join().expect("Pipewire thread panicked"); 132 | 133 | Ok(()) 134 | } 135 | -------------------------------------------------------------------------------- /src/view/node.rs: -------------------------------------------------------------------------------- 1 | // node.rs 2 | // 3 | // Copyright 2021 Tom A. Wagner 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | 20 | use gtk::{glib, prelude::*, subclass::prelude::*}; 21 | use pipewire::spa::Direction; 22 | 23 | use std::collections::HashMap; 24 | 25 | mod imp { 26 | use super::*; 27 | 28 | use std::cell::{Cell, RefCell}; 29 | 30 | pub struct Node { 31 | pub(super) grid: gtk::Grid, 32 | pub(super) label: gtk::Label, 33 | pub(super) ports: RefCell>, 34 | pub(super) num_ports_in: Cell, 35 | pub(super) num_ports_out: Cell, 36 | } 37 | 38 | #[glib::object_subclass] 39 | impl ObjectSubclass for Node { 40 | const NAME: &'static str = "Node"; 41 | type Type = super::Node; 42 | type ParentType = gtk::Widget; 43 | 44 | fn class_init(klass: &mut Self::Class) { 45 | klass.set_layout_manager_type::(); 46 | } 47 | 48 | fn new() -> Self { 49 | let grid = gtk::Grid::new(); 50 | let label = gtk::Label::new(None); 51 | 52 | grid.attach(&label, 0, 0, 2, 1); 53 | 54 | // Display a grab cursor when the mouse is over the label so the user knows the node can be dragged. 55 | label.set_cursor(gtk::gdk::Cursor::from_name("grab", None).as_ref()); 56 | 57 | Self { 58 | grid, 59 | label, 60 | ports: RefCell::new(HashMap::new()), 61 | num_ports_in: Cell::new(0), 62 | num_ports_out: Cell::new(0), 63 | } 64 | } 65 | } 66 | 67 | impl ObjectImpl for Node { 68 | fn constructed(&self, obj: &Self::Type) { 69 | self.parent_constructed(obj); 70 | self.grid.set_parent(obj); 71 | } 72 | 73 | fn dispose(&self, _obj: &Self::Type) { 74 | self.grid.unparent(); 75 | } 76 | } 77 | 78 | impl WidgetImpl for Node {} 79 | } 80 | 81 | glib::wrapper! { 82 | pub struct Node(ObjectSubclass) 83 | @extends gtk::Widget; 84 | } 85 | 86 | impl Node { 87 | pub fn new(name: &str) -> Self { 88 | let res: Self = glib::Object::new(&[]).expect("Failed to create Node"); 89 | let private = imp::Node::from_instance(&res); 90 | 91 | private.label.set_text(name); 92 | 93 | res 94 | } 95 | 96 | pub fn add_port(&mut self, id: u32, port: super::port::Port) { 97 | let private = imp::Node::from_instance(self); 98 | 99 | match port.direction() { 100 | Direction::Input => { 101 | private 102 | .grid 103 | .attach(&port, 0, private.num_ports_in.get() + 1, 1, 1); 104 | private.num_ports_in.set(private.num_ports_in.get() + 1); 105 | } 106 | Direction::Output => { 107 | private 108 | .grid 109 | .attach(&port, 1, private.num_ports_out.get() + 1, 1, 1); 110 | private.num_ports_out.set(private.num_ports_out.get() + 1); 111 | } 112 | } 113 | 114 | private.ports.borrow_mut().insert(id, port); 115 | } 116 | 117 | pub fn get_port(&self, id: u32) -> Option { 118 | let private = imp::Node::from_instance(self); 119 | private.ports.borrow_mut().get(&id).cloned() 120 | } 121 | 122 | pub fn remove_port(&self, id: u32) { 123 | let private = imp::Node::from_instance(self); 124 | if let Some(port) = private.ports.borrow_mut().remove(&id) { 125 | match port.direction() { 126 | Direction::Input => private.num_ports_in.set(private.num_ports_in.get() - 1), 127 | Direction::Output => private.num_ports_in.set(private.num_ports_out.get() - 1), 128 | } 129 | 130 | port.unparent(); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /data/icons/org.freedesktop.ryuukyu.Helvum.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/view/port.rs: -------------------------------------------------------------------------------- 1 | // port.rs 2 | // 3 | // Copyright 2021 Tom A. Wagner 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | 20 | use gtk::{ 21 | gdk, 22 | glib::{self, clone, subclass::Signal}, 23 | prelude::*, 24 | subclass::prelude::*, 25 | }; 26 | use log::{trace, warn}; 27 | use pipewire::spa::Direction; 28 | 29 | use crate::MediaType; 30 | 31 | /// A helper struct for linking a output port to an input port. 32 | /// It carries the output ports id. 33 | #[derive(Clone, Debug, glib::GBoxed)] 34 | #[gboxed(type_name = "HelvumForwardLink")] 35 | struct ForwardLink(u32); 36 | 37 | /// A helper struct for linking an input to an output port. 38 | /// It carries the input ports id. 39 | #[derive(Clone, Debug, glib::GBoxed)] 40 | #[gboxed(type_name = "HelvumReversedLink")] 41 | struct ReversedLink(u32); 42 | 43 | mod imp { 44 | use once_cell::{sync::Lazy, unsync::OnceCell}; 45 | use pipewire::spa::Direction; 46 | 47 | use super::*; 48 | 49 | /// Graphical representation of a pipewire port. 50 | #[derive(Default)] 51 | pub struct Port { 52 | pub(super) label: OnceCell, 53 | pub(super) id: OnceCell, 54 | pub(super) direction: OnceCell, 55 | } 56 | 57 | #[glib::object_subclass] 58 | impl ObjectSubclass for Port { 59 | const NAME: &'static str = "Port"; 60 | type Type = super::Port; 61 | type ParentType = gtk::Widget; 62 | 63 | fn class_init(klass: &mut Self::Class) { 64 | klass.set_layout_manager_type::(); 65 | 66 | // Make it look like a GTK button. 67 | klass.set_css_name("button"); 68 | } 69 | } 70 | 71 | impl ObjectImpl for Port { 72 | fn dispose(&self, _obj: &Self::Type) { 73 | if let Some(label) = self.label.get() { 74 | label.unparent() 75 | } 76 | } 77 | 78 | fn signals() -> &'static [Signal] { 79 | static SIGNALS: Lazy> = Lazy::new(|| { 80 | vec![Signal::builder( 81 | "port-toggled", 82 | // Provide id of output port and input port to signal handler. 83 | &[::static_type().into(), ::static_type().into()], 84 | // signal handler sends back nothing. 85 | <()>::static_type().into(), 86 | ) 87 | .build()] 88 | }); 89 | 90 | SIGNALS.as_ref() 91 | } 92 | } 93 | impl WidgetImpl for Port {} 94 | } 95 | 96 | glib::wrapper! { 97 | pub struct Port(ObjectSubclass) 98 | @extends gtk::Widget; 99 | } 100 | 101 | impl Port { 102 | pub fn new(id: u32, name: &str, direction: Direction, media_type: Option) -> Self { 103 | // Create the widget and initialize needed fields 104 | let res: Self = glib::Object::new(&[]).expect("Failed to create Port"); 105 | 106 | let private = imp::Port::from_instance(&res); 107 | private.id.set(id).expect("Port id already set"); 108 | private 109 | .direction 110 | .set(direction) 111 | .expect("Port direction already set"); 112 | 113 | let label = gtk::Label::new(Some(name)); 114 | label.set_parent(&res); 115 | private 116 | .label 117 | .set(label) 118 | .expect("Port label was already set"); 119 | 120 | // Add a drag source and drop target controller with the type depending on direction, 121 | // they will be responsible for link creation by dragging an output port onto an input port or the other way around. 122 | 123 | // FIXME: We should protect against different media types, e.g. it should not be possible to drop a video port on an audio port. 124 | 125 | // The port will simply provide its pipewire id to the drag target. 126 | let drag_src = gtk::DragSourceBuilder::new() 127 | .content(&gdk::ContentProvider::for_value(&match direction { 128 | Direction::Input => ReversedLink(id).to_value(), 129 | Direction::Output => ForwardLink(id).to_value(), 130 | })) 131 | .build(); 132 | drag_src.connect_drag_begin(move |_, _| { 133 | trace!("Drag started from port {}", id); 134 | }); 135 | drag_src.connect_drag_cancel(move |_, _, _| { 136 | trace!("Drag from port {} was cancelled", id); 137 | false 138 | }); 139 | res.add_controller(&drag_src); 140 | 141 | // The drop target will accept either a `ForwardLink` or `ReversedLink` depending in its own direction, 142 | // and use it to emit its `port-toggled` signal. 143 | let drop_target = gtk::DropTarget::new( 144 | match direction { 145 | Direction::Input => ForwardLink::static_type(), 146 | Direction::Output => ReversedLink::static_type(), 147 | }, 148 | gdk::DragAction::COPY, 149 | ); 150 | match direction { 151 | Direction::Input => { 152 | drop_target.connect_drop( 153 | clone!(@weak res as this => @default-panic, move |drop_target, val, _, _| { 154 | if let Ok(ForwardLink(source_id)) = val.get::() { 155 | // Get the callback registered in the widget and call it 156 | drop_target 157 | .widget() 158 | .expect("Drop target has no widget") 159 | .emit_by_name("port-toggled", &[&source_id, &this.id()]) 160 | .expect("Failed to send signal"); 161 | } else { 162 | warn!("Invalid type dropped on ingoing port"); 163 | } 164 | 165 | true 166 | }), 167 | ); 168 | } 169 | Direction::Output => { 170 | drop_target.connect_drop( 171 | clone!(@weak res as this => @default-panic, move |drop_target, val, _, _| { 172 | if let Ok(ReversedLink(target_id)) = val.get::() { 173 | // Get the callback registered in the widget and call it 174 | drop_target 175 | .widget() 176 | .expect("Drop target has no widget") 177 | .emit_by_name("port-toggled", &[&this.id(), &target_id]) 178 | .expect("Failed to send signal"); 179 | } else { 180 | warn!("Invalid type dropped on outgoing port"); 181 | } 182 | 183 | true 184 | }), 185 | ); 186 | } 187 | } 188 | res.add_controller(&drop_target); 189 | 190 | // Display a grab cursor when the mouse is over the port so the user knows it can be dragged to another port. 191 | res.set_cursor(gtk::gdk::Cursor::from_name("grab", None).as_ref()); 192 | 193 | // Color the port according to its media type. 194 | match media_type { 195 | Some(MediaType::Video) => res.add_css_class("video"), 196 | Some(MediaType::Audio) => res.add_css_class("audio"), 197 | Some(MediaType::Midi) => res.add_css_class("midi"), 198 | None => {} 199 | } 200 | 201 | res 202 | } 203 | 204 | pub fn id(&self) -> u32 { 205 | let private = imp::Port::from_instance(self); 206 | private.id.get().copied().expect("Port id is not set") 207 | } 208 | 209 | pub fn direction(&self) -> &Direction { 210 | let private = imp::Port::from_instance(self); 211 | private.direction.get().expect("Port direction is not set") 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /src/application.rs: -------------------------------------------------------------------------------- 1 | // application.rs 2 | // 3 | // Copyright 2021 Tom A. Wagner 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | 20 | use std::cell::RefCell; 21 | 22 | use gtk::{ 23 | gio, 24 | glib::{self, clone, Continue, Receiver}, 25 | prelude::*, 26 | subclass::prelude::*, 27 | }; 28 | use log::{info, warn}; 29 | use pipewire::{channel::Sender, spa::Direction}; 30 | 31 | use crate::{ 32 | view::{self}, 33 | GtkMessage, MediaType, NodeType, PipewireLink, PipewireMessage, 34 | }; 35 | 36 | static STYLE: &str = include_str!("style.css"); 37 | 38 | mod imp { 39 | use super::*; 40 | 41 | use once_cell::unsync::OnceCell; 42 | 43 | #[derive(Default)] 44 | pub struct Application { 45 | pub(super) graphview: view::GraphView, 46 | pub(super) pw_sender: OnceCell>>, 47 | } 48 | 49 | #[glib::object_subclass] 50 | impl ObjectSubclass for Application { 51 | const NAME: &'static str = "HelvumApplication"; 52 | type Type = super::Application; 53 | type ParentType = gtk::Application; 54 | } 55 | 56 | impl ObjectImpl for Application {} 57 | impl ApplicationImpl for Application { 58 | fn activate(&self, app: &Self::Type) { 59 | let scrollwindow = gtk::ScrolledWindowBuilder::new() 60 | .child(&self.graphview) 61 | .build(); 62 | let window = gtk::ApplicationWindowBuilder::new() 63 | .application(app) 64 | .default_width(1280) 65 | .default_height(720) 66 | .title("Helvum - Pipewire Patchbay") 67 | .child(&scrollwindow) 68 | .build(); 69 | window 70 | .settings() 71 | .set_gtk_application_prefer_dark_theme(true); 72 | window.show(); 73 | } 74 | 75 | fn startup(&self, app: &Self::Type) { 76 | self.parent_startup(app); 77 | 78 | // Load CSS from the STYLE variable. 79 | let provider = gtk::CssProvider::new(); 80 | provider.load_from_data(STYLE.as_bytes()); 81 | gtk::StyleContext::add_provider_for_display( 82 | >k::gdk::Display::default().expect("Error initializing gtk css provider."), 83 | &provider, 84 | gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, 85 | ); 86 | } 87 | } 88 | impl GtkApplicationImpl for Application {} 89 | } 90 | 91 | glib::wrapper! { 92 | pub struct Application(ObjectSubclass) 93 | @extends gio::Application, gtk::Application, 94 | @implements gio::ActionGroup, gio::ActionMap; 95 | } 96 | 97 | impl Application { 98 | /// Create the view. 99 | /// This will set up the entire user interface and prepare it for being run. 100 | pub(super) fn new( 101 | gtk_receiver: Receiver, 102 | pw_sender: Sender, 103 | ) -> Self { 104 | let app: Application = 105 | glib::Object::new(&[("application-id", &"org.freedesktop.ryuukyu.Helvum")]) 106 | .expect("Failed to create new Application"); 107 | 108 | let imp = imp::Application::from_instance(&app); 109 | imp.pw_sender 110 | .set(RefCell::new(pw_sender)) 111 | // Discard the returned sender, as it does not implement `Debug`. 112 | .map_err(|_| ()) 113 | .expect("pw_sender field was already set"); 114 | 115 | // Add shortcut for quitting the application. 116 | let quit = gtk::gio::SimpleAction::new("quit", None); 117 | quit.connect_activate(clone!(@weak app => move |_, _| { 118 | app.quit(); 119 | })); 120 | app.set_accels_for_action("app.quit", &["Q"]); 121 | app.add_action(&quit); 122 | 123 | // React to messages received from the pipewire thread. 124 | gtk_receiver.attach( 125 | None, 126 | clone!( 127 | @weak app => @default-return Continue(true), 128 | move |msg| { 129 | match msg { 130 | PipewireMessage::NodeAdded{ id, name, node_type } => app.add_node(id, name.as_str(), node_type), 131 | PipewireMessage::PortAdded{ id, node_id, name, direction, media_type } => app.add_port(id, name.as_str(), node_id, direction, media_type), 132 | PipewireMessage::LinkAdded{ id, node_from, port_from, node_to, port_to, active} => app.add_link(id, node_from, port_from, node_to, port_to, active), 133 | PipewireMessage::LinkStateChanged { id, active } => app.link_state_changed(id, active), // TODO 134 | PipewireMessage::NodeRemoved { id } => app.remove_node(id), 135 | PipewireMessage::PortRemoved { id, node_id } => app.remove_port(id, node_id), 136 | PipewireMessage::LinkRemoved { id } => app.remove_link(id) 137 | }; 138 | Continue(true) 139 | } 140 | ), 141 | ); 142 | 143 | app 144 | } 145 | 146 | /// Add a new node to the view. 147 | fn add_node(&self, id: u32, name: &str, node_type: Option) { 148 | info!("Adding node to graph: id {}", id); 149 | 150 | imp::Application::from_instance(self).graphview.add_node( 151 | id, 152 | view::Node::new(name), 153 | node_type, 154 | ); 155 | } 156 | 157 | /// Add a new port to the view. 158 | fn add_port( 159 | &self, 160 | id: u32, 161 | name: &str, 162 | node_id: u32, 163 | direction: Direction, 164 | media_type: Option, 165 | ) { 166 | info!("Adding port to graph: id {}", id); 167 | 168 | let imp = imp::Application::from_instance(self); 169 | 170 | let port = view::Port::new(id, name, direction, media_type); 171 | 172 | // Create or delete a link if the widget emits the "port-toggled" signal. 173 | if let Err(e) = port.connect_local( 174 | "port_toggled", 175 | false, 176 | clone!(@weak self as app => @default-return None, move |args| { 177 | // Args always look like this: &[widget, id_port_from, id_port_to] 178 | let port_from = args[1].get::().unwrap(); 179 | let port_to = args[2].get::().unwrap(); 180 | 181 | app.toggle_link(port_from, port_to); 182 | 183 | None 184 | }), 185 | ) { 186 | warn!("Failed to connect to \"port-toggled\" signal: {}", e); 187 | } 188 | 189 | imp.graphview.add_port(node_id, id, port); 190 | } 191 | 192 | /// Add a new link to the view. 193 | fn add_link( 194 | &self, 195 | id: u32, 196 | node_from: u32, 197 | port_from: u32, 198 | node_to: u32, 199 | port_to: u32, 200 | active: bool, 201 | ) { 202 | info!("Adding link to graph: id {}", id); 203 | 204 | // FIXME: Links should be colored depending on the data they carry (video, audio, midi) like ports are. 205 | 206 | // Update graph to contain the new link. 207 | imp::Application::from_instance(self).graphview.add_link( 208 | id, 209 | PipewireLink { 210 | node_from, 211 | port_from, 212 | node_to, 213 | port_to, 214 | }, 215 | active, 216 | ); 217 | } 218 | 219 | fn link_state_changed(&self, id: u32, active: bool) { 220 | info!( 221 | "Link state changed: Link (id={}) is now {}", 222 | id, 223 | if active { "active" } else { "inactive" } 224 | ); 225 | 226 | imp::Application::from_instance(self) 227 | .graphview 228 | .set_link_state(id, active); 229 | } 230 | 231 | // Toggle a link between the two specified ports on the remote pipewire server. 232 | fn toggle_link(&self, port_from: u32, port_to: u32) { 233 | let imp = imp::Application::from_instance(self); 234 | let sender = imp.pw_sender.get().expect("pw_sender not set").borrow_mut(); 235 | sender 236 | .send(GtkMessage::ToggleLink { port_from, port_to }) 237 | .expect("Failed to send message"); 238 | } 239 | 240 | /// Remove the node with the specified id from the view. 241 | fn remove_node(&self, id: u32) { 242 | info!("Removing node from graph: id {}", id); 243 | 244 | let imp = imp::Application::from_instance(self); 245 | imp.graphview.remove_node(id); 246 | } 247 | 248 | /// Remove the port with the id `id` from the node with the id `node_id` 249 | /// from the view. 250 | fn remove_port(&self, id: u32, node_id: u32) { 251 | info!("Removing port from graph: id {}, node_id: {}", id, node_id); 252 | 253 | let imp = imp::Application::from_instance(self); 254 | imp.graphview.remove_port(id, node_id); 255 | } 256 | 257 | /// Remove the link with the specified id from the view. 258 | fn remove_link(&self, id: u32) { 259 | info!("Removing link from graph: id {}", id); 260 | 261 | let imp = imp::Application::from_instance(self); 262 | imp.graphview.remove_link(id); 263 | } 264 | } 265 | -------------------------------------------------------------------------------- /src/pipewire_connection.rs: -------------------------------------------------------------------------------- 1 | // pipewire_connection.rs 2 | // 3 | // Copyright 2021 Tom A. Wagner 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | 20 | mod state; 21 | 22 | use std::{cell::RefCell, collections::HashMap, rc::Rc}; 23 | 24 | use gtk::glib::{self, clone}; 25 | use log::{debug, info, warn}; 26 | use pipewire::{ 27 | link::{Link, LinkChangeMask, LinkListener, LinkState}, 28 | prelude::*, 29 | properties, 30 | registry::{GlobalObject, Registry}, 31 | spa::{Direction, ForeignDict}, 32 | types::ObjectType, 33 | Context, Core, MainLoop, 34 | }; 35 | 36 | use crate::{GtkMessage, MediaType, NodeType, PipewireMessage}; 37 | use state::{Item, State}; 38 | 39 | enum ProxyItem { 40 | Link { 41 | _proxy: Link, 42 | _listener: LinkListener, 43 | }, 44 | } 45 | 46 | /// The "main" function of the pipewire thread. 47 | pub(super) fn thread_main( 48 | gtk_sender: glib::Sender, 49 | pw_receiver: pipewire::channel::Receiver, 50 | ) { 51 | let mainloop = MainLoop::new().expect("Failed to create mainloop"); 52 | let context = Context::new(&mainloop).expect("Failed to create context"); 53 | let core = Rc::new(context.connect(None).expect("Failed to connect to remote")); 54 | let registry = Rc::new(core.get_registry().expect("Failed to get registry")); 55 | 56 | // Keep proxies and their listeners alive so that we can receive info events. 57 | let proxies = Rc::new(RefCell::new(HashMap::new())); 58 | 59 | let state = Rc::new(RefCell::new(State::new())); 60 | 61 | let _receiver = pw_receiver.attach(&mainloop, { 62 | clone!(@strong mainloop, @weak core, @weak registry, @strong state => move |msg| match msg { 63 | GtkMessage::ToggleLink { port_from, port_to } => toggle_link(port_from, port_to, &core, ®istry, &state), 64 | GtkMessage::Terminate => mainloop.quit(), 65 | }) 66 | }); 67 | 68 | let _listener = registry 69 | .add_listener_local() 70 | .global(clone!(@strong gtk_sender, @weak registry, @strong proxies, @strong state => 71 | move |global| match global.type_ { 72 | ObjectType::Node => handle_node(global, >k_sender, &state), 73 | ObjectType::Port => handle_port(global, >k_sender, &state), 74 | ObjectType::Link => handle_link(global, >k_sender, ®istry, &proxies, &state), 75 | _ => { 76 | // Other objects are not interesting to us 77 | } 78 | } 79 | )) 80 | .global_remove(clone!(@strong proxies, @strong state => move |id| { 81 | if let Some(item) = state.borrow_mut().remove(id) { 82 | gtk_sender.send(match item { 83 | Item::Node { .. } => PipewireMessage::NodeRemoved {id}, 84 | Item::Port { node_id } => PipewireMessage::PortRemoved {id, node_id}, 85 | Item::Link { .. } => PipewireMessage::LinkRemoved {id}, 86 | }).expect("Failed to send message"); 87 | } else { 88 | warn!( 89 | "Attempted to remove item with id {} that is not saved in state", 90 | id 91 | ); 92 | } 93 | 94 | proxies.borrow_mut().remove(&id); 95 | })) 96 | .register(); 97 | 98 | mainloop.run(); 99 | } 100 | 101 | /// Handle a new node being added 102 | fn handle_node( 103 | node: &GlobalObject, 104 | sender: &glib::Sender, 105 | state: &Rc>, 106 | ) { 107 | let props = node 108 | .props 109 | .as_ref() 110 | .expect("Node object is missing properties"); 111 | 112 | // Get the nicest possible name for the node, using a fallback chain of possible name attributes. 113 | let name = String::from( 114 | props 115 | .get("node.nick") 116 | .or_else(|| props.get("node.description")) 117 | .or_else(|| props.get("node.name")) 118 | .unwrap_or_default(), 119 | ); 120 | 121 | // FIXME: Instead of checking these props, the "EnumFormat" parameter should be checked instead. 122 | let media_type = props.get("media.class").and_then(|class| { 123 | if class.contains("Audio") { 124 | Some(MediaType::Audio) 125 | } else if class.contains("Video") { 126 | Some(MediaType::Video) 127 | } else if class.contains("Midi") { 128 | Some(MediaType::Midi) 129 | } else { 130 | None 131 | } 132 | }); 133 | 134 | let media_class = |class: &str| { 135 | if class.contains("Sink") || class.contains("Input") { 136 | Some(NodeType::Input) 137 | } else if class.contains("Source") || class.contains("Output") { 138 | Some(NodeType::Output) 139 | } else { 140 | None 141 | } 142 | }; 143 | 144 | let node_type = props 145 | .get("media.category") 146 | .and_then(|class| { 147 | if class.contains("Duplex") { 148 | None 149 | } else { 150 | props.get("media.class").and_then(media_class) 151 | } 152 | }) 153 | .or_else(|| props.get("media.class").and_then(media_class)); 154 | 155 | state.borrow_mut().insert( 156 | node.id, 157 | Item::Node { 158 | // widget: node_widget, 159 | media_type, 160 | }, 161 | ); 162 | 163 | sender 164 | .send(PipewireMessage::NodeAdded { 165 | id: node.id, 166 | name, 167 | node_type, 168 | }) 169 | .expect("Failed to send message"); 170 | } 171 | 172 | /// Handle a new port being added 173 | fn handle_port( 174 | port: &GlobalObject, 175 | sender: &glib::Sender, 176 | state: &Rc>, 177 | ) { 178 | let props = port 179 | .props 180 | .as_ref() 181 | .expect("Port object is missing properties"); 182 | let name = props.get("port.name").unwrap_or_default().to_string(); 183 | let node_id: u32 = props 184 | .get("node.id") 185 | .expect("Port has no node.id property!") 186 | .parse() 187 | .expect("Could not parse node.id property"); 188 | let direction = if matches!(props.get("port.direction"), Some("in")) { 189 | Direction::Input 190 | } else { 191 | Direction::Output 192 | }; 193 | 194 | // Find out the nodes media type so that the port can be colored. 195 | let media_type = if let Some(Item::Node { media_type, .. }) = state.borrow().get(node_id) { 196 | media_type.to_owned() 197 | } else { 198 | warn!("Node not found for Port {}", port.id); 199 | None 200 | }; 201 | 202 | // Save node_id so we can delete this port easily. 203 | state.borrow_mut().insert(port.id, Item::Port { node_id }); 204 | 205 | sender 206 | .send(PipewireMessage::PortAdded { 207 | id: port.id, 208 | node_id, 209 | name, 210 | direction, 211 | media_type, 212 | }) 213 | .expect("Failed to send message"); 214 | } 215 | 216 | /// Handle a new link being added 217 | fn handle_link( 218 | link: &GlobalObject, 219 | sender: &glib::Sender, 220 | registry: &Rc, 221 | proxies: &Rc>>, 222 | state: &Rc>, 223 | ) { 224 | debug!( 225 | "New link (id:{}) appeared, setting up info listener.", 226 | link.id 227 | ); 228 | 229 | let proxy: Link = registry.bind(link).expect("Failed to bind to link proxy"); 230 | let listener = proxy 231 | .add_listener_local() 232 | .info(clone!(@strong state, @strong sender => move |info| { 233 | debug!("Received link info: {:?}", info); 234 | 235 | let id = info.id(); 236 | 237 | let mut state = state.borrow_mut(); 238 | if let Some(Item::Link { .. }) = state.get(id) { 239 | // Info was an update - figure out if we should notify the gtk thread 240 | if info.change_mask().contains(LinkChangeMask::STATE) { 241 | sender.send(PipewireMessage::LinkStateChanged { 242 | id, 243 | active: matches!(info.state(), LinkState::Active) 244 | }).expect("Failed to send message"); 245 | } 246 | // TODO -- check other values that might have changed 247 | } else { 248 | // First time we get info. We can now notify the gtk thread of a new link. 249 | let node_from = info.output_node_id(); 250 | let port_from = info.output_port_id(); 251 | let node_to = info.input_node_id(); 252 | let port_to = info.input_port_id(); 253 | 254 | state.insert(id, Item::Link { 255 | port_from, port_to 256 | }); 257 | 258 | sender.send(PipewireMessage::LinkAdded { 259 | id, 260 | node_from, 261 | port_from, 262 | node_to, 263 | port_to, 264 | active: matches!(info.state(), LinkState::Active) 265 | }).expect( 266 | "Failed to send message" 267 | ); 268 | } 269 | })) 270 | .register(); 271 | 272 | proxies.borrow_mut().insert( 273 | link.id, 274 | ProxyItem::Link { 275 | _proxy: proxy, 276 | _listener: listener, 277 | }, 278 | ); 279 | } 280 | 281 | /// Toggle a link between the two specified ports. 282 | fn toggle_link( 283 | port_from: u32, 284 | port_to: u32, 285 | core: &Rc, 286 | registry: &Rc, 287 | state: &Rc>, 288 | ) { 289 | let state = state.borrow_mut(); 290 | if let Some(id) = state.get_link_id(port_from, port_to) { 291 | info!("Requesting removal of link with id {}", id); 292 | 293 | // FIXME: Handle error 294 | registry.destroy_global(id); 295 | } else { 296 | info!( 297 | "Requesting creation of link from port id:{} to port id:{}", 298 | port_from, port_to 299 | ); 300 | 301 | let node_from = state 302 | .get_node_of_port(port_from) 303 | .expect("Requested port not in state"); 304 | let node_to = state 305 | .get_node_of_port(port_to) 306 | .expect("Requested port not in state"); 307 | 308 | if let Err(e) = core.create_object::( 309 | "link-factory", 310 | &properties! { 311 | "link.output.node" => node_from.to_string(), 312 | "link.output.port" => port_from.to_string(), 313 | "link.input.node" => node_to.to_string(), 314 | "link.input.port" => port_to.to_string(), 315 | "object.linger" => "1" 316 | }, 317 | ) { 318 | warn!("Failed to create link: {}", e); 319 | } 320 | } 321 | } 322 | -------------------------------------------------------------------------------- /src/view/graph_view.rs: -------------------------------------------------------------------------------- 1 | // graph_view.rs 2 | // 3 | // Copyright 2021 Tom A. Wagner 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | 20 | use super::{Node, Port}; 21 | 22 | use gtk::{ 23 | glib::{self, clone}, 24 | graphene, gsk, 25 | prelude::*, 26 | subclass::prelude::*, 27 | }; 28 | use log::{error, warn}; 29 | 30 | use std::{cmp::Ordering, collections::HashMap}; 31 | 32 | use crate::NodeType; 33 | 34 | mod imp { 35 | use super::*; 36 | 37 | use std::{cell::RefCell, rc::Rc}; 38 | 39 | use log::warn; 40 | 41 | #[derive(Default)] 42 | pub struct GraphView { 43 | pub(super) nodes: RefCell>, 44 | /// Stores the link and whether it is currently active. 45 | pub(super) links: RefCell>, 46 | } 47 | 48 | #[glib::object_subclass] 49 | impl ObjectSubclass for GraphView { 50 | const NAME: &'static str = "GraphView"; 51 | type Type = super::GraphView; 52 | type ParentType = gtk::Widget; 53 | 54 | fn class_init(klass: &mut Self::Class) { 55 | // The layout manager determines how child widgets are laid out. 56 | klass.set_layout_manager_type::(); 57 | klass.set_css_name("graphview"); 58 | } 59 | } 60 | 61 | impl ObjectImpl for GraphView { 62 | fn constructed(&self, obj: &Self::Type) { 63 | self.parent_constructed(obj); 64 | 65 | let drag_state = Rc::new(RefCell::new(None)); 66 | let drag_controller = gtk::GestureDrag::new(); 67 | 68 | drag_controller.connect_drag_begin( 69 | clone!(@strong drag_state => move |drag_controller, x, y| { 70 | let mut drag_state = drag_state.borrow_mut(); 71 | let widget = drag_controller 72 | .widget() 73 | .expect("drag-begin event has no widget") 74 | .dynamic_cast::() 75 | .expect("drag-begin event is not on the GraphView"); 76 | // pick() should at least return the widget itself. 77 | let target = widget.pick(x, y, gtk::PickFlags::DEFAULT).expect("drag-begin pick() did not return a widget"); 78 | *drag_state = if target.ancestor(Port::static_type()).is_some() { 79 | // The user targeted a port, so the dragging should be handled by the Port 80 | // component instead of here. 81 | None 82 | } else if let Some(target) = target.ancestor(Node::static_type()) { 83 | // The user targeted a Node without targeting a specific Port. 84 | // Drag the Node around the screen. 85 | if let Some((x, y)) = widget.get_node_position(&target) { 86 | Some((target, x, y)) 87 | } else { 88 | error!("Failed to obtain position of dragged node, drag aborted."); 89 | None 90 | } 91 | } else { 92 | None 93 | } 94 | } 95 | )); 96 | drag_controller.connect_drag_update( 97 | clone!(@strong drag_state => move |drag_controller, x, y| { 98 | let widget = drag_controller 99 | .widget() 100 | .expect("drag-update event has no widget") 101 | .dynamic_cast::() 102 | .expect("drag-update event is not on the GraphView"); 103 | let drag_state = drag_state.borrow(); 104 | if let Some((ref node, x1, y1)) = *drag_state { 105 | widget.move_node(node, x1 + x as f32, y1 + y as f32); 106 | } 107 | } 108 | ), 109 | ); 110 | obj.add_controller(&drag_controller); 111 | } 112 | 113 | fn dispose(&self, _obj: &Self::Type) { 114 | self.nodes 115 | .borrow() 116 | .values() 117 | .for_each(|node| node.unparent()) 118 | } 119 | } 120 | 121 | impl WidgetImpl for GraphView { 122 | fn snapshot(&self, widget: &Self::Type, snapshot: >k::Snapshot) { 123 | /* FIXME: A lot of hardcoded values in here. 124 | Try to use relative units (em) and colours from the theme as much as possible. */ 125 | 126 | let alloc = widget.allocation(); 127 | let widget_bounds = 128 | graphene::Rect::new(0.0, 0.0, alloc.width as f32, alloc.height as f32); 129 | 130 | let background_cr = snapshot 131 | .append_cairo(&widget_bounds) 132 | .expect("Failed to get cairo context"); 133 | 134 | // Draw a nice grid on the background. 135 | background_cr.set_source_rgb(0.18, 0.18, 0.18); 136 | background_cr.set_line_width(0.2); // TODO: Set to 1px 137 | let mut y = 0.0; 138 | while y < alloc.height.into() { 139 | background_cr.move_to(0.0, y); 140 | background_cr.line_to(alloc.width.into(), y); 141 | y += 20.0; // TODO: Change to em; 142 | } 143 | let mut x = 0.0; 144 | while x < alloc.width.into() { 145 | background_cr.move_to(x, 0.0); 146 | background_cr.line_to(x, alloc.height.into()); 147 | x += 20.0; // TODO: Change to em; 148 | } 149 | if let Err(e) = background_cr.stroke() { 150 | warn!("Failed to draw graphview grid: {}", e); 151 | }; 152 | 153 | // Draw all children 154 | self.nodes 155 | .borrow() 156 | .values() 157 | .for_each(|node| self.instance().snapshot_child(node, snapshot)); 158 | 159 | // Draw all links 160 | let link_cr = snapshot 161 | .append_cairo(&graphene::Rect::new( 162 | 0.0, 163 | 0.0, 164 | alloc.width as f32, 165 | alloc.height as f32, 166 | )) 167 | .expect("Failed to get cairo context"); 168 | 169 | link_cr.set_line_width(2.0); 170 | 171 | let gtk::gdk::RGBA { 172 | red, 173 | green, 174 | blue, 175 | alpha, 176 | } = widget 177 | .style_context() 178 | .lookup_color("graphview-link") 179 | .unwrap_or(gtk::gdk::RGBA { 180 | red: 0.0, 181 | green: 0.0, 182 | blue: 0.0, 183 | alpha: 0.0, 184 | }); 185 | link_cr.set_source_rgba(red.into(), green.into(), blue.into(), alpha.into()); 186 | 187 | for (link, active) in self.links.borrow().values() { 188 | if let Some((from_x, from_y, to_x, to_y)) = self.get_link_coordinates(link) { 189 | link_cr.move_to(from_x, from_y); 190 | 191 | // Use dashed line for inactive links, full line otherwise. 192 | if *active { 193 | link_cr.set_dash(&[], 0.0); 194 | } else { 195 | link_cr.set_dash(&[10.0, 5.0], 0.0); 196 | } 197 | 198 | // If the output port is farther right than the input port and they have 199 | // a similar y coordinate, apply a y offset to the control points 200 | // so that the curve sticks out a bit. 201 | let y_control_offset = if from_x > to_x { 202 | f64::max(0.0, 25.0 - (from_y - to_y).abs()) 203 | } else { 204 | 0.0 205 | }; 206 | 207 | // Place curve control offset by half the x distance between the two points. 208 | // This makes the curve scale well for varying distances between the two ports, 209 | // especially when the output port is farther right than the input port. 210 | let half_x_dist = f64::abs(from_x - to_x) / 2.0; 211 | link_cr.curve_to( 212 | from_x + half_x_dist, 213 | from_y - y_control_offset, 214 | to_x - half_x_dist, 215 | to_y - y_control_offset, 216 | to_x, 217 | to_y, 218 | ); 219 | 220 | if let Err(e) = link_cr.stroke() { 221 | warn!("Failed to draw graphview links: {}", e); 222 | }; 223 | } else { 224 | warn!("Could not get allocation of ports of link: {:?}", link); 225 | } 226 | } 227 | } 228 | } 229 | 230 | impl GraphView { 231 | /// Get coordinates for the drawn link to start at and to end at. 232 | /// 233 | /// # Returns 234 | /// `Some((from_x, from_y, to_x, to_y))` if all objects the links refers to exist as widgets. 235 | fn get_link_coordinates(&self, link: &crate::PipewireLink) -> Option<(f64, f64, f64, f64)> { 236 | let nodes = self.nodes.borrow(); 237 | 238 | // For some reason, gtk4::WidgetExt::translate_coordinates gives me incorrect values, 239 | // so we manually calculate the needed offsets here. 240 | 241 | let from_port = &nodes.get(&link.node_from)?.get_port(link.port_from)?; 242 | let gtk::Allocation { 243 | x: mut fx, 244 | y: mut fy, 245 | width: fw, 246 | height: fh, 247 | } = from_port.allocation(); 248 | let from_node = from_port 249 | .ancestor(Node::static_type()) 250 | .expect("Port is not a child of a node"); 251 | let gtk::Allocation { x: fnx, y: fny, .. } = from_node.allocation(); 252 | fx += fnx + fw; 253 | fy += fny + (fh / 2); 254 | 255 | let to_port = &nodes.get(&link.node_to)?.get_port(link.port_to)?; 256 | let gtk::Allocation { 257 | x: mut tx, 258 | y: mut ty, 259 | height: th, 260 | .. 261 | } = to_port.allocation(); 262 | let to_node = to_port 263 | .ancestor(Node::static_type()) 264 | .expect("Port is not a child of a node"); 265 | let gtk::Allocation { x: tnx, y: tny, .. } = to_node.allocation(); 266 | tx += tnx; 267 | ty += tny + (th / 2); 268 | 269 | Some((fx.into(), fy.into(), tx.into(), ty.into())) 270 | } 271 | } 272 | } 273 | 274 | glib::wrapper! { 275 | pub struct GraphView(ObjectSubclass) 276 | @extends gtk::Widget; 277 | } 278 | 279 | impl GraphView { 280 | pub fn new() -> Self { 281 | glib::Object::new(&[]).expect("Failed to create GraphView") 282 | } 283 | 284 | pub fn add_node(&self, id: u32, node: Node, node_type: Option) { 285 | let private = imp::GraphView::from_instance(self); 286 | node.set_parent(self); 287 | 288 | // Place widgets in colums of 3, growing down 289 | let x = if let Some(node_type) = node_type { 290 | match node_type { 291 | NodeType::Output => 20.0, 292 | NodeType::Input => 820.0, 293 | } 294 | } else { 295 | 420.0 296 | }; 297 | 298 | let y = private 299 | .nodes 300 | .borrow() 301 | .values() 302 | .filter_map(|node| { 303 | // Map nodes to locations, discard nodes without location 304 | self.get_node_position(&node.clone().upcast()) 305 | }) 306 | .filter(|(x2, _)| { 307 | // Only look for other nodes that have a similar x coordinate 308 | (x - x2).abs() < 50.0 309 | }) 310 | .max_by(|y1, y2| { 311 | // Get max in column 312 | y1.partial_cmp(y2).unwrap_or(Ordering::Equal) 313 | }) 314 | .map_or(20_f32, |(_x, y)| y + 100.0); 315 | 316 | self.move_node(&node.clone().upcast(), x, y); 317 | 318 | private.nodes.borrow_mut().insert(id, node); 319 | } 320 | 321 | pub fn remove_node(&self, id: u32) { 322 | let private = imp::GraphView::from_instance(self); 323 | let mut nodes = private.nodes.borrow_mut(); 324 | if let Some(node) = nodes.remove(&id) { 325 | node.unparent(); 326 | } else { 327 | warn!("Tried to remove non-existant node (id={}) from graph", id); 328 | } 329 | } 330 | 331 | pub fn add_port(&self, node_id: u32, port_id: u32, port: crate::view::port::Port) { 332 | let private = imp::GraphView::from_instance(self); 333 | 334 | if let Some(node) = private.nodes.borrow_mut().get_mut(&node_id) { 335 | node.add_port(port_id, port); 336 | } else { 337 | error!( 338 | "Node with id {} not found when trying to add port with id {} to graph", 339 | node_id, port_id 340 | ); 341 | } 342 | } 343 | 344 | pub fn remove_port(&self, id: u32, node_id: u32) { 345 | let private = imp::GraphView::from_instance(self); 346 | let nodes = private.nodes.borrow(); 347 | if let Some(node) = nodes.get(&node_id) { 348 | node.remove_port(id); 349 | } 350 | } 351 | 352 | pub fn add_link(&self, link_id: u32, link: crate::PipewireLink, active: bool) { 353 | let private = imp::GraphView::from_instance(self); 354 | private.links.borrow_mut().insert(link_id, (link, active)); 355 | self.queue_draw(); 356 | } 357 | 358 | pub fn set_link_state(&self, link_id: u32, active: bool) { 359 | let private = imp::GraphView::from_instance(self); 360 | if let Some((_, state)) = private.links.borrow_mut().get_mut(&link_id) { 361 | *state = active; 362 | self.queue_draw(); 363 | } else { 364 | warn!("Link state changed on unknown link (id={})", link_id); 365 | } 366 | } 367 | 368 | pub fn remove_link(&self, id: u32) { 369 | let private = imp::GraphView::from_instance(self); 370 | let mut links = private.links.borrow_mut(); 371 | links.remove(&id); 372 | 373 | self.queue_draw(); 374 | } 375 | 376 | /// Get the position of the specified node inside the graphview. 377 | /// 378 | /// Returns `None` if the node is not in the graphview. 379 | pub(super) fn get_node_position(&self, node: >k::Widget) -> Option<(f32, f32)> { 380 | let layout_manager = self 381 | .layout_manager() 382 | .expect("Failed to get layout manager") 383 | .dynamic_cast::() 384 | .expect("Failed to cast to FixedLayout"); 385 | 386 | let node = layout_manager 387 | .layout_child(node)? 388 | .dynamic_cast::() 389 | .expect("Could not cast to FixedLayoutChild"); 390 | let transform = node 391 | .transform() 392 | .expect("Failed to obtain transform from layout child"); 393 | Some(transform.to_translate()) 394 | } 395 | 396 | pub(super) fn move_node(&self, node: >k::Widget, x: f32, y: f32) { 397 | let layout_manager = self 398 | .layout_manager() 399 | .expect("Failed to get layout manager") 400 | .dynamic_cast::() 401 | .expect("Failed to cast to FixedLayout"); 402 | 403 | let transform = gsk::Transform::new() 404 | // Nodes should not be able to be dragged out of the view, so we use `max(coordinate, 0.0)` to prevent that. 405 | .translate(&graphene::Point::new(f32::max(x, 0.0), f32::max(y, 0.0))) 406 | .unwrap(); 407 | 408 | layout_manager 409 | .layout_child(node) 410 | .expect("Could not get layout child") 411 | .dynamic_cast::() 412 | .expect("Could not cast to FixedLayoutChild") 413 | .set_transform(&transform); 414 | 415 | // FIXME: If links become proper widgets, 416 | // we don't need to redraw the full graph everytime. 417 | self.queue_draw(); 418 | } 419 | } 420 | 421 | impl Default for GraphView { 422 | fn default() -> Self { 423 | Self::new() 424 | } 425 | } 426 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "0.7.15" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "ansi_term" 16 | version = "0.11.0" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" 19 | dependencies = [ 20 | "winapi", 21 | ] 22 | 23 | [[package]] 24 | name = "anyhow" 25 | version = "1.0.44" 26 | source = "registry+https://github.com/rust-lang/crates.io-index" 27 | checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" 28 | 29 | [[package]] 30 | name = "arrayvec" 31 | version = "0.5.2" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" 34 | 35 | [[package]] 36 | name = "atty" 37 | version = "0.2.14" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 40 | dependencies = [ 41 | "hermit-abi", 42 | "libc", 43 | "winapi", 44 | ] 45 | 46 | [[package]] 47 | name = "autocfg" 48 | version = "1.0.1" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 51 | 52 | [[package]] 53 | name = "bindgen" 54 | version = "0.59.1" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "453c49e5950bb0eb63bb3df640e31618846c89d5b7faa54040d76e98e0134375" 57 | dependencies = [ 58 | "bitflags", 59 | "cexpr", 60 | "clang-sys", 61 | "clap", 62 | "env_logger", 63 | "lazy_static", 64 | "lazycell", 65 | "log", 66 | "peeking_take_while", 67 | "proc-macro2", 68 | "quote", 69 | "regex", 70 | "rustc-hash", 71 | "shlex", 72 | "which", 73 | ] 74 | 75 | [[package]] 76 | name = "bitflags" 77 | version = "1.3.2" 78 | source = "registry+https://github.com/rust-lang/crates.io-index" 79 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 80 | 81 | [[package]] 82 | name = "bitvec" 83 | version = "0.19.5" 84 | source = "registry+https://github.com/rust-lang/crates.io-index" 85 | checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321" 86 | dependencies = [ 87 | "funty", 88 | "radium", 89 | "tap", 90 | "wyz", 91 | ] 92 | 93 | [[package]] 94 | name = "cairo-rs" 95 | version = "0.14.7" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "9164355c892b026d6257e696dde5f3cb39beb3718297f0f161b562fe2ee3ab86" 98 | dependencies = [ 99 | "bitflags", 100 | "cairo-sys-rs", 101 | "glib", 102 | "libc", 103 | "thiserror", 104 | ] 105 | 106 | [[package]] 107 | name = "cairo-sys-rs" 108 | version = "0.14.0" 109 | source = "registry+https://github.com/rust-lang/crates.io-index" 110 | checksum = "d7c9c3928781e8a017ece15eace05230f04b647457d170d2d9641c94a444ff80" 111 | dependencies = [ 112 | "glib-sys", 113 | "libc", 114 | "system-deps 3.2.0", 115 | ] 116 | 117 | [[package]] 118 | name = "cc" 119 | version = "1.0.70" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" 122 | 123 | [[package]] 124 | name = "cexpr" 125 | version = "0.5.0" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | checksum = "db507a7679252d2276ed0dd8113c6875ec56d3089f9225b2b42c30cc1f8e5c89" 128 | dependencies = [ 129 | "nom", 130 | ] 131 | 132 | [[package]] 133 | name = "cfg-expr" 134 | version = "0.8.1" 135 | source = "registry+https://github.com/rust-lang/crates.io-index" 136 | checksum = "b412e83326147c2bb881f8b40edfbf9905b9b8abaebd0e47ca190ba62fda8f0e" 137 | dependencies = [ 138 | "smallvec", 139 | ] 140 | 141 | [[package]] 142 | name = "cfg-expr" 143 | version = "0.9.0" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "edae0b9625d1fce32f7d64b71784d9b1bf8469ec1a9c417e44aaf16a9cbd7571" 146 | dependencies = [ 147 | "smallvec", 148 | ] 149 | 150 | [[package]] 151 | name = "cfg-if" 152 | version = "0.1.10" 153 | source = "registry+https://github.com/rust-lang/crates.io-index" 154 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 155 | 156 | [[package]] 157 | name = "cfg-if" 158 | version = "1.0.0" 159 | source = "registry+https://github.com/rust-lang/crates.io-index" 160 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 161 | 162 | [[package]] 163 | name = "clang-sys" 164 | version = "1.2.2" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | checksum = "10612c0ec0e0a1ff0e97980647cb058a6e7aedb913d01d009c406b8b7d0b26ee" 167 | dependencies = [ 168 | "glob", 169 | "libc", 170 | "libloading", 171 | ] 172 | 173 | [[package]] 174 | name = "clap" 175 | version = "2.33.3" 176 | source = "registry+https://github.com/rust-lang/crates.io-index" 177 | checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" 178 | dependencies = [ 179 | "ansi_term", 180 | "atty", 181 | "bitflags", 182 | "strsim", 183 | "textwrap", 184 | "unicode-width", 185 | "vec_map", 186 | ] 187 | 188 | [[package]] 189 | name = "cookie-factory" 190 | version = "0.3.2" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "396de984970346b0d9e93d1415082923c679e5ae5c3ee3dcbd104f5610af126b" 193 | 194 | [[package]] 195 | name = "either" 196 | version = "1.6.1" 197 | source = "registry+https://github.com/rust-lang/crates.io-index" 198 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 199 | 200 | [[package]] 201 | name = "env_logger" 202 | version = "0.8.4" 203 | source = "registry+https://github.com/rust-lang/crates.io-index" 204 | checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" 205 | dependencies = [ 206 | "atty", 207 | "humantime", 208 | "log", 209 | "regex", 210 | "termcolor", 211 | ] 212 | 213 | [[package]] 214 | name = "errno" 215 | version = "0.2.7" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" 218 | dependencies = [ 219 | "errno-dragonfly", 220 | "libc", 221 | "winapi", 222 | ] 223 | 224 | [[package]] 225 | name = "errno-dragonfly" 226 | version = "0.1.2" 227 | source = "registry+https://github.com/rust-lang/crates.io-index" 228 | checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" 229 | dependencies = [ 230 | "cc", 231 | "libc", 232 | ] 233 | 234 | [[package]] 235 | name = "field-offset" 236 | version = "0.3.4" 237 | source = "registry+https://github.com/rust-lang/crates.io-index" 238 | checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92" 239 | dependencies = [ 240 | "memoffset", 241 | "rustc_version", 242 | ] 243 | 244 | [[package]] 245 | name = "funty" 246 | version = "1.1.0" 247 | source = "registry+https://github.com/rust-lang/crates.io-index" 248 | checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" 249 | 250 | [[package]] 251 | name = "futures-channel" 252 | version = "0.3.17" 253 | source = "registry+https://github.com/rust-lang/crates.io-index" 254 | checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" 255 | dependencies = [ 256 | "futures-core", 257 | ] 258 | 259 | [[package]] 260 | name = "futures-core" 261 | version = "0.3.17" 262 | source = "registry+https://github.com/rust-lang/crates.io-index" 263 | checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" 264 | 265 | [[package]] 266 | name = "futures-executor" 267 | version = "0.3.17" 268 | source = "registry+https://github.com/rust-lang/crates.io-index" 269 | checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" 270 | dependencies = [ 271 | "futures-core", 272 | "futures-task", 273 | "futures-util", 274 | ] 275 | 276 | [[package]] 277 | name = "futures-io" 278 | version = "0.3.17" 279 | source = "registry+https://github.com/rust-lang/crates.io-index" 280 | checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" 281 | 282 | [[package]] 283 | name = "futures-task" 284 | version = "0.3.17" 285 | source = "registry+https://github.com/rust-lang/crates.io-index" 286 | checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" 287 | 288 | [[package]] 289 | name = "futures-util" 290 | version = "0.3.17" 291 | source = "registry+https://github.com/rust-lang/crates.io-index" 292 | checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" 293 | dependencies = [ 294 | "autocfg", 295 | "futures-core", 296 | "futures-task", 297 | "pin-project-lite", 298 | "pin-utils", 299 | "slab", 300 | ] 301 | 302 | [[package]] 303 | name = "gdk-pixbuf" 304 | version = "0.14.0" 305 | source = "registry+https://github.com/rust-lang/crates.io-index" 306 | checksum = "534192cb8f01daeb8fab2c8d4baa8f9aae5b7a39130525779f5c2608e235b10f" 307 | dependencies = [ 308 | "gdk-pixbuf-sys", 309 | "gio", 310 | "glib", 311 | "libc", 312 | ] 313 | 314 | [[package]] 315 | name = "gdk-pixbuf-sys" 316 | version = "0.14.0" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "f097c0704201fbc8f69c1762dc58c6947c8bb188b8ed0bc7e65259f1894fe590" 319 | dependencies = [ 320 | "gio-sys", 321 | "glib-sys", 322 | "gobject-sys", 323 | "libc", 324 | "system-deps 3.2.0", 325 | ] 326 | 327 | [[package]] 328 | name = "gdk4" 329 | version = "0.3.0" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "4c0f7f98ad25b81ac9462f74a091b0e4c0983ed1e74d19a38230c772b4dcef81" 332 | dependencies = [ 333 | "bitflags", 334 | "cairo-rs", 335 | "gdk-pixbuf", 336 | "gdk4-sys", 337 | "gio", 338 | "glib", 339 | "libc", 340 | "pango", 341 | ] 342 | 343 | [[package]] 344 | name = "gdk4-sys" 345 | version = "0.3.0" 346 | source = "registry+https://github.com/rust-lang/crates.io-index" 347 | checksum = "262a79666b42e1884577f11a050439a964b95dec55343ac6ace7930e1415fa18" 348 | dependencies = [ 349 | "cairo-sys-rs", 350 | "gdk-pixbuf-sys", 351 | "gio-sys", 352 | "glib-sys", 353 | "gobject-sys", 354 | "graphene-sys", 355 | "libc", 356 | "pango-sys", 357 | "system-deps 4.0.0", 358 | ] 359 | 360 | [[package]] 361 | name = "gio" 362 | version = "0.14.6" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "f3a29d8062af72045518271a2cd98b4e1617ce43f5b4223ad0fb9a0eff8f718c" 365 | dependencies = [ 366 | "bitflags", 367 | "futures-channel", 368 | "futures-core", 369 | "futures-io", 370 | "gio-sys", 371 | "glib", 372 | "libc", 373 | "once_cell", 374 | "thiserror", 375 | ] 376 | 377 | [[package]] 378 | name = "gio-sys" 379 | version = "0.14.0" 380 | source = "registry+https://github.com/rust-lang/crates.io-index" 381 | checksum = "c0a41df66e57fcc287c4bcf74fc26b884f31901ea9792ec75607289b456f48fa" 382 | dependencies = [ 383 | "glib-sys", 384 | "gobject-sys", 385 | "libc", 386 | "system-deps 3.2.0", 387 | "winapi", 388 | ] 389 | 390 | [[package]] 391 | name = "glib" 392 | version = "0.14.5" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | checksum = "d4a930b7208e6e0ab839eea5f65ac2b82109f729621430d47fe905e2e09d33f4" 395 | dependencies = [ 396 | "bitflags", 397 | "futures-channel", 398 | "futures-core", 399 | "futures-executor", 400 | "futures-task", 401 | "glib-macros", 402 | "glib-sys", 403 | "gobject-sys", 404 | "libc", 405 | "log", 406 | "once_cell", 407 | "smallvec", 408 | ] 409 | 410 | [[package]] 411 | name = "glib-macros" 412 | version = "0.14.1" 413 | source = "registry+https://github.com/rust-lang/crates.io-index" 414 | checksum = "2aad66361f66796bfc73f530c51ef123970eb895ffba991a234fcf7bea89e518" 415 | dependencies = [ 416 | "anyhow", 417 | "heck", 418 | "proc-macro-crate", 419 | "proc-macro-error", 420 | "proc-macro2", 421 | "quote", 422 | "syn", 423 | ] 424 | 425 | [[package]] 426 | name = "glib-sys" 427 | version = "0.14.0" 428 | source = "registry+https://github.com/rust-lang/crates.io-index" 429 | checksum = "1c1d60554a212445e2a858e42a0e48cece1bd57b311a19a9468f70376cf554ae" 430 | dependencies = [ 431 | "libc", 432 | "system-deps 3.2.0", 433 | ] 434 | 435 | [[package]] 436 | name = "glob" 437 | version = "0.3.0" 438 | source = "registry+https://github.com/rust-lang/crates.io-index" 439 | checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" 440 | 441 | [[package]] 442 | name = "gobject-sys" 443 | version = "0.14.0" 444 | source = "registry+https://github.com/rust-lang/crates.io-index" 445 | checksum = "aa92cae29759dae34ab5921d73fff5ad54b3d794ab842c117e36cafc7994c3f5" 446 | dependencies = [ 447 | "glib-sys", 448 | "libc", 449 | "system-deps 3.2.0", 450 | ] 451 | 452 | [[package]] 453 | name = "graphene-rs" 454 | version = "0.14.0" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "f1460a39f06e491e6112f27e71e51435c833ba370723224dd1743dfd1f201f19" 457 | dependencies = [ 458 | "glib", 459 | "graphene-sys", 460 | "libc", 461 | ] 462 | 463 | [[package]] 464 | name = "graphene-sys" 465 | version = "0.14.0" 466 | source = "registry+https://github.com/rust-lang/crates.io-index" 467 | checksum = "e7d23fb7a9547e5f072a7e0cd49cd648fedeb786d122b106217511980cbb8962" 468 | dependencies = [ 469 | "glib-sys", 470 | "libc", 471 | "pkg-config", 472 | "system-deps 3.2.0", 473 | ] 474 | 475 | [[package]] 476 | name = "gsk4" 477 | version = "0.3.0" 478 | source = "registry+https://github.com/rust-lang/crates.io-index" 479 | checksum = "20b71f2e2cc699c2e0fbfa22899eeaffd84f9c1dc01e9263deac8664eec22dc0" 480 | dependencies = [ 481 | "bitflags", 482 | "cairo-rs", 483 | "gdk4", 484 | "glib", 485 | "graphene-rs", 486 | "gsk4-sys", 487 | "libc", 488 | "pango", 489 | ] 490 | 491 | [[package]] 492 | name = "gsk4-sys" 493 | version = "0.3.0" 494 | source = "registry+https://github.com/rust-lang/crates.io-index" 495 | checksum = "30468aff80e4faadf22f9ba164ea17511a69a9995d7a13827a13424ef47b2472" 496 | dependencies = [ 497 | "cairo-sys-rs", 498 | "gdk4-sys", 499 | "glib-sys", 500 | "gobject-sys", 501 | "graphene-sys", 502 | "libc", 503 | "pango-sys", 504 | "system-deps 4.0.0", 505 | ] 506 | 507 | [[package]] 508 | name = "gtk4" 509 | version = "0.3.0" 510 | source = "registry+https://github.com/rust-lang/crates.io-index" 511 | checksum = "906f9308d15789d96a736881582181d710ae0937197119df459f3d2b46ef6776" 512 | dependencies = [ 513 | "bitflags", 514 | "cairo-rs", 515 | "field-offset", 516 | "futures-channel", 517 | "gdk-pixbuf", 518 | "gdk4", 519 | "gio", 520 | "glib", 521 | "graphene-rs", 522 | "gsk4", 523 | "gtk4-macros", 524 | "gtk4-sys", 525 | "libc", 526 | "once_cell", 527 | "pango", 528 | ] 529 | 530 | [[package]] 531 | name = "gtk4-macros" 532 | version = "0.3.0" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "4d0d008cdf23214c697482415dd20f666bdf3cc9f5e803b017223c17c5b59a6e" 535 | dependencies = [ 536 | "anyhow", 537 | "heck", 538 | "itertools", 539 | "proc-macro-crate", 540 | "proc-macro-error", 541 | "proc-macro2", 542 | "quote", 543 | "syn", 544 | ] 545 | 546 | [[package]] 547 | name = "gtk4-sys" 548 | version = "0.3.0" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "d06be0a6322aa77dd372f726e97efbcbb192d9a824a414a8874f238effd7747c" 551 | dependencies = [ 552 | "cairo-sys-rs", 553 | "gdk-pixbuf-sys", 554 | "gdk4-sys", 555 | "gio-sys", 556 | "glib-sys", 557 | "gobject-sys", 558 | "graphene-sys", 559 | "gsk4-sys", 560 | "libc", 561 | "pango-sys", 562 | "system-deps 4.0.0", 563 | ] 564 | 565 | [[package]] 566 | name = "heck" 567 | version = "0.3.3" 568 | source = "registry+https://github.com/rust-lang/crates.io-index" 569 | checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" 570 | dependencies = [ 571 | "unicode-segmentation", 572 | ] 573 | 574 | [[package]] 575 | name = "helvum" 576 | version = "0.3.2" 577 | dependencies = [ 578 | "glib", 579 | "gtk4", 580 | "log", 581 | "once_cell", 582 | "pipewire", 583 | ] 584 | 585 | [[package]] 586 | name = "hermit-abi" 587 | version = "0.1.19" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 590 | dependencies = [ 591 | "libc", 592 | ] 593 | 594 | [[package]] 595 | name = "humantime" 596 | version = "2.1.0" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" 599 | 600 | [[package]] 601 | name = "itertools" 602 | version = "0.10.1" 603 | source = "registry+https://github.com/rust-lang/crates.io-index" 604 | checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" 605 | dependencies = [ 606 | "either", 607 | ] 608 | 609 | [[package]] 610 | name = "lazy_static" 611 | version = "1.4.0" 612 | source = "registry+https://github.com/rust-lang/crates.io-index" 613 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 614 | 615 | [[package]] 616 | name = "lazycell" 617 | version = "1.3.0" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" 620 | 621 | [[package]] 622 | name = "lexical-core" 623 | version = "0.7.6" 624 | source = "registry+https://github.com/rust-lang/crates.io-index" 625 | checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" 626 | dependencies = [ 627 | "arrayvec", 628 | "bitflags", 629 | "cfg-if 1.0.0", 630 | "ryu", 631 | "static_assertions", 632 | ] 633 | 634 | [[package]] 635 | name = "libc" 636 | version = "0.2.103" 637 | source = "registry+https://github.com/rust-lang/crates.io-index" 638 | checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" 639 | 640 | [[package]] 641 | name = "libloading" 642 | version = "0.7.0" 643 | source = "registry+https://github.com/rust-lang/crates.io-index" 644 | checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" 645 | dependencies = [ 646 | "cfg-if 1.0.0", 647 | "winapi", 648 | ] 649 | 650 | [[package]] 651 | name = "libspa" 652 | version = "0.4.1" 653 | source = "registry+https://github.com/rust-lang/crates.io-index" 654 | checksum = "aeb373e8b03740369c5fe48a557c6408b6898982d57e17940de144375d472743" 655 | dependencies = [ 656 | "bitflags", 657 | "cc", 658 | "cookie-factory", 659 | "errno", 660 | "libc", 661 | "libspa-sys", 662 | "nom", 663 | "system-deps 3.2.0", 664 | ] 665 | 666 | [[package]] 667 | name = "libspa-sys" 668 | version = "0.4.1" 669 | source = "registry+https://github.com/rust-lang/crates.io-index" 670 | checksum = "d301a2fc2fed0a97c13836408a4d98f419af0c2695ecf74e634a214c17beefa6" 671 | dependencies = [ 672 | "bindgen", 673 | "system-deps 3.2.0", 674 | ] 675 | 676 | [[package]] 677 | name = "log" 678 | version = "0.4.14" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 681 | dependencies = [ 682 | "cfg-if 1.0.0", 683 | ] 684 | 685 | [[package]] 686 | name = "memchr" 687 | version = "2.3.4" 688 | source = "registry+https://github.com/rust-lang/crates.io-index" 689 | checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" 690 | 691 | [[package]] 692 | name = "memoffset" 693 | version = "0.6.4" 694 | source = "registry+https://github.com/rust-lang/crates.io-index" 695 | checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" 696 | dependencies = [ 697 | "autocfg", 698 | ] 699 | 700 | [[package]] 701 | name = "nix" 702 | version = "0.14.1" 703 | source = "registry+https://github.com/rust-lang/crates.io-index" 704 | checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" 705 | dependencies = [ 706 | "bitflags", 707 | "cc", 708 | "cfg-if 0.1.10", 709 | "libc", 710 | "void", 711 | ] 712 | 713 | [[package]] 714 | name = "nom" 715 | version = "6.2.1" 716 | source = "registry+https://github.com/rust-lang/crates.io-index" 717 | checksum = "9c5c51b9083a3c620fa67a2a635d1ce7d95b897e957d6b28ff9a5da960a103a6" 718 | dependencies = [ 719 | "bitvec", 720 | "funty", 721 | "lexical-core", 722 | "memchr", 723 | "version_check", 724 | ] 725 | 726 | [[package]] 727 | name = "once_cell" 728 | version = "1.8.0" 729 | source = "registry+https://github.com/rust-lang/crates.io-index" 730 | checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" 731 | 732 | [[package]] 733 | name = "pango" 734 | version = "0.14.3" 735 | source = "registry+https://github.com/rust-lang/crates.io-index" 736 | checksum = "e1fc88307d9797976ea62722ff2ec5de3fae279c6e20100ed3f49ca1a4bf3f96" 737 | dependencies = [ 738 | "bitflags", 739 | "glib", 740 | "libc", 741 | "once_cell", 742 | "pango-sys", 743 | ] 744 | 745 | [[package]] 746 | name = "pango-sys" 747 | version = "0.14.0" 748 | source = "registry+https://github.com/rust-lang/crates.io-index" 749 | checksum = "2367099ca5e761546ba1d501955079f097caa186bb53ce0f718dca99ac1942fe" 750 | dependencies = [ 751 | "glib-sys", 752 | "gobject-sys", 753 | "libc", 754 | "system-deps 3.2.0", 755 | ] 756 | 757 | [[package]] 758 | name = "peeking_take_while" 759 | version = "0.1.2" 760 | source = "registry+https://github.com/rust-lang/crates.io-index" 761 | checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" 762 | 763 | [[package]] 764 | name = "pest" 765 | version = "2.1.3" 766 | source = "registry+https://github.com/rust-lang/crates.io-index" 767 | checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" 768 | dependencies = [ 769 | "ucd-trie", 770 | ] 771 | 772 | [[package]] 773 | name = "pin-project-lite" 774 | version = "0.2.7" 775 | source = "registry+https://github.com/rust-lang/crates.io-index" 776 | checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" 777 | 778 | [[package]] 779 | name = "pin-utils" 780 | version = "0.1.0" 781 | source = "registry+https://github.com/rust-lang/crates.io-index" 782 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 783 | 784 | [[package]] 785 | name = "pipewire" 786 | version = "0.4.1" 787 | source = "registry+https://github.com/rust-lang/crates.io-index" 788 | checksum = "5de050d879e7b8d9313429ec314b88b26fe48ba29a6ecc3bc8289d3673fee6c8" 789 | dependencies = [ 790 | "anyhow", 791 | "bitflags", 792 | "errno", 793 | "libc", 794 | "libspa", 795 | "libspa-sys", 796 | "once_cell", 797 | "pipewire-sys", 798 | "signal", 799 | "thiserror", 800 | ] 801 | 802 | [[package]] 803 | name = "pipewire-sys" 804 | version = "0.4.1" 805 | source = "registry+https://github.com/rust-lang/crates.io-index" 806 | checksum = "9b4aa5ef9f3afef7dbb335106f69bd6bb541259e8796c693810cde20db1eb949" 807 | dependencies = [ 808 | "bindgen", 809 | "libspa-sys", 810 | "system-deps 3.2.0", 811 | ] 812 | 813 | [[package]] 814 | name = "pkg-config" 815 | version = "0.3.20" 816 | source = "registry+https://github.com/rust-lang/crates.io-index" 817 | checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb" 818 | 819 | [[package]] 820 | name = "proc-macro-crate" 821 | version = "1.1.0" 822 | source = "registry+https://github.com/rust-lang/crates.io-index" 823 | checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83" 824 | dependencies = [ 825 | "thiserror", 826 | "toml", 827 | ] 828 | 829 | [[package]] 830 | name = "proc-macro-error" 831 | version = "1.0.4" 832 | source = "registry+https://github.com/rust-lang/crates.io-index" 833 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 834 | dependencies = [ 835 | "proc-macro-error-attr", 836 | "proc-macro2", 837 | "quote", 838 | "syn", 839 | "version_check", 840 | ] 841 | 842 | [[package]] 843 | name = "proc-macro-error-attr" 844 | version = "1.0.4" 845 | source = "registry+https://github.com/rust-lang/crates.io-index" 846 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 847 | dependencies = [ 848 | "proc-macro2", 849 | "quote", 850 | "version_check", 851 | ] 852 | 853 | [[package]] 854 | name = "proc-macro2" 855 | version = "1.0.29" 856 | source = "registry+https://github.com/rust-lang/crates.io-index" 857 | checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" 858 | dependencies = [ 859 | "unicode-xid", 860 | ] 861 | 862 | [[package]] 863 | name = "quote" 864 | version = "1.0.9" 865 | source = "registry+https://github.com/rust-lang/crates.io-index" 866 | checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" 867 | dependencies = [ 868 | "proc-macro2", 869 | ] 870 | 871 | [[package]] 872 | name = "radium" 873 | version = "0.5.3" 874 | source = "registry+https://github.com/rust-lang/crates.io-index" 875 | checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" 876 | 877 | [[package]] 878 | name = "regex" 879 | version = "1.4.6" 880 | source = "registry+https://github.com/rust-lang/crates.io-index" 881 | checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" 882 | dependencies = [ 883 | "aho-corasick", 884 | "memchr", 885 | "regex-syntax", 886 | ] 887 | 888 | [[package]] 889 | name = "regex-syntax" 890 | version = "0.6.25" 891 | source = "registry+https://github.com/rust-lang/crates.io-index" 892 | checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" 893 | 894 | [[package]] 895 | name = "rustc-hash" 896 | version = "1.1.0" 897 | source = "registry+https://github.com/rust-lang/crates.io-index" 898 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 899 | 900 | [[package]] 901 | name = "rustc_version" 902 | version = "0.3.3" 903 | source = "registry+https://github.com/rust-lang/crates.io-index" 904 | checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" 905 | dependencies = [ 906 | "semver", 907 | ] 908 | 909 | [[package]] 910 | name = "ryu" 911 | version = "1.0.5" 912 | source = "registry+https://github.com/rust-lang/crates.io-index" 913 | checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" 914 | 915 | [[package]] 916 | name = "semver" 917 | version = "0.11.0" 918 | source = "registry+https://github.com/rust-lang/crates.io-index" 919 | checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" 920 | dependencies = [ 921 | "semver-parser", 922 | ] 923 | 924 | [[package]] 925 | name = "semver-parser" 926 | version = "0.10.2" 927 | source = "registry+https://github.com/rust-lang/crates.io-index" 928 | checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" 929 | dependencies = [ 930 | "pest", 931 | ] 932 | 933 | [[package]] 934 | name = "serde" 935 | version = "1.0.130" 936 | source = "registry+https://github.com/rust-lang/crates.io-index" 937 | checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" 938 | 939 | [[package]] 940 | name = "shlex" 941 | version = "1.1.0" 942 | source = "registry+https://github.com/rust-lang/crates.io-index" 943 | checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" 944 | 945 | [[package]] 946 | name = "signal" 947 | version = "0.7.0" 948 | source = "registry+https://github.com/rust-lang/crates.io-index" 949 | checksum = "2f6ce83b159ab6984d2419f495134972b48754d13ff2e3f8c998339942b56ed9" 950 | dependencies = [ 951 | "libc", 952 | "nix", 953 | ] 954 | 955 | [[package]] 956 | name = "slab" 957 | version = "0.4.4" 958 | source = "registry+https://github.com/rust-lang/crates.io-index" 959 | checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" 960 | 961 | [[package]] 962 | name = "smallvec" 963 | version = "1.7.0" 964 | source = "registry+https://github.com/rust-lang/crates.io-index" 965 | checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" 966 | 967 | [[package]] 968 | name = "static_assertions" 969 | version = "1.1.0" 970 | source = "registry+https://github.com/rust-lang/crates.io-index" 971 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 972 | 973 | [[package]] 974 | name = "strsim" 975 | version = "0.8.0" 976 | source = "registry+https://github.com/rust-lang/crates.io-index" 977 | checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 978 | 979 | [[package]] 980 | name = "strum" 981 | version = "0.21.0" 982 | source = "registry+https://github.com/rust-lang/crates.io-index" 983 | checksum = "aaf86bbcfd1fa9670b7a129f64fc0c9fcbbfe4f1bc4210e9e98fe71ffc12cde2" 984 | 985 | [[package]] 986 | name = "strum_macros" 987 | version = "0.21.1" 988 | source = "registry+https://github.com/rust-lang/crates.io-index" 989 | checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec" 990 | dependencies = [ 991 | "heck", 992 | "proc-macro2", 993 | "quote", 994 | "syn", 995 | ] 996 | 997 | [[package]] 998 | name = "syn" 999 | version = "1.0.77" 1000 | source = "registry+https://github.com/rust-lang/crates.io-index" 1001 | checksum = "5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0" 1002 | dependencies = [ 1003 | "proc-macro2", 1004 | "quote", 1005 | "unicode-xid", 1006 | ] 1007 | 1008 | [[package]] 1009 | name = "system-deps" 1010 | version = "3.2.0" 1011 | source = "registry+https://github.com/rust-lang/crates.io-index" 1012 | checksum = "480c269f870722b3b08d2f13053ce0c2ab722839f472863c3e2d61ff3a1c2fa6" 1013 | dependencies = [ 1014 | "anyhow", 1015 | "cfg-expr 0.8.1", 1016 | "heck", 1017 | "itertools", 1018 | "pkg-config", 1019 | "strum", 1020 | "strum_macros", 1021 | "thiserror", 1022 | "toml", 1023 | "version-compare", 1024 | ] 1025 | 1026 | [[package]] 1027 | name = "system-deps" 1028 | version = "4.0.0" 1029 | source = "registry+https://github.com/rust-lang/crates.io-index" 1030 | checksum = "6c1889ab44c2a423ba9ba4d64cd04989b25c0280ca7ade813f05368418722a04" 1031 | dependencies = [ 1032 | "cfg-expr 0.9.0", 1033 | "heck", 1034 | "pkg-config", 1035 | "toml", 1036 | "version-compare", 1037 | ] 1038 | 1039 | [[package]] 1040 | name = "tap" 1041 | version = "1.0.1" 1042 | source = "registry+https://github.com/rust-lang/crates.io-index" 1043 | checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" 1044 | 1045 | [[package]] 1046 | name = "termcolor" 1047 | version = "1.1.2" 1048 | source = "registry+https://github.com/rust-lang/crates.io-index" 1049 | checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" 1050 | dependencies = [ 1051 | "winapi-util", 1052 | ] 1053 | 1054 | [[package]] 1055 | name = "textwrap" 1056 | version = "0.11.0" 1057 | source = "registry+https://github.com/rust-lang/crates.io-index" 1058 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 1059 | dependencies = [ 1060 | "unicode-width", 1061 | ] 1062 | 1063 | [[package]] 1064 | name = "thiserror" 1065 | version = "1.0.29" 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" 1067 | checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" 1068 | dependencies = [ 1069 | "thiserror-impl", 1070 | ] 1071 | 1072 | [[package]] 1073 | name = "thiserror-impl" 1074 | version = "1.0.29" 1075 | source = "registry+https://github.com/rust-lang/crates.io-index" 1076 | checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" 1077 | dependencies = [ 1078 | "proc-macro2", 1079 | "quote", 1080 | "syn", 1081 | ] 1082 | 1083 | [[package]] 1084 | name = "toml" 1085 | version = "0.5.8" 1086 | source = "registry+https://github.com/rust-lang/crates.io-index" 1087 | checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" 1088 | dependencies = [ 1089 | "serde", 1090 | ] 1091 | 1092 | [[package]] 1093 | name = "ucd-trie" 1094 | version = "0.1.3" 1095 | source = "registry+https://github.com/rust-lang/crates.io-index" 1096 | checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" 1097 | 1098 | [[package]] 1099 | name = "unicode-segmentation" 1100 | version = "1.8.0" 1101 | source = "registry+https://github.com/rust-lang/crates.io-index" 1102 | checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" 1103 | 1104 | [[package]] 1105 | name = "unicode-width" 1106 | version = "0.1.9" 1107 | source = "registry+https://github.com/rust-lang/crates.io-index" 1108 | checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" 1109 | 1110 | [[package]] 1111 | name = "unicode-xid" 1112 | version = "0.2.2" 1113 | source = "registry+https://github.com/rust-lang/crates.io-index" 1114 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 1115 | 1116 | [[package]] 1117 | name = "vec_map" 1118 | version = "0.8.2" 1119 | source = "registry+https://github.com/rust-lang/crates.io-index" 1120 | checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" 1121 | 1122 | [[package]] 1123 | name = "version-compare" 1124 | version = "0.0.11" 1125 | source = "registry+https://github.com/rust-lang/crates.io-index" 1126 | checksum = "1c18c859eead79d8b95d09e4678566e8d70105c4e7b251f707a03df32442661b" 1127 | 1128 | [[package]] 1129 | name = "version_check" 1130 | version = "0.9.3" 1131 | source = "registry+https://github.com/rust-lang/crates.io-index" 1132 | checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" 1133 | 1134 | [[package]] 1135 | name = "void" 1136 | version = "1.0.2" 1137 | source = "registry+https://github.com/rust-lang/crates.io-index" 1138 | checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 1139 | 1140 | [[package]] 1141 | name = "which" 1142 | version = "3.1.1" 1143 | source = "registry+https://github.com/rust-lang/crates.io-index" 1144 | checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" 1145 | dependencies = [ 1146 | "libc", 1147 | ] 1148 | 1149 | [[package]] 1150 | name = "winapi" 1151 | version = "0.3.9" 1152 | source = "registry+https://github.com/rust-lang/crates.io-index" 1153 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1154 | dependencies = [ 1155 | "winapi-i686-pc-windows-gnu", 1156 | "winapi-x86_64-pc-windows-gnu", 1157 | ] 1158 | 1159 | [[package]] 1160 | name = "winapi-i686-pc-windows-gnu" 1161 | version = "0.4.0" 1162 | source = "registry+https://github.com/rust-lang/crates.io-index" 1163 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1164 | 1165 | [[package]] 1166 | name = "winapi-util" 1167 | version = "0.1.5" 1168 | source = "registry+https://github.com/rust-lang/crates.io-index" 1169 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 1170 | dependencies = [ 1171 | "winapi", 1172 | ] 1173 | 1174 | [[package]] 1175 | name = "winapi-x86_64-pc-windows-gnu" 1176 | version = "0.4.0" 1177 | source = "registry+https://github.com/rust-lang/crates.io-index" 1178 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1179 | 1180 | [[package]] 1181 | name = "wyz" 1182 | version = "0.2.0" 1183 | source = "registry+https://github.com/rust-lang/crates.io-index" 1184 | checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" 1185 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------