Skip to content

Commit

Permalink
Finally move to libpulse (#34)
Browse files Browse the repository at this point in the history
* refactor: move to libpulse
* build: use elementary runtime 6.1

Co-authored-by: SubhadeepJasu <[email protected]>
  • Loading branch information
ChildishGiant and SubhadeepJasu authored Dec 24, 2021
1 parent 8f69765 commit 389a16b
Show file tree
Hide file tree
Showing 18 changed files with 2,130 additions and 634 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: ghcr.io/elementary/flatpak-platform/runtime:6
image: ghcr.io/elementary/flatpak-platform/runtime:6.1
options: --privileged

steps:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ Ensure you have these dependencies installed
* granite
* gtk+-3.0
* libhandy-1.0
* libpulse

### Install, build and run

```bash
# install elementary-sdk, meson and ninja
sudo apt install elementary-sdk meson ninja-build libhandy-1-dev
sudo apt install elementary-sdk meson ninja-build libhandy-1-dev libpulse-dev
# clone repository
git clone https://github.com/ChildishGiant/mixer mixer
# cd to dir
Expand Down
2 changes: 1 addition & 1 deletion com.github.childishgiant.mixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ app-id: com.github.childishgiant.mixer
# we can use a convenient pre-made runtime and SDK. For this example, we'll be
# using the runtime and SDK provided by elementary.
runtime: io.elementary.Platform
runtime-version: '6'
runtime-version: '6.1'
sdk: io.elementary.Sdk

# This should match the exec line in your .desktop file and usually is the same
Expand Down
10 changes: 9 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ add_project_arguments (
language: 'c'
)

add_project_arguments(
['--vapidir', join_paths(meson.current_source_dir(), 'vapi')],
language: 'vala'
)


# Listing dependencies
dependencies = [
dependency ('glib-2.0'),
dependency ('gtk+-3.0'),
dependency ('granite'),
dependency('libhandy-1', version: '>=1.0.0')
dependency('libhandy-1', version: '>=1.0.0'),
dependency('libpulse'),
dependency('libpulse-mainloop-glib'),
]

subdir ('src')
Expand Down
23 changes: 4 additions & 19 deletions src/AlertView.vala
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
/*
* Copyright (c) 2021 - Today Allie Law (ChildishGiant)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Rajdeep Singha <[email protected]>
*/
* Copyright 2021 Allie Law <[email protected]>
* Copyright 2021 Rajdeep Singha <[email protected]>
* SPDX-License-Identifier: GPL-3.0-or-later
*/

public class AlertView : Gtk.Grid {
construct {
Expand Down
54 changes: 22 additions & 32 deletions src/Application.vala
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
/*
* Copyright (c) 2021 - Today Allie Law (ChildishGiant)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Allie Law <[email protected]>
*/
* Copyright 2021 Allie Law <[email protected]>
* SPDX-License-Identifier: GPL-3.0-or-later
*/

public class Mixer.App : Gtk.Application {

private static string version = "0.1.4";
private static bool print_version = false;
private static string mockup = null;
public PulseManager manager;
Response[] responses;
Sink[] sinks;

public App () {
Object (
Expand Down Expand Up @@ -82,28 +69,31 @@ public class Mixer.App : Gtk.Application {
return;
}

var listener = new Listener ("/home", "/usr/bin/pactl subscribe");
manager = new PulseManager ();
app_window.pulse_manager = manager;

listener.output_changed.connect ((line) => {
// If the change is a sink-input
if (line.contains ("sink-input") && (line.contains ("new") || line.contains ("remove"))) {
debug (line.strip ());
app_window.populate ();
app_window.show_all ();
manager.get_apps ();
manager.get_outputs ();

manager.sinks_updated.connect ((_sinks) => {
sinks = _sinks;
if (responses != null) {
app_window.populate ("", responses, sinks);
}
});

listener.run ();

app_window.destroy.connect (() => {
listener.quit ();
manager.apps_updated.connect ((_apps) => {
responses = _apps;
if (sinks != null) {
app_window.populate ("", responses, sinks);
app_window.show_all ();
}
});

app_window.show_all ();

quit_action.activate.connect (() => {
if (app_window != null) {
app_window.destroy ();
app_window.show_all ();
}
});

Expand Down
Loading

0 comments on commit 389a16b

Please sign in to comment.