Skip to content

Commit

Permalink
WIP: Whatever I did ages ago
Browse files Browse the repository at this point in the history
  • Loading branch information
ChildishGiant committed Aug 17, 2023
1 parent cda4d26 commit cecf808
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 149 deletions.
59 changes: 59 additions & 0 deletions com.github.childishgiant.mixer.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"app-id" : "com.github.childishgiant.mixer",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
"sdk-extensions" : [
"org.freedesktop.Sdk.Extension.vala"
],
"command" : "com.github.childishgiant.mixer",
"finish-args" : [
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--socket=pulseaudio",
"--device=all",
"--env=G_MESSAGES_DEBUG=all"
],
"build-options" : {
"append-path" : "/usr/lib/sdk/vala/bin",
"prepend-ld-library-path" : "/usr/lib/sdk/vala/lib"
},
"cleanup" : [
"/include",
"/lib/pkgconfig",
"/man",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"/share/vala",
"*.la",
"*.a"
],
"modules" : [
{
"name" : "blueprint",
"buildsystem" : "meson",
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/jwestman/blueprint-compiler.git",
"tag" : "v0.6.0"
}
]
},
{
"name" : "mixer",
"builddir" : true,
"buildsystem" : "meson",
"sources" : [
{
"type" : "dir",
"path" : "."
}
]
}
]
}

126 changes: 41 additions & 85 deletions src/appEntry.blp
Original file line number Diff line number Diff line change
Expand Up @@ -2,100 +2,56 @@ using Gtk 4.0;
using Adw 1;


template MixerAppEntry : Gtk.Grid {
template MixerAppEntry : Adw.ExpanderRow {
title: _("App Name");

Gtk.Label name_label {
layout {
row: 0;
column: 0;
}
label: _("App Name");
max-width-chars: 32;
ellipsize: end;
[prefix]
Gtk.Image icon {
icon-name: "applications-multimedia-symbolic";
}

Gtk.Label volume_label {
layout {
row: 0;
column: 1;
}
label: _("Volume:");
halign: start;
}

Gtk.Scale volume_scale {
layout {
row: 0;
column: 2;
}
adjustment: Gtk.Adjustment {
page-increment: 5;
upper: 100;
lower: 0;
};
draw-value: false;
hexpand: true;
}
[action]
Gtk.Box {
Gtk.Scale volume_scale {
adjustment: Gtk.Adjustment {
page-increment: .05;
upper: 1;
lower: 0;
};
draw-value: false;
hexpand: true;

}
Gtk.Button mute-button {
styles ["flat"]
valign: center;
icon-name: "audio-volume-high-symbolic";
action-name: "mute";

Gtk.Switch volume_switch {
layout {
row: 0;
column: 3;
}
valign: center;
}

Gtk.Image icon {
layout {
row: 1;
column: 0;
}
icon-name: "audio-volume-high-symbolic";
valign: start;
}

Gtk.Label balance_label {
layout {
row: 1;
column: 1;
}
label: _("Balance:");
halign: start;
valign: start;
}
}

Gtk.Scale balance_scale {
layout {
row: 1;
column: 2;
}
adjustment: Gtk.Adjustment {
page-increment: 0.1;
upper: 1;
lower: -1;
};
draw-value: false;
has-origin: false;
width-request: 150;
hexpand: true;
Adw.ActionRow balance_row {
title: _("Balance");

Gtk.Scale balance_scale {
adjustment: Gtk.Adjustment {
page-increment: 0.1;
upper: 1;
lower: -1;
};
draw-value: false;
has-origin: false;
hexpand: true;
}
}

Gtk.Label output_label {
layout {
row: 2;
column: 1;
}
label: _("Output:");
halign: end;
}

Gtk.ComboBoxText dropdown {
layout {
row: 2;
column: 2;
}
width-request: 75;
}
Adw.ComboRow output_row {
title: _("Output");
//model: StringList {strings [""] };
model: StringList { strings ["test","test2"] };
}

}

11 changes: 6 additions & 5 deletions src/application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Mixer {
flags: ApplicationFlags.FLAGS_NONE
);

this.add_main_option_entries(options);
this.add_main_option_entries (options);
}


Expand All @@ -62,8 +62,8 @@ namespace Mixer {

public override void activate () {

debug("Mockup: %s".printf (mockup));
debug(mockup == ""? "Mockup: %s".printf (mockup) : "No mockup");
debug ("Mockup: %s".printf (mockup));
debug (mockup == ""? "Mockup: %s".printf (mockup) : "No mockup");

if (print_version) {

Expand All @@ -78,10 +78,11 @@ namespace Mixer {
}

// FIXME TODO mockup not working now.
// Just move it to a blp
if (mockup != null) {
debug("Using mockup");
debug ("Using mockup");
var cast_win = (Mixer.Window) win;
cast_win.populate(mockup);
cast_win.populate (mockup);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/digest.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Response : GLib.Object {

public Response digest (PulseAudio.SinkInputInfo sink_input) {

// debug(sink_input.proplist.to_string());
debug(sink_input.proplist.to_string());

Response app = new Response ();

Expand All @@ -29,7 +29,7 @@ public Response digest (PulseAudio.SinkInputInfo sink_input) {
debug ("Index: %d", (int)app.index);

// Set name
app.name = sink_input.proplist.gets ("application.name");
app.name = sink_input.proplist.gets ("application.name") + sink_input.proplist.gets("media.name");
debug ("\t Name: %s", app.name);

// Set mute state
Expand Down
11 changes: 5 additions & 6 deletions src/pulseManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public class PulseManager : Object {


if (sink != null) {
// debug("Sink info: %s", sink.proplist.to_string());
// debug("Sink info: %s", sink.proplist.to_string());

var sink_response = new Sink ();

Expand Down Expand Up @@ -208,13 +208,13 @@ public class PulseManager : Object {

return this.sinks;
}

private void success_cb (Context c, int success) {
if (success == 0) {
debug("Failed: %s", c.errno().to_string());
debug ("Failed: %s", c.errno( ).to_string( ));
}
}

public void set_volume (Response app, Gtk.Scale balance_scale, Gtk.Scale volume_scale) {

debug ("Setting volume and balance for %s (%i)", app.name, (int)app.index);
Expand All @@ -225,7 +225,7 @@ public class PulseManager : Object {

// Set volume
debug ("Volume input: %s", volume.to_string ());
var vol = PulseAudio.Volume.sw_from_linear (volume / 100);
var vol = PulseAudio.Volume.sw_from_linear (volume);
cvol.set (app.channel_map.channels, vol);
debug ("Volume: %s", vol.to_string ());

Expand All @@ -248,4 +248,3 @@ public class PulseManager : Object {
}

}

3 changes: 1 addition & 2 deletions src/util.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ int get_index (uint32[] arr, int val) {
}
}
return -1;
}

}
4 changes: 1 addition & 3 deletions src/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ template MixerWindow : Adw.ApplicationWindow {
min-content-height: 120;
propagate-natural-height: true;

Gtk.Box apps_grid {
orientation: vertical;
spacing: 6;
Adw.PreferencesGroup apps_grid {
margin-top: 6;
margin-bottom: 6;
// Side margins to make scrolling easier
Expand Down
Loading

0 comments on commit cecf808

Please sign in to comment.