From de72c05088157b29cbcc743594c7f5b8ad7962a6 Mon Sep 17 00:00:00 2001 From: Jas Singh Date: Sat, 29 Jun 2024 20:05:47 -0700 Subject: [PATCH] Orgnize audio module code --- .../menus/audio/{ => active}/SelectedInput.js | 2 +- .../audio/{ => active}/SelectedPlayback.js | 2 +- modules/menus/audio/active/index.js | 39 +++++++ .../audio/{ => available}/InputDevices.js | 0 .../audio/{ => available}/PlaybackDevices.js | 0 modules/menus/audio/available/index.js | 81 +++++++++++++ modules/menus/audio/index.js | 109 +----------------- 7 files changed, 126 insertions(+), 107 deletions(-) rename modules/menus/audio/{ => active}/SelectedInput.js (98%) rename modules/menus/audio/{ => active}/SelectedPlayback.js (98%) create mode 100644 modules/menus/audio/active/index.js rename modules/menus/audio/{ => available}/InputDevices.js (100%) rename modules/menus/audio/{ => available}/PlaybackDevices.js (100%) create mode 100644 modules/menus/audio/available/index.js diff --git a/modules/menus/audio/SelectedInput.js b/modules/menus/audio/active/SelectedInput.js similarity index 98% rename from modules/menus/audio/SelectedInput.js rename to modules/menus/audio/active/SelectedInput.js index 45579c9..cf0e59a 100644 --- a/modules/menus/audio/SelectedInput.js +++ b/modules/menus/audio/active/SelectedInput.js @@ -1,5 +1,5 @@ const audio = await Service.import("audio"); -import { getIcon } from './utils.js'; +import { getIcon } from '../utils.js'; const renderActiveInput = () => { return [ diff --git a/modules/menus/audio/SelectedPlayback.js b/modules/menus/audio/active/SelectedPlayback.js similarity index 98% rename from modules/menus/audio/SelectedPlayback.js rename to modules/menus/audio/active/SelectedPlayback.js index e410f9c..cf276b0 100644 --- a/modules/menus/audio/SelectedPlayback.js +++ b/modules/menus/audio/active/SelectedPlayback.js @@ -1,5 +1,5 @@ const audio = await Service.import("audio"); -import { getIcon } from "./utils.js"; +import { getIcon } from "../utils.js"; const renderActivePlayback = () => { return [ diff --git a/modules/menus/audio/active/index.js b/modules/menus/audio/active/index.js new file mode 100644 index 0000000..e428879 --- /dev/null +++ b/modules/menus/audio/active/index.js @@ -0,0 +1,39 @@ +import { renderActiveInput } from "./SelectedInput.js"; +import { renderActivePlayback } from "./SelectedPlayback.js"; + +const activeDevices = () => { + return Widget.Box({ + class_name: "menu-section-container volume", + vertical: true, + children: [ + Widget.Box({ + class_name: "menu-label-container volume", + hpack: "fill", + child: Widget.Label({ + class_name: "menu-label audio volume", + hexpand: true, + hpack: "center", + label: "Volume", + }), + }), + Widget.Box({ + class_name: "menu-items-section selected", + vertical: true, + children: [ + Widget.Box({ + class_name: "menu-active-container playback", + vertical: true, + children: renderActivePlayback(), + }), + Widget.Box({ + class_name: "menu-active-container input", + vertical: true, + children: renderActiveInput(), + }), + ], + }), + ], + }); +}; + +export { activeDevices }; diff --git a/modules/menus/audio/InputDevices.js b/modules/menus/audio/available/InputDevices.js similarity index 100% rename from modules/menus/audio/InputDevices.js rename to modules/menus/audio/available/InputDevices.js diff --git a/modules/menus/audio/PlaybackDevices.js b/modules/menus/audio/available/PlaybackDevices.js similarity index 100% rename from modules/menus/audio/PlaybackDevices.js rename to modules/menus/audio/available/PlaybackDevices.js diff --git a/modules/menus/audio/available/index.js b/modules/menus/audio/available/index.js new file mode 100644 index 0000000..e177b8d --- /dev/null +++ b/modules/menus/audio/available/index.js @@ -0,0 +1,81 @@ +const audio = await Service.import("audio"); +import { renderInputDevices } from "./InputDevices.js"; +import { renderPlaybacks } from "./PlaybackDevices.js"; + +const availableDevices = () => { + return Widget.Box({ + vertical: true, + children: [ + Widget.Box({ + class_name: "menu-section-container playback", + vertical: true, + children: [ + Widget.Box({ + class_name: "menu-label-container playback", + hpack: "fill", + child: Widget.Label({ + class_name: "menu-label audio playback", + hexpand: true, + hpack: "center", + label: "Playback Devices", + }), + }), + Widget.Box({ + class_name: "menu-items-section playback", + vertical: true, + children: [ + Widget.Box({ + class_name: "menu-container playback", + vertical: true, + children: [ + Widget.Box({ + vertical: true, + children: audio + .bind("speakers") + .as((v) => renderPlaybacks(v)), + }), + ], + }), + ], + }), + ], + }), + Widget.Box({ + class_name: "menu-section-container input", + vertical: true, + children: [ + Widget.Box({ + class_name: "menu-label-container playback", + hpack: "fill", + child: Widget.Label({ + class_name: "menu-label audio playback", + hexpand: true, + hpack: "center", + label: "Input Devices", + }), + }), + Widget.Box({ + class_name: "menu-items-section input", + vertical: true, + children: [ + Widget.Box({ + class_name: "menu-container input", + vertical: true, + children: [ + Widget.Box({ + vertical: true, + children: audio + .bind("microphones") + .as((v) => renderInputDevices(v)), + }), + ], + }), + ], + }), + ], + }), + ], + }); +}; + +export { availableDevices }; diff --git a/modules/menus/audio/index.js b/modules/menus/audio/index.js index cdb0a06..2edb2f8 100644 --- a/modules/menus/audio/index.js +++ b/modules/menus/audio/index.js @@ -1,9 +1,6 @@ -const audio = await Service.import("audio"); import DropdownMenu from "../DropdownMenu.js"; -import { renderInputDevices } from "./InputDevices.js"; -import { renderPlaybacks } from "./PlaybackDevices.js"; -import { renderActiveInput } from "./SelectedInput.js"; -import { renderActivePlayback } from "./SelectedPlayback.js"; +import { activeDevices } from "./active/index.js"; +import { availableDevices } from "./available/index.js"; export default () => { return DropdownMenu({ @@ -19,106 +16,8 @@ export default () => { hexpand: true, class_name: "menu-items-container", children: [ - Widget.Box({ - class_name: "menu-section-container volume", - vertical: true, - children: [ - Widget.Box({ - class_name: "menu-label-container volume", - hpack: "fill", - child: Widget.Label({ - class_name: "menu-label audio volume", - hexpand: true, - hpack: "center", - label: "Volume", - }), - }), - Widget.Box({ - class_name: "menu-items-section selected", - vertical: true, - children: [ - Widget.Box({ - class_name: "menu-active-container playback", - vertical: true, - children: renderActivePlayback(), - }), - Widget.Box({ - class_name: "menu-active-container input", - vertical: true, - children: renderActiveInput(), - }), - ], - }), - ], - }), - Widget.Box({ - class_name: "menu-section-container playback", - vertical: true, - children: [ - Widget.Box({ - class_name: "menu-label-container playback", - hpack: "fill", - child: Widget.Label({ - class_name: "menu-label audio playback", - hexpand: true, - hpack: "center", - label: "Playback Devices", - }), - }), - Widget.Box({ - class_name: "menu-items-section playback", - vertical: true, - children: [ - Widget.Box({ - class_name: "menu-container playback", - vertical: true, - children: [ - Widget.Box({ - vertical: true, - children: audio - .bind("speakers") - .as((v) => renderPlaybacks(v)), - }), - ], - }), - ], - }), - ], - }), - Widget.Box({ - class_name: "menu-section-container input", - vertical: true, - children: [ - Widget.Box({ - class_name: "menu-label-container playback", - hpack: "fill", - child: Widget.Label({ - class_name: "menu-label audio playback", - hexpand: true, - hpack: "center", - label: "Input Devices", - }), - }), - Widget.Box({ - class_name: "menu-items-section input", - vertical: true, - children: [ - Widget.Box({ - class_name: "menu-container input", - vertical: true, - children: [ - Widget.Box({ - vertical: true, - children: audio - .bind("microphones") - .as((v) => renderInputDevices(v)), - }), - ], - }), - ], - }), - ], - }), + activeDevices(), + availableDevices(), ], }), }),