improve ui

This commit is contained in:
takotori 2023-12-14 15:53:56 +01:00
parent 834a462e4b
commit db501b2e93
17 changed files with 320 additions and 260 deletions

View file

@ -10,6 +10,7 @@ use glib::subclass::types::ObjectSubclassIsExt;
use glib::{clone, Propagation};
use gtk::{gio, CheckButton};
use re_set_lib::audio::audio_structures::Source;
use crate::components::utils::set_action_row_ellipsis;
use crate::components::utils::{BASE, DBUS_PATH, AUDIO};
@ -98,6 +99,7 @@ impl SourceEntry {
}
toggle_source_mute(source.index, source.muted);
}));
set_action_row_ellipsis(imp.reset_source_name.get());
}
obj
}

View file

@ -10,6 +10,7 @@ use glib::subclass::types::ObjectSubclassIsExt;
use glib::{clone, Propagation};
use gtk::{gio, CheckButton};
use re_set_lib::audio::audio_structures::Sink;
use crate::components::utils::set_action_row_ellipsis;
use crate::components::utils::{AUDIO, DBUS_PATH, BASE};
@ -96,6 +97,7 @@ impl SinkEntry {
}
toggle_sink_mute(stream.index, stream.muted);
}));
set_action_row_ellipsis(imp.reset_sink_name.get());
}
obj
}

View file

@ -1,9 +1,9 @@
use adw::{ActionRow, ComboRow};
use adw::gdk::pango::EllipsizeMode;
use adw::prelude::ListModelExtManual;
use adw::ComboRow;
use glib::{Cast, Object};
use gtk::prelude::{GObjectPropertyExpressionExt, ListBoxRowExt, ListItemExt, WidgetExt};
use gtk::{Align, SignalListItemFactory, StringObject};
use gtk::prelude::{GObjectPropertyExpressionExt, ListBoxRowExt, ListItemExt, WidgetExt};
pub const DBUS_PATH: &str = "/org/Xetibo/ReSet/Daemon";
pub const WIRELESS: &str = "org.Xetibo.ReSet.Wireless";
@ -17,22 +17,14 @@ pub fn create_dropdown_label_factory() -> SignalListItemFactory {
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
let label = gtk::Label::new(None);
label.set_halign(Align::Start);
item.property_expression("item")
.chain_property::<StringObject>("string")
.bind(&label, "label", gtk::Widget::NONE);
item.property_expression("item").chain_property::<StringObject>("string").bind(&label, "label", gtk::Widget::NONE);
item.set_child(Some(&label));
});
factory
}
pub fn set_combo_row_ellipsis(element: ComboRow) {
for (i, child) in element
.child()
.unwrap()
.observe_children()
.iter::<Object>()
.enumerate()
{
for (i, child) in element.child().unwrap().observe_children().iter::<Object>().enumerate() {
if i == 2 {
if let Ok(object) = child {
if let Some(item) = object.downcast_ref::<gtk::Box>() {
@ -47,3 +39,23 @@ pub fn set_combo_row_ellipsis(element: ComboRow) {
}
}
}
pub fn set_action_row_ellipsis(element: ActionRow) {
let option = element.first_child();
if let Some(first_box) = option {
for (i, child) in first_box.observe_children().iter::<Object>().enumerate() {
if i == 2 {
if let Ok(object) = child {
if let Some(item) = object.downcast_ref::<gtk::Box>() {
if let Some(widget) = item.first_child() {
if let Some(label) = widget.downcast_ref::<gtk::Label>() {
label.set_ellipsize(EllipsizeMode::End);
label.set_max_width_chars(1);
}
}
}
}
}
}
}
}

View file

@ -3,7 +3,7 @@ use adw::subclass::prelude::ObjectSubclassIsExt;
use adw::BreakpointCondition;
use glib::Object;
use gtk::gio::ActionEntry;
use gtk::{gio, glib, Application, ListBoxRow, Orientation};
use gtk::{gio, glib, Application, ListBoxRow, Orientation, AccessibleRole};
use gtk::{prelude::*, DirectionType};
use crate::components::window::handle_sidebar_click::*;