Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-11-13 10:19:59 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-11-13 10:19:59 (GMT)
commit83d4dd693f87890141b4a474d2d3c01af1c6e626 (patch)
treef46abe9baf7319fd9c1ad3bb752c8fe044b1e228
parent1648c5dd2e9c343f65b5797438dd80fbeb27a9a7 (diff)
#4638 Update dates when the journal is displayed.
-rw-r--r--NEWS1
-rw-r--r--collapsedentry.py4
-rwxr-xr-xjournalactivity.py21
-rw-r--r--listview.py4
-rw-r--r--misc.py3
5 files changed, 31 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index cfceebf..e38491d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+* #4638 Update dates when the journal is displayed. (tomeu)
* #4409 Fix showing malformed bundles. (tomeu)
69
diff --git a/collapsedentry.py b/collapsedentry.py
index fae9a35..017cdfe 100644
--- a/collapsedentry.py
+++ b/collapsedentry.py
@@ -268,3 +268,7 @@ class CollapsedEntry(hippo.CanvasBox):
return self._jobject
jobject = property(get_jobject, set_jobject)
+
+ def update_date(self):
+ self._date.props.text = misc.get_date(self._jobject)
+
diff --git a/journalactivity.py b/journalactivity.py
index 468bfc3..5aee640 100755
--- a/journalactivity.py
+++ b/journalactivity.py
@@ -43,6 +43,8 @@ J_DBUS_SERVICE = 'org.laptop.Journal'
J_DBUS_INTERFACE = 'org.laptop.Journal'
J_DBUS_PATH = '/org/laptop/Journal'
+UPDATE_INTERVAL = 300000
+
class JournalActivityDBusService(dbus.service.Object):
def __init__(self, parent):
self._parent = parent
@@ -75,10 +77,14 @@ class JournalActivity(activity.Activity):
self.set_title(_('Journal'))
self._can_close = False
+ self._update_timer = None
self.iconify()
self._setup_main_view()
self._setup_secondary_view()
+
+ self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
+ self.connect('visibility-notify-event', self.__visibility_notify_event_cb)
self.connect('key-press-event', self._key_press_event_cb)
self.connect('focus-in-event', self._focus_in_event_cb)
@@ -193,6 +199,7 @@ class JournalActivity(activity.Activity):
def _focus_in_event_cb(self, window, event):
self.search_grab_focus()
+ self._list_view.update_dates()
def _check_for_bundle(self, jobject):
bundle = misc.get_bundle(jobject)
@@ -220,3 +227,17 @@ class JournalActivity(activity.Activity):
search_toolbar = self._main_toolbox.search_toolbar
search_toolbar._search_entry.grab_focus()
+ def __update_timer_cb(self):
+ self._list_view.update_dates()
+ return True
+
+ def __visibility_notify_event_cb(self, window, event):
+ if event.state == gtk.gdk.VISIBILITY_FULLY_OBSCURED:
+ if self._update_timer is not None:
+ gobject.source_remove(self._update_timer)
+ self._update_timer = None
+ else:
+ if self._update_timer is None:
+ self._update_timer = gobject.timeout_add(UPDATE_INTERVAL,
+ self.__update_timer_cb)
+
diff --git a/listview.py b/listview.py
index 6c05d13..334d9b1 100644
--- a/listview.py
+++ b/listview.py
@@ -338,3 +338,7 @@ class ListView(gtk.HBox):
logging.debug('_result_set_modified_cb')
self._do_scroll(force=True)
+ def update_dates(self):
+ logging.debug('ListView.update_dates')
+ for entry in self._entries:
+ entry.update_date()
diff --git a/misc.py b/misc.py
index e52dc64..cc03484 100644
--- a/misc.py
+++ b/misc.py
@@ -78,8 +78,7 @@ units = [[_('%d year'), _('%d years'), 356 * 24 * 60 * 60],
[_('%d week'), _('%d weeks'), 7 * 24 * 60 * 60],
[_('%d day'), _('%d days'), 24 * 60 * 60],
[_('%d hour'), _('%d hours'), 60 * 60],
- [_('%d minute'), _('%d minutes'), 60],
- [_('%d second'), _('%d seconds'), 1]]
+ [_('%d minute'), _('%d minutes'), 60]]
AND = _(' and ')
COMMA = _(', ')