mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-07-01 15:57:46 +02:00
Improve UI
This commit is contained in:
parent
02e63f5984
commit
c6efced326
28 changed files with 609 additions and 1035 deletions
|
@ -3,7 +3,7 @@ use std::time::{Duration, SystemTime};
|
|||
|
||||
use adw::glib;
|
||||
use adw::glib::Object;
|
||||
use adw::prelude::{ButtonExt, RangeExt};
|
||||
use adw::prelude::{ButtonExt, ComboRowExt, PreferencesRowExt, RangeExt};
|
||||
use dbus::blocking::Connection;
|
||||
use dbus::Error;
|
||||
use glib::subclass::types::ObjectSubclassIsExt;
|
||||
|
@ -16,7 +16,7 @@ use super::sourceBox::SourceBox;
|
|||
|
||||
glib::wrapper! {
|
||||
pub struct OutputStreamEntry(ObjectSubclass<outputStreamEntryImpl::OutputStreamEntry>)
|
||||
@extends gtk::Box, gtk::Widget,
|
||||
@extends adw::PreferencesGroup, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ impl OutputStreamEntry {
|
|||
let box_imp = source_box.imp();
|
||||
let imp = obj.imp();
|
||||
let name = stream.application_name.clone() + ": " + stream.name.as_str();
|
||||
imp.resetSourceName.set_text(name.as_str());
|
||||
imp.resetSourceSelection.set_title(name.as_str());
|
||||
let volume = stream.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
|
@ -69,7 +69,7 @@ impl OutputStreamEntry {
|
|||
// list = box_imp.resetModelList.try_borrow();
|
||||
// }
|
||||
// let list = list.unwrap();
|
||||
imp.resetSelectedSource.set_model(Some(&*list));
|
||||
imp.resetSourceSelection.set_model(Some(&*list));
|
||||
let map = box_imp.resetSourceMap.write().unwrap();
|
||||
// while map.is_err() {
|
||||
// map = box_imp.resetSourceMap.try_borrow();
|
||||
|
@ -83,10 +83,10 @@ impl OutputStreamEntry {
|
|||
let name = &name.alias;
|
||||
let index = map.get(name);
|
||||
if index.is_some() {
|
||||
imp.resetSelectedSource.set_selected(index.unwrap().1);
|
||||
imp.resetSourceSelection.set_selected(index.unwrap().1);
|
||||
}
|
||||
}
|
||||
imp.resetSelectedSource.connect_selected_notify(
|
||||
imp.resetSourceSelection.connect_selected_notify(
|
||||
clone!(@weak imp, @weak box_imp => move |dropdown| {
|
||||
let selected = dropdown.selected_item();
|
||||
if selected.is_none() {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use std::cell::RefCell;
|
||||
use std::sync::Arc;
|
||||
use std::time::SystemTime;
|
||||
use adw::{ComboRow, PreferencesGroup};
|
||||
use adw::subclass::prelude::PreferencesGroupImpl;
|
||||
|
||||
use crate::components::input::outputStreamEntry;
|
||||
use gtk::subclass::prelude::*;
|
||||
|
@ -12,9 +14,7 @@ use ReSet_Lib::audio::audio::OutputStream;
|
|||
#[template(resource = "/org/Xetibo/ReSet/resetOutputStreamEntry.ui")]
|
||||
pub struct OutputStreamEntry {
|
||||
#[template_child]
|
||||
pub resetSourceName: TemplateChild<Label>,
|
||||
#[template_child]
|
||||
pub resetSelectedSource: TemplateChild<DropDown>,
|
||||
pub resetSourceSelection: TemplateChild<ComboRow>,
|
||||
#[template_child]
|
||||
pub resetSourceMute: TemplateChild<Button>,
|
||||
#[template_child]
|
||||
|
@ -33,7 +33,7 @@ impl ObjectSubclass for OutputStreamEntry {
|
|||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetOutputStreamEntry";
|
||||
type Type = outputStreamEntry::OutputStreamEntry;
|
||||
type ParentType = gtk::Box;
|
||||
type ParentType = PreferencesGroup;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
|
@ -44,7 +44,7 @@ impl ObjectSubclass for OutputStreamEntry {
|
|||
}
|
||||
}
|
||||
|
||||
impl BoxImpl for OutputStreamEntry {}
|
||||
impl PreferencesGroupImpl for OutputStreamEntry {}
|
||||
|
||||
impl ObjectImpl for OutputStreamEntry {}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use adw::prelude::PreferencesRowExt;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
|
@ -55,12 +56,12 @@ impl SourceBox {
|
|||
selfImp
|
||||
.resetCardsRow
|
||||
.set_action_target_value(Some(&Variant::from("profileConfiguration")));
|
||||
selfImp
|
||||
.resetOutputStreamButton
|
||||
.set_action_name(Some("navigation.pop"));
|
||||
selfImp
|
||||
.resetInputCardsBackButton
|
||||
.set_action_name(Some("navigation.pop"));
|
||||
|
||||
selfImp.resetOutputStreamButton.set_activatable(true);
|
||||
selfImp.resetOutputStreamButton.set_action_name(Some("navigation.pop"));
|
||||
|
||||
selfImp.resetInputCardsBackButton.set_activatable(true);
|
||||
selfImp.resetInputCardsBackButton.set_action_name(Some("navigation.pop"));
|
||||
|
||||
let factory = &SignalListItemFactory::new();
|
||||
factory.connect_setup(|_, item| {
|
||||
|
@ -457,7 +458,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
|||
} else {
|
||||
imp.resetSelectedSource.set_active(false);
|
||||
}
|
||||
imp.resetSourceName.set_text(ir.source.alias.clone().as_str());
|
||||
imp.resetSourceName.set_title(ir.source.alias.clone().as_str());
|
||||
imp.resetVolumePercentage.set_text(&percentage);
|
||||
imp.resetVolumeSlider.set_value(*volume as f64);
|
||||
|
||||
|
@ -530,7 +531,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
|||
.set_icon_name("audio-input-microphone-symbolic");
|
||||
}
|
||||
let name = ir.stream.application_name.clone() + ": " + ir.stream.name.as_str();
|
||||
imp.resetSourceName.set_text(name.as_str());
|
||||
imp.resetSourceSelection.set_title(name.as_str());
|
||||
let volume = ir.stream.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
|
@ -539,7 +540,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
|||
let map = output_box_imp.resetSourceMap.read().unwrap();
|
||||
let index = map.get(&alias);
|
||||
if index.is_some() {
|
||||
imp.resetSelectedSource.set_selected(index.unwrap().1);
|
||||
imp.resetSourceSelection.set_selected(index.unwrap().1);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -35,11 +35,11 @@ pub struct SourceBox {
|
|||
#[template_child]
|
||||
pub resetSources: TemplateChild<gtk::Box>,
|
||||
#[template_child]
|
||||
pub resetOutputStreamButton: TemplateChild<ListEntry>,
|
||||
pub resetOutputStreamButton: TemplateChild<ActionRow>,
|
||||
#[template_child]
|
||||
pub resetOutputStreams: TemplateChild<gtk::Box>,
|
||||
#[template_child]
|
||||
pub resetInputCardsBackButton: TemplateChild<ListEntry>,
|
||||
pub resetInputCardsBackButton: TemplateChild<ActionRow>,
|
||||
#[template_child]
|
||||
pub resetCards: TemplateChild<PreferencesGroup>,
|
||||
pub resetDefaultCheckButton: Arc<CheckButton>,
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::time::{Duration, SystemTime};
|
|||
|
||||
use adw::glib;
|
||||
use adw::glib::Object;
|
||||
use adw::prelude::{ButtonExt, CheckButtonExt, RangeExt};
|
||||
use adw::prelude::{ButtonExt, CheckButtonExt, PreferencesRowExt, RangeExt};
|
||||
use dbus::blocking::Connection;
|
||||
use dbus::Error;
|
||||
use glib::subclass::types::ObjectSubclassIsExt;
|
||||
|
@ -15,7 +15,7 @@ use super::sourceEntryImpl;
|
|||
|
||||
glib::wrapper! {
|
||||
pub struct SourceEntry(ObjectSubclass<sourceEntryImpl::SourceEntry>)
|
||||
@extends gtk::Box, gtk::Widget,
|
||||
@extends adw::PreferencesGroup, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ impl SourceEntry {
|
|||
// TODO use event callback for progress bar -> this is the "im speaking" indicator
|
||||
{
|
||||
let imp = obj.imp();
|
||||
imp.resetSourceName.set_text(stream.alias.clone().as_str());
|
||||
imp.resetSourceName.set_title(stream.alias.clone().as_str());
|
||||
let name = Arc::new(stream.name.clone());
|
||||
let volume = stream.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use std::cell::RefCell;
|
||||
use std::sync::Arc;
|
||||
use std::time::SystemTime;
|
||||
use adw::{ActionRow, PreferencesGroup};
|
||||
use adw::subclass::prelude::PreferencesGroupImpl;
|
||||
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{glib, Button, CheckButton, CompositeTemplate, Label, ProgressBar, Scale};
|
||||
|
@ -13,7 +15,7 @@ use super::sourceEntry;
|
|||
#[template(resource = "/org/Xetibo/ReSet/resetSourceEntry.ui")]
|
||||
pub struct SourceEntry {
|
||||
#[template_child]
|
||||
pub resetSourceName: TemplateChild<Label>,
|
||||
pub resetSourceName: TemplateChild<ActionRow>,
|
||||
#[template_child]
|
||||
pub resetSelectedSource: TemplateChild<CheckButton>,
|
||||
#[template_child]
|
||||
|
@ -33,7 +35,7 @@ impl ObjectSubclass for SourceEntry {
|
|||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetSourceEntry";
|
||||
type Type = sourceEntry::SourceEntry;
|
||||
type ParentType = gtk::Box;
|
||||
type ParentType = PreferencesGroup;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
|
@ -44,7 +46,7 @@ impl ObjectSubclass for SourceEntry {
|
|||
}
|
||||
}
|
||||
|
||||
impl BoxImpl for SourceEntry {}
|
||||
impl PreferencesGroupImpl for SourceEntry {}
|
||||
|
||||
impl ObjectImpl for SourceEntry {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue