Subject: [PATCH] Click on journal icons with a exclusive time frame

From: Martin Abente <[email-masked]>
Date: Tue, 1 Jun 2010 16:50:17 -0400

Double-or-more clicks on Journal icons causes multiple activities
instances, saturating the whole evironment
---
 src/jarabe/journal/listview.py |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
index 9e19f70..2974f16 100644
--- a/src/jarabe/journal/listview.py
+++ b/src/jarabe/journal/listview.py
@@ -39,6 +39,8 @@ UPDATE_INTERVAL = 300
 MESSAGE_EMPTY_JOURNAL = 0
 MESSAGE_NO_MATCH = 1
 
+EXCLUSIVITY_TIME = 2000
+
 class TreeView(gtk.TreeView):
     __gtype_name__ = 'JournalTreeView'
 
@@ -467,6 +469,7 @@ class ListView(BaseListView):
     def __init__(self):
         BaseListView.__init__(self)
         self._is_dragging = False
+        self._exclusivity_timer = None
 
         self.tree_view.connect('drag-begin', self.__drag_begin_cb)
         self.tree_view.connect('button-release-event',
@@ -475,7 +478,7 @@ class ListView(BaseListView):
         self.cell_title.connect('edited', self.__cell_title_edited_cb)
         self.cell_title.connect('editing-canceled', self.__editing_canceled_cb)
 
-        self.cell_icon.connect('clicked', self.__icon_clicked_cb)
+        self.cell_icon.connect('clicked', self.__icon_clicked_exclusively)
         self.cell_icon.connect('detail-clicked', self.__detail_clicked_cb)
 
         cell_detail = CellRendererDetail(self.tree_view)
@@ -518,6 +521,16 @@ class ListView(BaseListView):
     def __detail_clicked_cb(self, cell, uid):
         self.emit('detail-clicked', uid)
 
+    def __icon_clicked_exclusively(self, cell, path):
+       if self._exclusivity_timer == None:
+            self._exclusivity_timer = gobject.timeout_add(EXCLUSIVITY_TIME, self.__allow_clicking)
+            self.__icon_clicked_cb(cell, path)
+       else:
+            logging.debug(_('Sorry, too soon to activate this icon again'))
+
+    def __allow_clicking(self):
+        self._exclusivity_timer = None
+
     def __icon_clicked_cb(self, cell, path):
         row = self.tree_view.get_model()[path]
         metadata = model.get(row[ListModel.COLUMN_UID])
-- 
1.6.0.4