Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing features #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions blueprint-compiler-0.16.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

self: prev: {
blueprint-compiler = prev.blueprint-compiler.overrideAttrs (oldAttrs: {
version = "0.16.0";
src = prev.fetchFromGitLab {
domain = "gitlab.gnome.org";
owner = "jwestman";
repo = "blueprint-compiler";
rev = "v0.16.0";
sha256 = "1y40kf9yfrjlfr5ax27j7ksv27fsznl7jhvvkzbfifdymjv10wqn";
};
patches = (prev.patches or []) ++ [
./skip-docs.patch
];
});
}
49 changes: 49 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
astal = {
url = "github:aylur/astal?ref=pull/297/head";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, astal }: let
system = "x86_64-linux";
overlays = [
(import ./blueprint-compiler-0.16.nix)
];
pkgs = import nixpkgs {
inherit system overlays;
};
in {
packages.${system}.default = pkgs.stdenv.mkDerivation {
name = "wirecontrol";
src = ./.;

nativeBuildInputs = with pkgs; [
meson
ninja
pkg-config
vala
gobject-introspection
desktop-file-utils
pkgs.blueprint-compiler
];

buildInputs = with pkgs; [
astal.packages.${system}.wireplumber
gtk4
libadwaita
];
};
};
}
13 changes: 13 additions & 0 deletions skip-docs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git i/meson.build w/meson.build
index 63d9489..66bfaa0 100644
--- i/meson.build
+++ w/meson.build
@@ -7,8 +7,6 @@ datadir = join_paths(prefix, get_option('datadir'))

py = import('python').find_installation('python3')

