mirror of https://github.com/zlatinb/muwire
taskbar badge on windows
parent
25051a6b30
commit
7cc7027364
|
@ -17,6 +17,8 @@ import javax.swing.event.ChangeEvent
|
|||
import javax.swing.event.ChangeListener
|
||||
import javax.swing.tree.DefaultMutableTreeNode
|
||||
import java.awt.GridBagConstraints
|
||||
import java.awt.Image
|
||||
import java.awt.Window
|
||||
import java.util.function.Predicate
|
||||
|
||||
import static com.muwire.gui.Translator.trans
|
||||
|
@ -105,7 +107,7 @@ class MainFrameView {
|
|||
JPanel messageFolderContents
|
||||
|
||||
void initUI() {
|
||||
chatNotificator = new ChatNotificator(application.getMvcGroupManager())
|
||||
|
||||
settings = application.context.get("ui-settings")
|
||||
int rowHeight = application.context.get("row-height")
|
||||
|
||||
|
@ -780,6 +782,10 @@ class MainFrameView {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
chatNotificator = new ChatNotificator(application.getMvcGroupManager(),
|
||||
(Window)application.getWindowManager().findWindow("main-frame"),
|
||||
(Image) builder.imageIcon("/comment.png").image)
|
||||
|
||||
collectionsTable = builder.getVariable("collections-table")
|
||||
collectionFilesTable = builder.getVariable("items-table")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muwire.gui
|
||||
|
||||
import java.awt.Image
|
||||
import java.awt.Taskbar
|
||||
import java.awt.Taskbar.Feature
|
||||
|
||||
|
@ -8,6 +9,8 @@ import javax.swing.JTabbedPane
|
|||
|
||||
import griffon.core.mvc.MVCGroupManager
|
||||
|
||||
import java.awt.Window
|
||||
|
||||
class ChatNotificator {
|
||||
|
||||
public static interface Listener {
|
||||
|
@ -15,6 +18,8 @@ class ChatNotificator {
|
|||
}
|
||||
|
||||
private final MVCGroupManager groupManager
|
||||
private final Window window
|
||||
private final Image image
|
||||
|
||||
private boolean chatInFocus
|
||||
private String currentServerTab
|
||||
|
@ -24,8 +29,10 @@ class ChatNotificator {
|
|||
|
||||
private Listener listener
|
||||
|
||||
ChatNotificator(MVCGroupManager groupManager) {
|
||||
ChatNotificator(MVCGroupManager groupManager, Window window, Image image) {
|
||||
this.groupManager = groupManager
|
||||
this.window = window
|
||||
this.image = image
|
||||
}
|
||||
|
||||
void serverTabChanged(JTabbedPane source) {
|
||||
|
@ -92,17 +99,24 @@ class ChatNotificator {
|
|||
listener?.update()
|
||||
if (!Taskbar.isTaskbarSupported())
|
||||
return
|
||||
|
||||
int total = 0
|
||||
roomsWithMessages.values().each {
|
||||
total += it
|
||||
}
|
||||
|
||||
def taskBar = Taskbar.getTaskbar()
|
||||
if (!taskBar.isSupported(Feature.ICON_BADGE_NUMBER))
|
||||
return
|
||||
if (roomsWithMessages.isEmpty())
|
||||
taskBar.setIconBadge("")
|
||||
else {
|
||||
int total = 0
|
||||
roomsWithMessages.values().each {
|
||||
total += it
|
||||
if (taskBar.isSupported(Feature.ICON_BADGE_NUMBER)) {
|
||||
if (total == 0)
|
||||
taskBar.setIconBadge("")
|
||||
else {
|
||||
taskBar.setIconBadge(String.valueOf(total))
|
||||
}
|
||||
taskBar.setIconBadge(String.valueOf(total))
|
||||
} else if (taskBar.isSupported(Feature.ICON_BADGE_IMAGE_WINDOW)) {
|
||||
if (total > 0)
|
||||
taskBar.setWindowIconBadge(window, image)
|
||||
else
|
||||
taskBar.setWindowIconBadge(window, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue