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.event.ChangeListener
|
||||||
import javax.swing.tree.DefaultMutableTreeNode
|
import javax.swing.tree.DefaultMutableTreeNode
|
||||||
import java.awt.GridBagConstraints
|
import java.awt.GridBagConstraints
|
||||||
|
import java.awt.Image
|
||||||
|
import java.awt.Window
|
||||||
import java.util.function.Predicate
|
import java.util.function.Predicate
|
||||||
|
|
||||||
import static com.muwire.gui.Translator.trans
|
import static com.muwire.gui.Translator.trans
|
||||||
|
@ -105,7 +107,7 @@ class MainFrameView {
|
||||||
JPanel messageFolderContents
|
JPanel messageFolderContents
|
||||||
|
|
||||||
void initUI() {
|
void initUI() {
|
||||||
chatNotificator = new ChatNotificator(application.getMvcGroupManager())
|
|
||||||
settings = application.context.get("ui-settings")
|
settings = application.context.get("ui-settings")
|
||||||
int rowHeight = application.context.get("row-height")
|
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")
|
collectionsTable = builder.getVariable("collections-table")
|
||||||
collectionFilesTable = builder.getVariable("items-table")
|
collectionFilesTable = builder.getVariable("items-table")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muwire.gui
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import java.awt.Image
|
||||||
import java.awt.Taskbar
|
import java.awt.Taskbar
|
||||||
import java.awt.Taskbar.Feature
|
import java.awt.Taskbar.Feature
|
||||||
|
|
||||||
|
@ -8,6 +9,8 @@ import javax.swing.JTabbedPane
|
||||||
|
|
||||||
import griffon.core.mvc.MVCGroupManager
|
import griffon.core.mvc.MVCGroupManager
|
||||||
|
|
||||||
|
import java.awt.Window
|
||||||
|
|
||||||
class ChatNotificator {
|
class ChatNotificator {
|
||||||
|
|
||||||
public static interface Listener {
|
public static interface Listener {
|
||||||
|
@ -15,6 +18,8 @@ class ChatNotificator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MVCGroupManager groupManager
|
private final MVCGroupManager groupManager
|
||||||
|
private final Window window
|
||||||
|
private final Image image
|
||||||
|
|
||||||
private boolean chatInFocus
|
private boolean chatInFocus
|
||||||
private String currentServerTab
|
private String currentServerTab
|
||||||
|
@ -24,8 +29,10 @@ class ChatNotificator {
|
||||||
|
|
||||||
private Listener listener
|
private Listener listener
|
||||||
|
|
||||||
ChatNotificator(MVCGroupManager groupManager) {
|
ChatNotificator(MVCGroupManager groupManager, Window window, Image image) {
|
||||||
this.groupManager = groupManager
|
this.groupManager = groupManager
|
||||||
|
this.window = window
|
||||||
|
this.image = image
|
||||||
}
|
}
|
||||||
|
|
||||||
void serverTabChanged(JTabbedPane source) {
|
void serverTabChanged(JTabbedPane source) {
|
||||||
|
@ -92,17 +99,24 @@ class ChatNotificator {
|
||||||
listener?.update()
|
listener?.update()
|
||||||
if (!Taskbar.isTaskbarSupported())
|
if (!Taskbar.isTaskbarSupported())
|
||||||
return
|
return
|
||||||
|
|
||||||
|
int total = 0
|
||||||
|
roomsWithMessages.values().each {
|
||||||
|
total += it
|
||||||
|
}
|
||||||
|
|
||||||
def taskBar = Taskbar.getTaskbar()
|
def taskBar = Taskbar.getTaskbar()
|
||||||
if (!taskBar.isSupported(Feature.ICON_BADGE_NUMBER))
|
if (taskBar.isSupported(Feature.ICON_BADGE_NUMBER)) {
|
||||||
return
|
if (total == 0)
|
||||||
if (roomsWithMessages.isEmpty())
|
taskBar.setIconBadge("")
|
||||||
taskBar.setIconBadge("")
|
else {
|
||||||
else {
|
taskBar.setIconBadge(String.valueOf(total))
|
||||||
int total = 0
|
|
||||||
roomsWithMessages.values().each {
|
|
||||||
total += it
|
|
||||||
}
|
}
|
||||||
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