small fixes

This commit is contained in:
Ashley Wulber 2021-12-21 18:45:57 -05:00
parent a3349e673f
commit 6be5b84b24
4 changed files with 13 additions and 5 deletions

View file

@ -11,9 +11,7 @@
</object>
</child>
<child>
<object class="GtkBox" id="dots">
<property name="orientation">horizontal</property>
<property name="spacing">4</property>
<object class="GtkLabel" id="dots">
<property name="hexpand">true</property>
<property name="halign">center</property>
</object>

View file

@ -13,7 +13,7 @@ pub struct DockItem {
#[template_child]
pub image: TemplateChild<gtk::Image>,
#[template_child]
pub dots: TemplateChild<gtk::Box>,
pub dots: TemplateChild<gtk::Label>,
pub drag_controller: OnceCell<DragSource>,
}

View file

@ -5,9 +5,12 @@ use gio::DesktopAppInfo;
use gio::Icon;
use gio::ListStore;
use gtk4 as gtk;
use gtk4::Align;
use gtk4::Box;
use gtk4::DragSource;
use gtk4::IconTheme;
use gtk4::Label;
use gtk4::Orientation;
mod imp;
use gtk::glib;
@ -121,8 +124,11 @@ impl DockItem {
}
if let Ok(active_value) = app_info.property("active") {
if let Ok(active) = active_value.get::<BoxedSearchResults>() {
self_.dots.set_text("");
for _ in active.0 {
self_.dots.append(&Label::new(Some("·")));
self_
.dots
.set_text(format!("{}{}", self_.dots.text(), " · ").as_str());
}
}
}

View file

@ -131,10 +131,14 @@ fn main() {
//TODO refresh the model from cached_results (required after DnD for example)
}
Event::Response(event) => {
// TODO investigate why polled results are out of date after launching a new window
if let pop_launcher::Response::Update(mut results) = event {
// sort to make comparison with cache easier
let mut cached_results = cached_results.as_mut();
results.sort_by(|a, b| a.name.cmp(&b.name));
dbg!(&results);
dbg!(&cached_results);
// check if cache equals the new polled results
// skip if equal
if cached_results.len() == results.len() && results.iter().zip(cached_results.iter()).fold(0, |acc, z: (&SearchResult, &SearchResult)| {