mirror of https://github.com/zlatinb/muwire
icon badge on windows and some linux desktop environments
parent
5e23c1b823
commit
68c8948da7
|
@ -6,6 +6,9 @@ import com.muwire.core.search.ResultsEvent
|
|||
|
||||
import javax.swing.DefaultListModel
|
||||
import javax.swing.SwingWorker
|
||||
import java.awt.Image
|
||||
import java.awt.TrayIcon
|
||||
import java.awt.Window
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
import javax.annotation.Nonnull
|
||||
|
@ -228,7 +231,10 @@ class MainFrameModel {
|
|||
|
||||
uiSettings = application.context.get("ui-settings")
|
||||
|
||||
messageNotificator = new MessageNotificator(uiSettings, application.context.get("tray-icon"))
|
||||
messageNotificator = new MessageNotificator(uiSettings,
|
||||
(TrayIcon) application.context.get("tray-icon"),
|
||||
(Window) application.getWindowManager().findWindow("main-frame"),
|
||||
(Image) view.builder.imageIcon("/comment.png").image)
|
||||
|
||||
shared = []
|
||||
treeRoot = new DefaultMutableTreeNode()
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.muwire.gui
|
||||
|
||||
import java.awt.Image
|
||||
import java.awt.Window
|
||||
|
||||
import static com.muwire.gui.Translator.trans
|
||||
import java.awt.Taskbar
|
||||
import java.awt.Taskbar.Feature
|
||||
|
@ -9,9 +12,13 @@ class MessageNotificator {
|
|||
|
||||
private final UISettings settings
|
||||
private final TrayIcon trayIcon
|
||||
MessageNotificator(UISettings settings, TrayIcon trayIcon) {
|
||||
private final Window window
|
||||
private final Image image
|
||||
MessageNotificator(UISettings settings, TrayIcon trayIcon, Window window, Image image) {
|
||||
this.settings = settings
|
||||
this.trayIcon = trayIcon
|
||||
this.window = window
|
||||
this.image = image
|
||||
}
|
||||
|
||||
void newMessage(String from) {
|
||||
|
@ -38,6 +45,11 @@ class MessageNotificator {
|
|||
taskBar.setIconBadge(String.valueOf(count))
|
||||
else
|
||||
taskBar.setIconBadge("")
|
||||
} else if (taskBar.isSupported(Feature.ICON_BADGE_IMAGE_WINDOW)) {
|
||||
if (count == 0)
|
||||
taskBar.setWindowIconBadge(window, null)
|
||||
else
|
||||
taskBar.setWindowIconBadge(window, image)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue