[blam] Show number of new posts in the tray-icon tooltip and the notification
- From: Carlos Martín Nieto <cmartin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [blam] Show number of new posts in the tray-icon tooltip and the notification
- Date: Sun, 6 Jun 2010 16:58:31 +0000 (UTC)
commit 0cba95320fe0b26f60a7f37f5b49480bdeaf1cd9
Author: Carlos MartÃn Nieto <carlos cmartin tk>
Date: Sun Jun 6 18:54:35 2010 +0200
Show number of new posts in the tray-icon tooltip and the notification
src/Application.cs | 7 ++++---
src/Channel.cs | 14 ++++++++++++++
src/ChannelCollection.cs | 20 ++++++++++++++++++--
src/ChannelGroup.cs | 15 +++++++++++++++
src/UnreadNotification.cs | 6 +++---
5 files changed, 54 insertions(+), 8 deletions(-)
---
diff --git a/src/Application.cs b/src/Application.cs
index fdfa8b6..6e34bda 100644
--- a/src/Application.cs
+++ b/src/Application.cs
@@ -847,17 +847,18 @@ namespace Imendio.Blam {
private void UpdateTotalNumberOfUnread ()
{
- int nrOfUnread;
+ int nrOfUnread, nrOfNew;
nrOfUnread = mCollection.NrOfUnreadItems;
+ nrOfNew = mCollection.NrOfNewItems;
channelsLabel.Markup = string.Format("<b>" +
channelsLabelText +
"</b>",
nrOfUnread);
- trayIcon.Tooltip = string.Format (Catalog.GetPluralString ("{0} unread item", "{0} unread items", nrOfUnread),
- nrOfUnread);
+ trayIcon.Tooltip = string.Format (Catalog.GetPluralString ("{0} unread item ({1} new)", "{0} unread items ({1} new)", nrOfUnread),
+ nrOfUnread, nrOfNew);
}
public static void SetProcessName(string name)
diff --git a/src/Channel.cs b/src/Channel.cs
index cb4311e..c979597 100644
--- a/src/Channel.cs
+++ b/src/Channel.cs
@@ -80,6 +80,20 @@ namespace Imendio.Blam {
}
}
+ public int NrOfNewItems {
+ get {
+ int new_items = 0;
+
+ foreach(Item item in mItems){
+ if(item.Unread && !item.Old){
+ ++new_items;
+ }
+ }
+
+ return new_items;
+ }
+ }
+
ArrayList mItems;
[XmlElement ("Item", typeof (Item))]
public ArrayList Items {
diff --git a/src/ChannelCollection.cs b/src/ChannelCollection.cs
index 6008836..74d26d3 100644
--- a/src/ChannelCollection.cs
+++ b/src/ChannelCollection.cs
@@ -65,6 +65,22 @@ namespace Imendio.Blam {
}
}
+ public int NrOfNewItems {
+ get {
+ int new_items = 0;
+
+ foreach(Channel channel in mChannels){
+ new_items += channel.NrOfNewItems;
+ }
+
+ foreach(ChannelGroup changrp in Groups){
+ new_items += changrp.NrOfNewItems;
+ }
+
+ return new_items;
+ }
+ }
+
public ChannelCollection ()
{
mQueue = Queue.Synchronized (new Queue ());
@@ -342,8 +358,8 @@ namespace Imendio.Blam {
#if ENABLE_NOTIFY
/* Make sure we have something to say and the user isn't watching us */
if(mQueue.Count == 0 &&
- NrOfUnreadItems != 0 && mainWindow.IsActive == false){
- UnreadNotification.NotifyUnreadPosts(NrOfUnreadItems);
+ NrOfUnreadItems != 0 && Application.TheApp.Window.IsActive == false){
+ UnreadNotification.NotifyUnreadPosts(NrOfUnreadItems, NrOfNewItems);
}
#endif
} catch (InvalidOperationException) {
diff --git a/src/ChannelGroup.cs b/src/ChannelGroup.cs
index a0242e0..2166e3c 100644
--- a/src/ChannelGroup.cs
+++ b/src/ChannelGroup.cs
@@ -47,6 +47,21 @@ namespace Imendio.Blam
}
}
+ public int NrOfNewItems {
+ get {
+ int nr = 0;
+
+ if(Channels.Count == 0)
+ return nr;
+
+ foreach(IChannel channel in Channels){
+ nr += channel.NrOfUnreadItems;
+ }
+
+ return nr;
+ }
+ }
+
public int NrOfItems {
get {
int n = 0;
diff --git a/src/UnreadNotification.cs b/src/UnreadNotification.cs
index 1fb062d..d47c7c0 100644
--- a/src/UnreadNotification.cs
+++ b/src/UnreadNotification.cs
@@ -14,11 +14,11 @@ namespace Imendio.Blam
note = new Notification();
}
- public static void NotifyUnreadPosts(int unread)
+ public static void NotifyUnreadPosts(int unread, int new_items)
{
/* Same as for the tray icon tooltip */
- String str = string.Format (Catalog.GetPluralString ("{0} unread item", "{0} unread items", unread),
- unread);
+ String str = string.Format (Catalog.GetPluralString ("{0} unread item ({1} new)", "{0} unread items ({1} new)", unread),
+ unread, new_items);
note.IconName = "blam";
note.Summary = Catalog.GetString("Feeds refreshed");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]