From cfc99ff6f56886edd9be23ccbbb76b4d25f8c9ab Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Mon, 6 Jul 2026 07:50:47 +0200 Subject: [PATCH] fix: use list item factory ellipsize dropdown item label width --- src/ui/debug_view.rs | 13 +++++++------ src/ui/util.rs | 41 ++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ui/debug_view.rs b/src/ui/debug_view.rs index 7aa929b..0ab9eba 100644 --- a/src/ui/debug_view.rs +++ b/src/ui/debug_view.rs @@ -16,7 +16,7 @@ use crate::{ alert::alert, app::{BuildProfileAction, BuildProfileCleanAction}, profile_editor::{ProfileEditor, ProfileEditorInit, ProfileEditorMsg, ProfileEditorOutMsg}, - util::limit_dropdown_width, + util::ELLIPSIZED_LABEL_LIST_ITEM, }, util::file_utils::get_writer, }; @@ -263,14 +263,15 @@ impl AsyncComponent for DebugView { let names: Vec<_> = model.profiles.iter().map(|p| p.name.as_str()).collect(); gtk::StringList::new(&names) }), + set_factory: Some( + >k::BuilderListItemFactory::from_bytes( + Option::<>k::BuilderScope>::None, + >k::glib::Bytes::from_static(ELLIPSIZED_LABEL_LIST_ITEM.as_bytes()) + ) + ), connect_selected_item_notify[sender] => move |dd| { sender.input(Self::Input::ProfileSelected(dd.selected())); }, - connect_realize => move |dd| { - limit_dropdown_width( - dd, - ); - }, }, gtk::MenuButton { set_icon_name: "view-more-symbolic", diff --git a/src/ui/util.rs b/src/ui/util.rs index 13292fa..bd1ca7e 100644 --- a/src/ui/util.rs +++ b/src/ui/util.rs @@ -1,27 +1,6 @@ use gtk::{gdk, gio, glib::clone, prelude::*}; use tracing::{error, warn}; -pub fn limit_dropdown_width(dd: >k::DropDown) { - let mut dd_child = dd - .first_child() - .unwrap() - .first_child() - .unwrap() - .first_child() - .unwrap() - .last_child(); - loop { - if dd_child.is_none() { - break; - } - if let Ok(label) = dd_child.clone().unwrap().downcast::() { - label.set_ellipsize(gtk::pango::EllipsizeMode::End); - } - let nc = dd_child.unwrap().first_child().clone(); - dd_child = nc; - } -} - pub fn open_with_default_handler(uri: &str) { if let Err(e) = gio::AppInfo::launch_default_for_uri(uri, gio::AppLaunchContext::NONE) { error!("opening uri {uri}: {e}") @@ -180,3 +159,23 @@ pub fn info_card(level: InfoCardLevel, title: Option<&str>, text: &str) -> gtk:: pub fn warn_card(title: Option<&str>, text: &str) -> gtk::Box { info_card(InfoCardLevel::Warn, title, text) } + +pub const ELLIPSIZED_LABEL_LIST_ITEM: &str = r#" + + + + +"#; -- 2.51.2