Skip to content

Commit

Permalink
Merge pull request #100 from Xetibo/dashie
Browse files Browse the repository at this point in the history
feat: Dynamic sidebars
  • Loading branch information
takotori authored Apr 11, 2024
2 parents a7489f7 + 2324814 commit ee31829
Show file tree
Hide file tree
Showing 42 changed files with 368 additions and 208 deletions.
4 changes: 2 additions & 2 deletions better_test_plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub const INTERFACE: &str = "org.Xetibo.ReSet.TestPlugin";
#[allow(improper_ctypes_definitions)]
pub extern "C" fn capabilities() -> PluginCapabilities {
println!("frontend capabilities called");
PluginCapabilities::new(vec!["frontend test"], PluginImplementation::Frontend)
PluginCapabilities::new(vec!["test"], PluginImplementation::Frontend)
}

#[no_mangle]
Expand Down Expand Up @@ -81,4 +81,4 @@ pub struct LabelWrapper {

unsafe impl Send for LabelWrapper {}

unsafe impl Sync for LabelWrapper {}
unsafe impl Sync for LabelWrapper {}
103 changes: 45 additions & 58 deletions flatpak/cargo-sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,14 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/glib/glib-0.18.4.crate",
"sha256": "951bbd7fdc5c044ede9f05170f05a3ae9479239c3afdfe2d22d537a3add15c4e",
"dest": "cargo/vendor/glib-0.18.4"
"url": "https://static.crates.io/crates/glib/glib-0.18.3.crate",
"sha256": "58cf801b6f7829fa76db37449ab67c9c98a2b1bf21076d9113225621e61a0fa6",
"dest": "cargo/vendor/glib-0.18.3"
},
{
"type": "inline",
"contents": "{\"package\": \"951bbd7fdc5c044ede9f05170f05a3ae9479239c3afdfe2d22d537a3add15c4e\", \"files\": {}}",
"dest": "cargo/vendor/glib-0.18.4",
"contents": "{\"package\": \"58cf801b6f7829fa76db37449ab67c9c98a2b1bf21076d9113225621e61a0fa6\", \"files\": {}}",
"dest": "cargo/vendor/glib-0.18.3",
"dest-filename": ".cargo-checksum.json"
},
{
Expand Down Expand Up @@ -886,14 +886,14 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/mio/mio-0.8.9.crate",
"sha256": "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0",
"dest": "cargo/vendor/mio-0.8.9"
"url": "https://static.crates.io/crates/mio/mio-0.8.10.crate",
"sha256": "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09",
"dest": "cargo/vendor/mio-0.8.10"
},
{
"type": "inline",
"contents": "{\"package\": \"3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0\", \"files\": {}}",
"dest": "cargo/vendor/mio-0.8.9",
"contents": "{\"package\": \"8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09\", \"files\": {}}",
"dest": "cargo/vendor/mio-0.8.10",
"dest-filename": ".cargo-checksum.json"
},
{
Expand Down Expand Up @@ -951,14 +951,14 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/once_cell/once_cell-1.18.0.crate",
"sha256": "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d",
"dest": "cargo/vendor/once_cell-1.18.0"
"url": "https://static.crates.io/crates/once_cell/once_cell-1.19.0.crate",
"sha256": "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92",
"dest": "cargo/vendor/once_cell-1.19.0"
},
{
"type": "inline",
"contents": "{\"package\": \"dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d\", \"files\": {}}",
"dest": "cargo/vendor/once_cell-1.18.0",
"contents": "{\"package\": \"3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92\", \"files\": {}}",
"dest": "cargo/vendor/once_cell-1.19.0",
"dest-filename": ".cargo-checksum.json"
},
{
Expand Down Expand Up @@ -1042,14 +1042,14 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/proc-macro-crate/proc-macro-crate-2.0.0.crate",
"sha256": "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8",
"dest": "cargo/vendor/proc-macro-crate-2.0.0"
"url": "https://static.crates.io/crates/proc-macro-crate/proc-macro-crate-2.0.1.crate",
"sha256": "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a",
"dest": "cargo/vendor/proc-macro-crate-2.0.1"
},
{
"type": "inline",
"contents": "{\"package\": \"7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8\", \"files\": {}}",
"dest": "cargo/vendor/proc-macro-crate-2.0.0",
"contents": "{\"package\": \"97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a\", \"files\": {}}",
"dest": "cargo/vendor/proc-macro-crate-2.0.1",
"dest-filename": ".cargo-checksum.json"
},
{
Expand Down Expand Up @@ -1146,14 +1146,14 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/reset_daemon/reset_daemon-1.0.0.crate",
"sha256": "4ac44390e711dd73b2a2c365890d28f0ceec5c3e9f760deafbab2ad7410e90ed",
"dest": "cargo/vendor/reset_daemon-1.0.0"
"url": "https://static.crates.io/crates/reset_daemon/reset_daemon-1.0.1.crate",
"sha256": "eedc50550fb0c1b1a6d09c0c9e8025678d50833805ddf09e3aa39a66ff391cc4",
"dest": "cargo/vendor/reset_daemon-1.0.1"
},
{
"type": "inline",
"contents": "{\"package\": \"4ac44390e711dd73b2a2c365890d28f0ceec5c3e9f760deafbab2ad7410e90ed\", \"files\": {}}",
"dest": "cargo/vendor/reset_daemon-1.0.0",
"contents": "{\"package\": \"eedc50550fb0c1b1a6d09c0c9e8025678d50833805ddf09e3aa39a66ff391cc4\", \"files\": {}}",
"dest": "cargo/vendor/reset_daemon-1.0.1",
"dest-filename": ".cargo-checksum.json"
},
{
Expand Down Expand Up @@ -1380,27 +1380,27 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/toml/toml-0.8.8.crate",
"sha256": "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35",
"dest": "cargo/vendor/toml-0.8.8"
"url": "https://static.crates.io/crates/toml/toml-0.8.2.crate",
"sha256": "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d",
"dest": "cargo/vendor/toml-0.8.2"
},
{
"type": "inline",
"contents": "{\"package\": \"a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35\", \"files\": {}}",
"dest": "cargo/vendor/toml-0.8.8",
"contents": "{\"package\": \"185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d\", \"files\": {}}",
"dest": "cargo/vendor/toml-0.8.2",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/toml_datetime/toml_datetime-0.6.5.crate",
"sha256": "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1",
"dest": "cargo/vendor/toml_datetime-0.6.5"
"url": "https://static.crates.io/crates/toml_datetime/toml_datetime-0.6.3.crate",
"sha256": "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b",
"dest": "cargo/vendor/toml_datetime-0.6.3"
},
{
"type": "inline",
"contents": "{\"package\": \"3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1\", \"files\": {}}",
"dest": "cargo/vendor/toml_datetime-0.6.5",
"contents": "{\"package\": \"7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b\", \"files\": {}}",
"dest": "cargo/vendor/toml_datetime-0.6.3",
"dest-filename": ".cargo-checksum.json"
},
{
Expand All @@ -1419,27 +1419,14 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/toml_edit/toml_edit-0.20.7.crate",
"sha256": "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81",
"dest": "cargo/vendor/toml_edit-0.20.7"
"url": "https://static.crates.io/crates/toml_edit/toml_edit-0.20.2.crate",
"sha256": "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338",
"dest": "cargo/vendor/toml_edit-0.20.2"
},
{
"type": "inline",
"contents": "{\"package\": \"70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81\", \"files\": {}}",
"dest": "cargo/vendor/toml_edit-0.20.7",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/toml_edit/toml_edit-0.21.0.crate",
"sha256": "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03",
"dest": "cargo/vendor/toml_edit-0.21.0"
},
{
"type": "inline",
"contents": "{\"package\": \"d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03\", \"files\": {}}",
"dest": "cargo/vendor/toml_edit-0.21.0",
"contents": "{\"package\": \"396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338\", \"files\": {}}",
"dest": "cargo/vendor/toml_edit-0.20.2",
"dest-filename": ".cargo-checksum.json"
},
{
Expand Down Expand Up @@ -1653,14 +1640,14 @@
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/winnow/winnow-0.5.19.crate",
"sha256": "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b",
"dest": "cargo/vendor/winnow-0.5.19"
"url": "https://static.crates.io/crates/winnow/winnow-0.5.26.crate",
"sha256": "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff",
"dest": "cargo/vendor/winnow-0.5.26"
},
{
"type": "inline",
"contents": "{\"package\": \"829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b\", \"files\": {}}",
"dest": "cargo/vendor/winnow-0.5.19",
"contents": "{\"package\": \"b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff\", \"files\": {}}",
"dest": "cargo/vendor/winnow-0.5.26",
"dest-filename": ".cargo-checksum.json"
},
{
Expand Down
16 changes: 8 additions & 8 deletions src/components/audio/audio_box_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use std::{
use adw::prelude::{ComboRowExt, PreferencesRowExt};
use dbus::arg::{Arg, Get};
use glib::{
object::{Cast, IsA},
object::{Cast, IsA, ObjectExt},
property::PropertyGet,
ControlFlow, Propagation,
};
use gtk::{
Expand Down Expand Up @@ -171,8 +172,8 @@ pub fn populate_audio_objects<
default_audio_object_function: &'static DBusFunction,
set_default_audio_object_function: &'static DBusFunction,
get_audio_streams_function: &'static DBusFunction,
set_audio_object_mute_function: &'static DBusFunction,
set_audio_object_volume_function: &'static DBusFunction,
set_audio_object_mute_function: &'static DBusFunction,
) {
gio::spawn_blocking(move || {
let sources = audio_dbus_call::<AudioBox, (Vec<AudioObject>,), ()>(
Expand Down Expand Up @@ -264,6 +265,7 @@ pub fn object_added_handler<
>(
audio_box: Arc<AudioBox>,
ir: Event,
dummy_name: &'static str,
) -> bool {
glib::spawn_future(async move {
glib::idle_add_once(move || {
Expand Down Expand Up @@ -305,17 +307,15 @@ pub fn object_added_handler<
let mut index = index.write().unwrap();
let model_list = source_box_imp.model_list();
let model_list = model_list.write().unwrap();
// TODO: make this work generic!
if model_list.string(*index - 1) == Some("Monitor of Dummy Output".into()) {
if model_list.string(*index - 1) == Some(dummy_name.into()) {
model_list.append(&alias);
model_list.remove(*index - 1);
map.insert(alias, (object_index, name));
source_box_imp.audio_object_dropdown().set_selected(0);
} else {
model_list.append(&alias);
map.insert(alias.clone(), (object_index, name));
// TODO: make this work generic!
if alias == "Monitor of Dummy Output" {
if alias == dummy_name {
source_box_imp.audio_object_dropdown().set_selected(0);
}
*index += 1;
Expand Down Expand Up @@ -406,6 +406,7 @@ pub fn object_removed_handler<
>(
audio_box: Arc<AudioBox>,
ir: Event,
dummy_name: &'static str,
) -> bool {
glib::spawn_future(async move {
glib::idle_add_once(move || {
Expand All @@ -431,8 +432,7 @@ pub fn object_removed_handler<
let model_list = model_list.write().unwrap();

if *index == 1 {
// TODO: ensure dummy output and input are mentioned
model_list.append("Dummy");
model_list.append(dummy_name);
}
for entry in 0..*index {
if model_list.string(entry) == Some(alias.clone().into()) {
Expand Down
7 changes: 3 additions & 4 deletions src/components/audio/audio_box_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ pub fn start_audio_box_listener<
conn: Connection,
source_box: Arc<AudioBox>,
get_default_name_function: &'static DBusFunction,
dummy_name: &'static str,
) -> Connection {
// TODO: make the failed logs generically sound -> deynamic output for both
let object_added =
Expand Down Expand Up @@ -361,7 +362,7 @@ pub fn start_audio_box_listener<
AudioBox,
AudioBoxImpl,
ObjectAdded,
>(object_added_box.clone(), ir)
>(object_added_box.clone(), ir, dummy_name)
});
if res.is_err() {
// TODO: handle this with the log/error macro
Expand All @@ -370,7 +371,6 @@ pub fn start_audio_box_listener<
}

let res = conn.add_match(object_changed, move |ir: ObjectChanged, _, _| {
// source_changed_handler(source_changed_box.clone(), ir)
object_changed_handler::<
AudioObject,
StreamObject,
Expand All @@ -389,7 +389,6 @@ pub fn start_audio_box_listener<
}

let res = conn.add_match(object_removed, move |ir: ObjectRemoved, _, _| {
// source_removed_handler(source_removed_box.clone(), ir)
object_removed_handler::<
AudioObject,
StreamObject,
Expand All @@ -400,7 +399,7 @@ pub fn start_audio_box_listener<
AudioBox,
AudioBoxImpl,
ObjectRemoved,
>(object_removed_box.clone(), ir)
>(object_removed_box.clone(), ir, dummy_name)
});
if res.is_err() {
println!("fail on source remove event");
Expand Down
4 changes: 2 additions & 2 deletions src/components/audio/input/source_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::components::base::error_impl::ReSetErrorImpl;

use super::output_stream_entry::OutputStreamEntry;
use super::source_const::{
GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME,
DUMMY, GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME
};
use super::source_entry::SourceEntry;

Expand Down Expand Up @@ -110,5 +110,5 @@ pub fn start_source_box_listener(conn: Connection, source_box: Arc<SourceBox>) -
OutputStreamAdded,
OutputStreamChanged,
OutputStreamRemoved,
>(conn, source_box, &GETDEFAULTNAME)
>(conn, source_box, &GETDEFAULTNAME, DUMMY)
}
2 changes: 2 additions & 0 deletions src/components/audio/input/source_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ pub const SETSTREAMOBJECT: DBusFunction = DBusFunction {
function: "SetSourceOfOutputStream",
error: "Failed to set source of output stream",
};

pub const DUMMY: &str = "Monitor of Dummy Output";
13 changes: 5 additions & 8 deletions src/components/audio/output/sink_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ use crate::components::base::error_impl::ReSetErrorImpl;

use super::input_stream_entry::InputStreamEntry;
use super::sink_box_impl;
use super::sink_const::GETDEFAULT;
use super::sink_const::GETDEFAULTNAME;
use super::sink_const::GETOBJECTS;
use super::sink_const::GETSTREAMS;
use super::sink_const::SETDEFAULT;
use super::sink_const::SETMUTE;
use super::sink_const::SETVOLUME;
use super::sink_const::DUMMY;
use super::sink_const::{
GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME,
};
use super::sink_entry::SinkEntry;

glib::wrapper! {
Expand Down Expand Up @@ -117,5 +114,5 @@ pub fn start_sink_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Conn
InputStreamAdded,
InputStreamChanged,
InputStreamRemoved,
>(conn, sink_box, &GETDEFAULTNAME)
>(conn, sink_box, &GETDEFAULTNAME, DUMMY)
}
2 changes: 2 additions & 0 deletions src/components/audio/output/sink_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ pub const SETSTREAMOBJECT: DBusFunction = DBusFunction {
function: "SetSinkOfInputStream",
error: "Failed to set sink of input stream",
};

pub const DUMMY: &str = "Dummy Input";
Loading

0 comments on commit ee31829

Please sign in to comment.