[blam] Use the runtime's timers instead of glib's
- From: Carlos Martín Nieto <cmartin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [blam] Use the runtime's timers instead of glib's
- Date: Fri, 14 Jun 2013 00:17:06 +0000 (UTC)
commit c7382d52c0d1e4264f8f30954d9637acf8970a62
Author: Carlos Martín Nieto <cmn dwim me>
Date: Thu Jun 13 05:52:20 2013 +0200
Use the runtime's timers instead of glib's
src/ItemList.cs | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/src/ItemList.cs b/src/ItemList.cs
index b5863b5..f020946 100644
--- a/src/ItemList.cs
+++ b/src/ItemList.cs
@@ -12,6 +12,7 @@ using GLib;
using GtkSharp;
using System;
using System.Collections;
+using System.Threading;
using System.ServiceModel.Syndication;
namespace Imendio.Blam {
@@ -27,7 +28,8 @@ namespace Imendio.Blam {
private TreeViewColumn iconColumn;
private Item lastItem;
- private uint lastTimeout;
+ Timer timer;
+ const int infinite = System.Threading.Timeout.Infinite;
private IChannel channel;
public IChannel CurrentChannel {
@@ -179,27 +181,26 @@ namespace Imendio.Blam {
EmitItemSelected (item);
bool useTimeout = (bool) Conf.Get(Preference.MARK_ITEMS_READ, false);
- if(useTimeout){
- if(lastTimeout > 0)
- GLib.Source.Remove(lastTimeout);
+ if(useTimeout) {
+ if (timer == null) {
+ timer = new Timer(o => {
+ if (lastItem == GetSelected())
+ lastItem.SetUnread(false);
+ });
+ }
+
+ // disable the old timeout
+ timer.Change(infinite, infinite);
uint readTimeout = (uint) Conf.Get(Preference.MARK_ITEMS_READ_TIMEOUT, 3000);
lastItem = item;
- lastTimeout = GLib.Timeout.Add(readTimeout, new GLib.TimeoutHandler (SetToRead));
+ timer.Change(readTimeout, infinite);
} else {
item.SetUnread(false);
}
}
}
- private bool SetToRead()
- {
- if(lastItem == GetSelected())
- lastItem.SetUnread(false);
-
- return false;
- }
-
private int CompareFunc(TreeModel model, TreeIter a, TreeIter b)
{
Item ia = Model.GetValue(a, 0) as Item;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]