status-area: Show icons that have icon_pixmap but not icon_name (#302)
This is at least one of the issue behind https://github.com/pop-os/cosmic-applets/issues/165. OBS now shows it's icon instead of an empty space. But the Mattermost flatpak doesn't show anything. (Is that Flatpak related, or does it not use `StatusNotifierItem`?) Requires https://github.com/pop-os/libcosmic/pull/368. Ideally, it should have some way to choose from multiple icons in memory of different sizes.
This commit is contained in:
parent
8128b6cf89
commit
180e75cb9a
4 changed files with 61 additions and 24 deletions
|
|
@ -174,11 +174,14 @@ impl cosmic::Application for App {
|
|||
fn view(&self) -> cosmic::Element<'_, Msg> {
|
||||
// XXX connect open event
|
||||
iced::widget::row(self.menus.iter().map(|(id, menu)| {
|
||||
self.core
|
||||
.applet
|
||||
.icon_button(menu.icon_name())
|
||||
.on_press(Msg::TogglePopup(*id))
|
||||
.into()
|
||||
match menu.icon_pixmap() {
|
||||
Some(icon) if menu.icon_name() == "" => {
|
||||
self.core.applet.icon_button_from_handle(icon.clone())
|
||||
}
|
||||
_ => self.core.applet.icon_button(menu.icon_name()),
|
||||
}
|
||||
.on_press(Msg::TogglePopup(*id))
|
||||
.into()
|
||||
}))
|
||||
.into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use cosmic::applet::menu_button;
|
||||
use cosmic::iced;
|
||||
use cosmic::{iced, widget::icon};
|
||||
|
||||
use crate::subscriptions::status_notifier_item::{Layout, StatusNotifierItem};
|
||||
|
||||
|
|
@ -65,6 +65,10 @@ impl State {
|
|||
self.item.icon_name()
|
||||
}
|
||||
|
||||
pub fn icon_pixmap(&self) -> Option<&icon::Handle> {
|
||||
self.item.icon_pixmap()
|
||||
}
|
||||
|
||||
pub fn popup_view(&self) -> cosmic::Element<Msg> {
|
||||
if let Some(layout) = self.layout.as_ref() {
|
||||
layout_view(layout, self.expanded)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue