graph: Refactor graph item management into new graph_manager object

The graph widgets management (watching a glib receiver, adding and removing
Nodes, Ports and Links) currently done in the `Application` and `GraphView`
objects has been extracted into a new GraphManager object, which watches the
receiver instead, pushes changes directly to the widgets, and reacts to their signals.

This seperates widget logic and management logic cleanly instead of both
being mixed into the GraphView, and also reduces the code size for the
Application object.
This commit is contained in:
Tom A. Wagner
2023-08-01 08:50:51 +02:00
parent a9ad1cccf0
commit 0b3b124cdf
6 changed files with 342 additions and 243 deletions

View File

@@ -15,6 +15,7 @@
// SPDX-License-Identifier: GPL-3.0-only
mod application;
mod graph_manager;
mod pipewire_connection;
mod ui;
@@ -24,7 +25,7 @@ use pipewire::spa::Direction;
/// Messages sent by the GTK thread to notify the pipewire thread.
#[derive(Debug, Clone)]
enum GtkMessage {
pub enum GtkMessage {
/// Toggle a link between the two specified ports.
ToggleLink { port_from: u32, port_to: u32 },
/// Quit the event loop and let the thread finish.
@@ -33,7 +34,7 @@ enum GtkMessage {
/// Messages sent by the pipewire thread to notify the GTK thread.
#[derive(Debug, Clone)]
enum PipewireMessage {
pub enum PipewireMessage {
NodeAdded {
id: u32,
name: String,
@@ -48,9 +49,7 @@ enum PipewireMessage {
},
LinkAdded {
id: u32,
node_from: u32,
port_from: u32,
node_to: u32,
port_to: u32,
active: bool,
},