Skip to content

Commit

Permalink
feat: allow choosing audio device
Browse files Browse the repository at this point in the history
Closes #227
  • Loading branch information
SeaDve committed Feb 17, 2024
1 parent 4bf78a7 commit 0494986
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 355 deletions.
74 changes: 3 additions & 71 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ gst = { package = "gstreamer", version = "0.22" }
gst-plugin-gif = "0.12"
gst-plugin-gtk4 = { version = "0.12", features = ["gtk_v4_14"] }
gtk = { package = "gtk4", version = "0.8", features = ["v4_14"] }
indexmap = "2.2"
num-rational = { version = "0.4", default-features = false }
num-traits = "0.2"
once_cell = "1.19.0"
pulse = { package = "libpulse-binding", version = "2.26.0" }
pulse_glib = { package = "libpulse-glib-binding", version = "2.25.1" }
serde_yaml = "0.9.31"
serde = { version = "1.0.196", features = ["derive"] }
tracing = "0.1.36"
Expand Down
1 change: 1 addition & 0 deletions data/io.github.seadve.Kooha.metainfo.xml.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<description translatable="no">
<p>This release contains new features and fixes:</p>
<ul>
<li>Audio device can now be changed from the preferences</li>
<li>Area selector window is now resizable</li>
<li>Previous selected area is now remembered</li>
<li>Logout and idle are now inhibited while recording</li>
Expand Down
15 changes: 15 additions & 0 deletions data/resources/ui/preferences_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Audio</property>
<child>
<object class="AdwComboRow" id="desktop_audio_row">
<property name="title" translatable="yes">Desktop Audio Device</property>
</object>
</child>
<child>
<object class="AdwComboRow" id="microphone_row">
<property name="title" translatable="yes">Microphone Device</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
Expand Down
2 changes: 0 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ dependency('gtk4', version: '>= 4.13')
dependency('libadwaita-1', version: '>= 1.5')
dependency('gstreamer-1.0', version: '>= 1.22')
dependency('gstreamer-plugins-base-1.0', version: '>= 1.22')
dependency('libpulse-mainloop-glib', version: '>= 16.0')
dependency('libpulse', version: '>= 16.0')

glib_compile_resources = find_program('glib-compile-resources', required: true)
glib_compile_schemas = find_program('glib-compile-schemas', required: true)
Expand Down
1 change: 0 additions & 1 deletion po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ data/resources/ui/shortcuts.ui
data/resources/ui/window.ui
src/about.rs
src/application.rs
src/audio_device.rs
src/format_time.rs
src/main.rs
src/preferences_dialog.rs
Expand Down
25 changes: 24 additions & 1 deletion src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use gtk::{
use crate::{
about,
config::{APP_ID, PKGDATADIR, PROFILE, VERSION},
device_manager::{DeviceClass, DeviceManager},
format_time,
preferences_dialog::PreferencesDialog,
settings::Settings,
Expand All @@ -22,6 +23,9 @@ mod imp {
#[derive(Debug, Default)]
pub struct Application {
pub(super) settings: OnceCell<Settings>,

pub(super) desktop_audio_manager: OnceCell<DeviceManager>,
pub(super) microphone_manger: OnceCell<DeviceManager>,
}

#[glib::object_subclass]
Expand Down Expand Up @@ -53,6 +57,13 @@ mod imp {

gtk::Window::set_default_icon_name(APP_ID);

self.desktop_audio_manager
.set(DeviceManager::new(DeviceClass::Sink))
.unwrap();
self.microphone_manger
.set(DeviceManager::new(DeviceClass::Source))
.unwrap();

let obj = self.obj();

obj.setup_gactions();
Expand Down Expand Up @@ -106,6 +117,14 @@ impl Application {
})
}

pub fn desktop_audio_manager(&self) -> &DeviceManager {
self.imp().desktop_audio_manager.get().unwrap()
}

pub fn microphone_manager(&self) -> &DeviceManager {
self.imp().microphone_manger.get().unwrap()
}

pub fn window(&self) -> Window {
self.active_window()
.map_or_else(|| Window::new(self), |w| w.downcast().unwrap())
Expand Down Expand Up @@ -150,7 +169,11 @@ impl Application {
}

pub fn present_preferences_dialog(&self) {
let dialog = PreferencesDialog::new(self.settings());
let dialog = PreferencesDialog::new(
self.settings(),
self.desktop_audio_manager(),
self.microphone_manager(),
);
dialog.present(&self.window());
}

Expand Down
Loading

0 comments on commit 0494986

Please sign in to comment.