OSDN Git Service

Fix a thread title is not loaded.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 30 Aug 2006 14:56:00 +0000 (23:56 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 30 Aug 2006 14:56:00 +0000 (23:56 +0900)
src/Hage1/datfile.py
src/Hage1/thread_window.py

index 4c41173..5a4221e 100644 (file)
@@ -52,6 +52,13 @@ def get_dat_line_count(bbs, board, thread):
     for l in f: -1
     return f.filelineno()
 
+def do_get_title_from_dat(line):
+    if line:
+        m = REG_EXPR_TITLE.match(line.decode("cp932", "replace"))
+        if m:
+            return m.group(1)
+    return ""
+    
 def get_title_from_dat(bbs, board, thread):
     """Returns thread title in dat file
 
@@ -70,10 +77,7 @@ def get_title_from_dat(bbs, board, thread):
     f = open(dat_path, "r")
     try:
         line = f.readline()
-        if line:
-            m = REG_EXPR_TITLE.match(line.decode("cp932", "replace"))
-            if m:
-                return m.group(1)
+        return do_get_title_from_dat(line)
     finally:
         f.close()
 
index bff4178..90294fb 100644 (file)
@@ -125,7 +125,7 @@ class WinWrap:
         self.uri = self.bbs_type.uri
         self.size = 0
         self.num = 0
-        self.title = None
+        self.title = ""
         self.lock_obj = False
         self.jump_request_num = 0
         self.progress = False
@@ -374,11 +374,6 @@ class WinWrap:
         self.jump_request_num = 0
 
         def load():
-            title = datfile.get_title_from_dat(
-                self.bbs, self.board, self.thread)
-            if title:
-                self.title = title
-                gobject.idle_add(self.window.set_title, title)
 
             def create_mark():
                 self.textbuffer.create_mark("1", self.enditer, True)
@@ -414,6 +409,12 @@ class WinWrap:
         self.size += len(line)
         self.num += 1
 
+        if not self.title and self.num == 1:
+            title = datfile.do_get_title_from_dat(line)
+            if title:
+                self.title = title
+                gobject.idle_add(self.window.set_title, title)
+
         h = lambda name,mail,date,msg: self.reselems_to_buffer(
             self.num, name, mail, date, msg)