mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-17 10:18:32 +02:00
Add ellipsis to labels in ComboRow
This commit is contained in:
parent
00ffb7faf9
commit
f7c95cd4a1
|
@ -10,7 +10,7 @@ use glib::subclass::types::ObjectSubclassIsExt;
|
||||||
use glib::{clone, Cast, Propagation};
|
use glib::{clone, Cast, Propagation};
|
||||||
use gtk::{gio, StringObject};
|
use gtk::{gio, StringObject};
|
||||||
use ReSet_Lib::audio::audio::OutputStream;
|
use ReSet_Lib::audio::audio::OutputStream;
|
||||||
use crate::components::utils::createDropdownLabelFactory;
|
use crate::components::utils::{createDropdownLabelFactory, setComboRowEllipsis};
|
||||||
|
|
||||||
use super::outputStreamEntryImpl;
|
use super::outputStreamEntryImpl;
|
||||||
use super::sourceBox::SourceBox;
|
use super::sourceBox::SourceBox;
|
||||||
|
@ -34,6 +34,7 @@ impl OutputStreamEntry {
|
||||||
let name = stream.application_name.clone() + ": " + stream.name.as_str();
|
let name = stream.application_name.clone() + ": " + stream.name.as_str();
|
||||||
imp.resetSourceSelection.set_title(name.as_str());
|
imp.resetSourceSelection.set_title(name.as_str());
|
||||||
imp.resetSourceSelection.set_factory(Some(&createDropdownLabelFactory()));
|
imp.resetSourceSelection.set_factory(Some(&createDropdownLabelFactory()));
|
||||||
|
setComboRowEllipsis(imp.resetSourceSelection.get());
|
||||||
let volume = stream.volume.first().unwrap_or(&0_u32);
|
let volume = stream.volume.first().unwrap_or(&0_u32);
|
||||||
let fraction = (*volume as f64 / 655.36).round();
|
let fraction = (*volume as f64 / 655.36).round();
|
||||||
let percentage = (fraction).to_string() + "%";
|
let percentage = (fraction).to_string() + "%";
|
||||||
|
|
|
@ -22,7 +22,7 @@ use crate::components::base::utils::{
|
||||||
};
|
};
|
||||||
use crate::components::input::sourceBoxImpl;
|
use crate::components::input::sourceBoxImpl;
|
||||||
use crate::components::input::sourceEntry::set_source_volume;
|
use crate::components::input::sourceEntry::set_source_volume;
|
||||||
use crate::components::utils::createDropdownLabelFactory;
|
use crate::components::utils::{createDropdownLabelFactory, setComboRowEllipsis};
|
||||||
|
|
||||||
use super::outputStreamEntry::OutputStreamEntry;
|
use super::outputStreamEntry::OutputStreamEntry;
|
||||||
use super::sourceEntry::{set_default_source, SourceEntry, toggle_source_mute};
|
use super::sourceEntry::{set_default_source, SourceEntry, toggle_source_mute};
|
||||||
|
@ -65,6 +65,7 @@ impl SourceBox {
|
||||||
selfImp.resetInputCardsBackButton.set_action_name(Some("navigation.pop"));
|
selfImp.resetInputCardsBackButton.set_action_name(Some("navigation.pop"));
|
||||||
|
|
||||||
selfImp.resetSourceDropdown.set_factory(Some(&createDropdownLabelFactory()));
|
selfImp.resetSourceDropdown.set_factory(Some(&createDropdownLabelFactory()));
|
||||||
|
setComboRowEllipsis(selfImp.resetSourceDropdown.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use glib::subclass::types::ObjectSubclassIsExt;
|
||||||
use glib::{clone, Cast, Propagation};
|
use glib::{clone, Cast, Propagation};
|
||||||
use gtk::{gio, StringObject};
|
use gtk::{gio, StringObject};
|
||||||
use ReSet_Lib::audio::audio::InputStream;
|
use ReSet_Lib::audio::audio::InputStream;
|
||||||
use crate::components::utils::createDropdownLabelFactory;
|
use crate::components::utils::{createDropdownLabelFactory, setComboRowEllipsis};
|
||||||
|
|
||||||
use super::inputStreamEntryImpl;
|
use super::inputStreamEntryImpl;
|
||||||
use super::sinkBox::SinkBox;
|
use super::sinkBox::SinkBox;
|
||||||
|
@ -39,6 +39,7 @@ impl InputStreamEntry {
|
||||||
let name = stream.application_name.clone() + ": " + stream.name.as_str();
|
let name = stream.application_name.clone() + ": " + stream.name.as_str();
|
||||||
imp.resetSinkSelection.set_title(name.as_str());
|
imp.resetSinkSelection.set_title(name.as_str());
|
||||||
imp.resetSinkSelection.set_factory(Some(&createDropdownLabelFactory()));
|
imp.resetSinkSelection.set_factory(Some(&createDropdownLabelFactory()));
|
||||||
|
setComboRowEllipsis(imp.resetSinkSelection.get());
|
||||||
let volume = stream.volume.first().unwrap_or(&0_u32);
|
let volume = stream.volume.first().unwrap_or(&0_u32);
|
||||||
let fraction = (*volume as f64 / 655.36).round();
|
let fraction = (*volume as f64 / 655.36).round();
|
||||||
let percentage = (fraction).to_string() + "%";
|
let percentage = (fraction).to_string() + "%";
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::components::base::utils::{
|
||||||
InputStreamAdded, InputStreamChanged, InputStreamRemoved, SinkAdded, SinkChanged, SinkRemoved,
|
InputStreamAdded, InputStreamChanged, InputStreamRemoved, SinkAdded, SinkChanged, SinkRemoved,
|
||||||
};
|
};
|
||||||
use crate::components::output::sinkEntry::set_sink_volume;
|
use crate::components::output::sinkEntry::set_sink_volume;
|
||||||
use crate::components::utils::createDropdownLabelFactory;
|
use crate::components::utils::{createDropdownLabelFactory, setComboRowEllipsis};
|
||||||
|
|
||||||
use super::inputStreamEntry::InputStreamEntry;
|
use super::inputStreamEntry::InputStreamEntry;
|
||||||
use super::sinkBoxImpl;
|
use super::sinkBoxImpl;
|
||||||
|
@ -72,6 +72,7 @@ impl SinkBox {
|
||||||
selfImp.resetInputCardsBackButton.set_action_name(Some("navigation.pop"));
|
selfImp.resetInputCardsBackButton.set_action_name(Some("navigation.pop"));
|
||||||
|
|
||||||
selfImp.resetSinkDropdown.set_factory(Some(&createDropdownLabelFactory()));
|
selfImp.resetSinkDropdown.set_factory(Some(&createDropdownLabelFactory()));
|
||||||
|
setComboRowEllipsis(selfImp.resetSinkDropdown.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
use glib::Cast;
|
use adw::ComboRow;
|
||||||
|
use adw::gdk::pango::EllipsizeMode;
|
||||||
|
use adw::prelude::ListModelExtManual;
|
||||||
|
use glib::{Cast, Object};
|
||||||
use gtk::{Align, SignalListItemFactory, StringObject};
|
use gtk::{Align, SignalListItemFactory, StringObject};
|
||||||
use gtk::prelude::{GObjectPropertyExpressionExt, ListItemExt, WidgetExt};
|
use gtk::prelude::{GObjectPropertyExpressionExt, ListBoxRowExt, ListItemExt, WidgetExt};
|
||||||
|
|
||||||
pub fn createDropdownLabelFactory() -> SignalListItemFactory {
|
pub fn createDropdownLabelFactory() -> SignalListItemFactory {
|
||||||
let factory = SignalListItemFactory::new();
|
let factory = SignalListItemFactory::new();
|
||||||
|
@ -14,4 +17,21 @@ pub fn createDropdownLabelFactory() -> SignalListItemFactory {
|
||||||
item.set_child(Some(&label));
|
item.set_child(Some(&label));
|
||||||
});
|
});
|
||||||
factory
|
factory
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn setComboRowEllipsis(element: ComboRow) {
|
||||||
|
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>() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -22,6 +22,7 @@ use gtk::prelude::{ActionableExt, WidgetExt};
|
||||||
use ReSet_Lib::network::network::{AccessPoint, WifiStrength};
|
use ReSet_Lib::network::network::{AccessPoint, WifiStrength};
|
||||||
use ReSet_Lib::signals::{AccessPointAdded};
|
use ReSet_Lib::signals::{AccessPointAdded};
|
||||||
use ReSet_Lib::signals::{AccessPointChanged, AccessPointRemoved};
|
use ReSet_Lib::signals::{AccessPointChanged, AccessPointRemoved};
|
||||||
|
use crate::components::utils::setComboRowEllipsis;
|
||||||
|
|
||||||
|
|
||||||
use crate::components::wifi::wifiBoxImpl;
|
use crate::components::wifi::wifiBoxImpl;
|
||||||
|
@ -56,6 +57,7 @@ impl WifiBox {
|
||||||
|
|
||||||
selfImp.resetAvailableNetworks.set_activatable(true);
|
selfImp.resetAvailableNetworks.set_activatable(true);
|
||||||
selfImp.resetAvailableNetworks.set_action_name(Some("navigation.pop"));
|
selfImp.resetAvailableNetworks.set_action_name(Some("navigation.pop"));
|
||||||
|
setComboRowEllipsis(selfImp.resetWiFiDevice.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue