mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 14:21:03 +02:00
fix(tray): menus not attaching to secondary bars
This commit is contained in:
parent
48dc65f60b
commit
5aa9f37fe4
2 changed files with 11 additions and 4 deletions
|
@ -7,7 +7,7 @@ use system_tray::item::{IconPixmap, StatusNotifierItem, Tooltip};
|
|||
/// Main tray icon to show on the bar
|
||||
pub(crate) struct TrayMenu {
|
||||
pub event_box: EventBox,
|
||||
pub widget: MenuItem,
|
||||
widget: MenuItem,
|
||||
image_widget: Option<Image>,
|
||||
label_widget: Option<Label>,
|
||||
|
||||
|
@ -18,7 +18,7 @@ pub(crate) struct TrayMenu {
|
|||
}
|
||||
|
||||
impl TrayMenu {
|
||||
pub fn new(item: StatusNotifierItem) -> Self {
|
||||
pub fn new(address: &str, item: StatusNotifierItem) -> Self {
|
||||
let event_box = EventBox::new();
|
||||
|
||||
let widget = MenuItem::new();
|
||||
|
@ -27,7 +27,7 @@ impl TrayMenu {
|
|||
|
||||
event_box.show_all();
|
||||
|
||||
Self {
|
||||
let mut slf = Self {
|
||||
event_box,
|
||||
widget,
|
||||
image_widget: None,
|
||||
|
@ -36,7 +36,14 @@ impl TrayMenu {
|
|||
icon_name: item.icon_name,
|
||||
icon_theme_path: item.icon_theme_path,
|
||||
icon_pixmap: item.icon_pixmap,
|
||||
};
|
||||
|
||||
if let Some(menu) = item.menu {
|
||||
let menu = system_tray::gtk_menu::Menu::new(address, &menu);
|
||||
slf.set_menu_widget(menu);
|
||||
}
|
||||
|
||||
slf
|
||||
}
|
||||
|
||||
/// Updates the label text, and shows it in favour of the image.
|
||||
|
|
|
@ -150,7 +150,7 @@ fn on_update(
|
|||
Event::Add(address, item) => {
|
||||
debug!("Received new tray item at '{address}': {item:?}");
|
||||
|
||||
let mut menu_item = TrayMenu::new(*item);
|
||||
let mut menu_item = TrayMenu::new(&address, *item);
|
||||
container.pack_start(&menu_item.event_box, true, true, 0);
|
||||
|
||||
if let Ok(image) = icon::get_image(&menu_item, icon_theme, icon_size, prefer_icons) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue