Big restructuring

This commit is contained in:
takotori 2023-10-30 19:43:50 +01:00
parent c4c95df8d3
commit 13084ed86d
22 changed files with 638 additions and 595 deletions

View file

@ -1,43 +1,15 @@
use gtk::{Button, CompositeTemplate, DropDown, TemplateChild, glib};
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use crate::components::audio::AudioSourceEntry;
use adw::glib;
use adw::glib::Object;
use crate::components::audio::audioBoxImpl;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
#[template(resource = "/org/Xetibo/ReSet/resetAudio.ui")]
pub struct AudioBox {
#[template_child]
pub resetOutputDevice: TemplateChild<DropDown>,
#[template_child]
pub resetAllOutputDevices: TemplateChild<Button>,
glib::wrapper! {
pub struct AudioBox(ObjectSubclass<audioBoxImpl::AudioBox>)
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
}
#[glib::object_subclass]
impl ObjectSubclass for AudioBox {
const NAME: &'static str = "resetAudio";
type Type = super::AudioBox;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
AudioSourceEntry::ensure_type();
klass.bind_template();
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
impl AudioBox {
pub fn new() -> Self {
Object::builder().build()
}
}
impl BoxImpl for AudioBox {}
impl ObjectImpl for AudioBox {}
impl ListBoxRowImpl for AudioBox {}
impl WidgetImpl for AudioBox {}
impl WindowImpl for AudioBox {}
impl ApplicationWindowImpl for AudioBox {}

View file

@ -0,0 +1,44 @@
use gtk::{Button, CompositeTemplate, DropDown, TemplateChild, glib};
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use crate::components::audio::audioBox;
use crate::components::audio::audioSource::AudioSourceEntry;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
#[template(resource = "/org/Xetibo/ReSet/resetAudio.ui")]
pub struct AudioBox {
#[template_child]
pub resetOutputDevice: TemplateChild<DropDown>,
#[template_child]
pub resetAllOutputDevices: TemplateChild<Button>,
}
#[glib::object_subclass]
impl ObjectSubclass for AudioBox {
const NAME: &'static str = "resetAudio";
type Type = audioBox::AudioBox;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
AudioSourceEntry::ensure_type();
klass.bind_template();
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}
impl BoxImpl for AudioBox {}
impl ObjectImpl for AudioBox {}
impl ListBoxRowImpl for AudioBox {}
impl WidgetImpl for AudioBox {}
impl WindowImpl for AudioBox {}
impl ApplicationWindowImpl for AudioBox {}

View file

@ -1,41 +1,15 @@
use gtk::{Button, CompositeTemplate, glib, Image, Label, ProgressBar, Scale};
use gtk::subclass::prelude::*;
use adw::glib;
use adw::glib::Object;
use crate::components::audio::audioSourceImpl;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
#[template(resource = "/org/Xetibo/ReSet/resetAudioSourceEntry.ui")]
pub struct AudioSourceEntry {
#[template_child]
pub resetSourceIcon: TemplateChild<Image>,
#[template_child]
pub resetSourceName: TemplateChild<Label>,
#[template_child]
pub resetSourceMute: TemplateChild<Button>,
#[template_child]
pub resetVolumeSlider: TemplateChild<Scale>,
#[template_child]
pub resetVolumePercentage: TemplateChild<Label>,
#[template_child]
pub resetVolumeMeter: TemplateChild<ProgressBar>,
glib::wrapper! {
pub struct AudioSourceEntry(ObjectSubclass<audioSourceImpl::AudioSourceEntry>)
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
}
#[glib::object_subclass]
impl ObjectSubclass for AudioSourceEntry {
const NAME: &'static str = "resetAudioSourceEntry";
type Type = super::AudioSourceEntry;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
klass.bind_template();
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
impl AudioSourceEntry {
pub fn new() -> Self {
Object::builder().build()
}
}
impl BoxImpl for AudioSourceEntry {}
impl ObjectImpl for AudioSourceEntry {}
impl WidgetImpl for AudioSourceEntry {}

View file

@ -0,0 +1,42 @@
use gtk::{Button, CompositeTemplate, glib, Image, Label, ProgressBar, Scale};
use gtk::subclass::prelude::*;
use crate::components::audio::audioSource;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
#[template(resource = "/org/Xetibo/ReSet/resetAudioSourceEntry.ui")]
pub struct AudioSourceEntry {
#[template_child]
pub resetSourceIcon: TemplateChild<Image>,
#[template_child]
pub resetSourceName: TemplateChild<Label>,
#[template_child]
pub resetSourceMute: TemplateChild<Button>,
#[template_child]
pub resetVolumeSlider: TemplateChild<Scale>,
#[template_child]
pub resetVolumePercentage: TemplateChild<Label>,
#[template_child]
pub resetVolumeMeter: TemplateChild<ProgressBar>,
}
#[glib::object_subclass]
impl ObjectSubclass for AudioSourceEntry {
const NAME: &'static str = "resetAudioSourceEntry";
type Type = audioSource::AudioSourceEntry;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
klass.bind_template();
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}
impl BoxImpl for AudioSourceEntry {}
impl ObjectImpl for AudioSourceEntry {}
impl WidgetImpl for AudioSourceEntry {}

View file

@ -1,31 +1,5 @@
#![allow(non_snake_case)]
mod audioSource;
mod audioBox;
use adw::glib::Object;
use gtk::{glib};
glib::wrapper! {
pub struct AudioBox(ObjectSubclass<audioBox::AudioBox>)
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
}
glib::wrapper! {
pub struct AudioSourceEntry(ObjectSubclass<audioSource::AudioSourceEntry>)
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
}
impl AudioBox {
pub fn new() -> Self {
Object::builder().build()
}
}
impl AudioSourceEntry {
pub fn new() -> Self {
Object::builder().build()
}
}
pub mod audioSource;
pub mod audioBox;
pub mod audioBoxImpl;
pub mod audioSourceImpl;