OSDN Git Service

Notify thread idx updated to board window.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Mon, 21 Aug 2006 15:05:13 +0000 (00:05 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Mon, 21 Aug 2006 15:05:13 +0000 (00:05 +0900)
src/Hage1/board_window.py
src/Hage1/thread_window.py
src/Hage1/threadlistmodel.py
src/Hage1/windowlist.py

index 367b4d1..b711d60 100644 (file)
@@ -259,3 +259,17 @@ class WinWrap:
         print "end"
         time_end = time.time()
         print time_end - time_start
+
+    def on_thread_idx_updated(self, thread, idx_dic):
+        if not thread or not idx_dic:
+            return
+
+        model = self.treeview.get_model()
+        if model:
+            idx_dic["id"] = thread
+            try:
+                idx_dic["lastModified"] =  misc.httpdate_to_secs(
+                    idx_dic["lastModified"])
+            except ValueError:
+                idx_dic["lastModified"] = 0
+            model.modify_row(idx_dic)
index c28d5e4..a120393 100644 (file)
@@ -151,6 +151,9 @@ class WinWrap:
                    "lastModified": lastmod, "etag": etag}
             idxfile.save_idx(self.bbs, self.board, self.thread, idx_dic)
 
+            windowlist.thread_idx_updated(
+                self.bbs, self.board, self.thread, idx_dic)
+
     def update(self, widget=None):
         line_count = datfile.get_dat_line_count(
             self.bbs, self.board, self.thread)
index 465f52a..7bef1d1 100644 (file)
@@ -40,6 +40,16 @@ class ThreadListModel(gtk.GenericTreeModel):
         self.do_filter()
         self.do_sort(self.sort_column_name, self.sort_reverse)
 
+    def modify_row(self, dict):
+        id = dict["id"]
+        if id in self.order_dict:
+            index = self.order_dict[id]
+            target_dict = self.list[index]
+            for name in self.column_names:
+                if name in dict:
+                    target_dict[name] = dict[name]
+            self.row_changed(index, self.get_iter(index))
+
     def refilter(self):
         before_size = len(self.list)
         self.do_filter()
index 60e62e4..fe18027 100644 (file)
@@ -18,6 +18,7 @@
 import pygtk
 pygtk.require('2.0')
 import gtk
+import gobject
 
 # key: /bbs/board/thread value: toplevel window widget
 _windows = {}
@@ -52,3 +53,15 @@ def on_window_destroy(widget, key):
 
 def on_all_window_destroy():
     gtk.main_quit()
+
+def thread_idx_updated(bbs, board, thread, idx_dic):
+    if not bbs or not board or not thread:
+        raise ValueError, "parameter must not be empty"
+
+    gobject.idle_add(on_thread_idx_updated, bbs, board, thread, idx_dic)
+
+def on_thread_idx_updated(bbs, board, thread, idx_dic):
+    key = "/" + bbs + "/" + board
+    winwrap = get_window(key)
+    if winwrap:
+        winwrap.on_thread_idx_updated(thread, idx_dic)