-subdir('docs')
-
configure_file(
input: 'blueprint-compiler.pc.in',
output: 'blueprint-compiler.pc',
42 changes: 42 additions & 0 deletions src/device.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Gtk 4.0;
using AstalWp 0.1;

template $WirecontrolDevice: Gtk.ListBoxRow {
selectable: false;
activatable: false;
child: Gtk.Box {
margin-start: 10;
margin-end: 10;
margin-top: 10;
margin-bottom: 10;

Gtk.CenterBox {
hexpand: true;
[start]
Gtk.Box {
spacing: 10;

Gtk.Image {
icon-name: bind template.device as <AstalWp.Device>.icon;
use-fallback: true;
}
Gtk.Label {
label: bind template.device as <AstalWp.Device>.description;
ellipsize: end;
xalign: 0;
}
}
[end]
Gtk.Box {
spacing: 5;
Gtk.DropDown profile {
model: bind template.profiles;
expression: expr item as <AstalWp.Profile>.description;
}
}
}
};
}



37 changes: 37 additions & 0 deletions src/device.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Wirecontrol {
[GtkTemplate (ui = "/com/github/kotontrion/wirecontrol/device.ui")]
public class Device : Gtk.ListBoxRow {

public AstalWp.Device device { get; construct; }
public ListStore profiles { get; private set; }

[GtkChild]
private unowned Gtk.DropDown profile;

public Device (AstalWp.Device device) {
Object(device: device);

this.profiles = new ListStore(typeof(AstalWp.Profile));
device.profiles.foreach((profile) => {
profiles.append(profile);
});

device.notify["active-profile-id"].connect(() => {
uint position;
bool found = profiles.find(device.get_profile(device.active_profile_id), out position);
profile.selected = position;
});
uint position;
bool found = profiles.find(device.get_profile(device.active_profile_id), out position);
profile.selected = position;

profile.notify["selected"].connect(() => {
var selected_profile = profiles.get_item(profile.selected) as AstalWp.Profile;
device.active_profile_id = selected_profile.index;
});


}

}
}
13 changes: 12 additions & 1 deletion src/endpoint.blp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ template $WirecontrolEndpoint: Gtk.ListBoxRow {
[end]
Gtk.Box {
spacing: 5;
Gtk.DropDown route {
model: bind template.routes;
expression: expr item as <AstalWp.Route>.description;
}

Gtk.ToggleButton mute_toggle {
child: Gtk.Image {
icon-name: "audio-volume-muted-symbolic";
Expand All @@ -48,7 +53,6 @@ template $WirecontrolEndpoint: Gtk.ListBoxRow {
};
}
Gtk.ToggleButton default_toggle {
visible: bind $default_toggle_visible(template.endpoint as <AstalWp.Endpoint>.media-class) as <bool>;
halign: end;
child: Gtk.Image {
icon-name: "object-select-symbolic";
Expand All @@ -69,6 +73,13 @@ template $WirecontrolEndpoint: Gtk.ListBoxRow {
};
}
}
Gtk.Expander {
label: _("channels");

Gtk.Box channel_box {
orientation: vertical;
}
}
};
}

Expand Down
46 changes: 41 additions & 5 deletions src/endpoint.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Wirecontrol {
public class Endpoint : Gtk.ListBoxRow {

public AstalWp.Endpoint endpoint { get; construct; }
public ListStore routes {get; construct; }

[GtkChild]
private unowned Gtk.Adjustment volume_adjust;
Expand All @@ -12,9 +13,13 @@ namespace Wirecontrol {
private unowned Gtk.ToggleButton default_toggle;
[GtkChild]
private unowned Gtk.ToggleButton lock_toggle;
[GtkChild]
private unowned Gtk.Box channel_box;
[GtkChild]
private unowned Gtk.DropDown route;

public Endpoint (AstalWp.Endpoint endpoint) {
Object(endpoint: endpoint);
Object(endpoint: endpoint, routes: new ListStore(typeof(AstalWp.Route)));

endpoint.bind_property("volume", volume_adjust, "value", GLib.BindingFlags.BIDIRECTIONAL | GLib.BindingFlags.SYNC_CREATE);
endpoint.bind_property("mute", mute_toggle, "active", GLib.BindingFlags.BIDIRECTIONAL | GLib.BindingFlags.SYNC_CREATE);
Expand All @@ -23,12 +28,43 @@ namespace Wirecontrol {
realize.connect(() => {
get_root().bind_property("max-vol", volume_adjust, "upper", GLib.BindingFlags.SYNC_CREATE);
});

endpoint.notify["channels"].connect(recreate_channels);
recreate_channels();

endpoint.routes.foreach((route) => {
routes.append(route);
});

endpoint.notify["active-route"].connect(() => {
uint position;
routes.find(endpoint.get_route(), out position);
route.selected = position;
});

uint position;
routes.find(endpoint.get_route(), out position);
route.selected = position;

route.notify["selected"].connect(() => {
var selected_route = routes.get_item(route.selected) as AstalWp.Route;
endpoint.set_route(selected_route);
});
}

[GtkCallback]
public bool default_toggle_visible(AstalWp.MediaClass media_class) {
return media_class == AstalWp.MediaClass.AUDIO_SPEAKER
|| media_class == AstalWp.MediaClass.AUDIO_MICROPHONE;


private void recreate_channels() {
var widget = channel_box.get_first_child();
while(widget != null) {
channel_box.remove(widget);
widget = channel_box.get_first_child();
}
if(endpoint.channels == null) return;
foreach(var cv in endpoint.channels) {
var channel = new Wirecontrol.VolumeScale(cv);
channel_box.append(channel);
}
}
}
}
6 changes: 6 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ wirecontrol_sources = [
'application.vala',
'window.vala',
'endpoint.vala',
'stream.vala',
'device.vala',
'volume_scale.vala'
]

wirecontrol_deps = [
Expand All @@ -16,6 +19,9 @@ blueprints = custom_target('blueprint-compiler',
input: files(
'window.blp',
'endpoint.blp',
'device.blp',
'volume_scale.blp',
'stream.blp'
),
output: '.',
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
Expand Down
Loading