Browse Source

Add an event for unread status changes.

pull/311/head
Chris Smith 9 years ago
parent
commit
9a19431320

+ 58
- 0
src/com/dmdirc/events/UnreadStatusChangedEvent.java View File

@@ -0,0 +1,58 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.FrameContainer;
26
+import com.dmdirc.util.colours.Colour;
27
+
28
+import java.util.Optional;
29
+
30
+/**
31
+ * Event raised when the unread status of a window has changed.
32
+ */
33
+public class UnreadStatusChangedEvent extends DMDircEvent {
34
+
35
+    private final FrameContainer source;
36
+    private final Optional<Colour> notificationColour;
37
+    private final int unreadCount;
38
+
39
+    public UnreadStatusChangedEvent(final FrameContainer source,
40
+            final Optional<Colour> notificationColour, final int unreadCount) {
41
+        this.source = source;
42
+        this.notificationColour = notificationColour;
43
+        this.unreadCount = unreadCount;
44
+    }
45
+
46
+    public FrameContainer getSource() {
47
+        return source;
48
+    }
49
+
50
+    public Optional<Colour> getNotificationColour() {
51
+        return notificationColour;
52
+    }
53
+
54
+    public int getUnreadCount() {
55
+        return unreadCount;
56
+    }
57
+
58
+}

+ 4
- 0
src/com/dmdirc/ui/messages/UnreadStatusManager.java View File

@@ -29,6 +29,7 @@ import com.dmdirc.events.BaseQueryTextEvent;
29 29
 import com.dmdirc.events.ChannelHighlightEvent;
30 30
 import com.dmdirc.events.DisplayableEvent;
31 31
 import com.dmdirc.events.QueryHighlightEvent;
32
+import com.dmdirc.events.UnreadStatusChangedEvent;
32 33
 import com.dmdirc.util.colours.Colour;
33 34
 
34 35
 import java.util.Optional;
@@ -112,6 +113,9 @@ public class UnreadStatusManager {
112 113
         } else {
113 114
             notificationColour = Optional.of(colour);
114 115
         }
116
+
117
+        eventBus.publishAsync(new UnreadStatusChangedEvent(container, notificationColour,
118
+                unreadLines));
115 119
     }
116 120
 
117 121
 }

Loading…
Cancel
Save