OSDN Git Service

Statusbar, ThreadWindow
[fukui-no-namari/fukui-no-namari.git] / src / FukuiNoNamari / thread_window.py
index 5e91f7a..a6421e7 100644 (file)
@@ -148,6 +148,10 @@ class WinWrap(winwrapbase.WinWrapBase):
 
         self.threadview.on_uri_clicked = self.on_threadview_uri_clicked
 
+        self.statusbar_context_id = self.statusbar.get_context_id(
+            "Thread Window Status")
+        self.statusbar.push(self.statusbar_context_id, "OK.")
+
         self.threadview.popupmenu = self.widget_tree.get_widget(
             "popup_threadview_menu")
         self.threadview.menu_openuri = self.widget_tree.get_widget(
@@ -318,19 +322,38 @@ class WinWrap(winwrapbase.WinWrapBase):
         if etag:
             req.add_header("If-None-Match", etag)
 
+        def push():
+            self.statusbar.pop(self.statusbar_context_id)
+            self.statusbar.push(self.statusbar_context_id, "GET...")
+        gobject.idle_add(push)
+
         req = self.bbs_type.set_extra_dat_request(req, self)
 
         opener = urllib2.build_opener(HTTPRedirectHandler302, HTTPDebugHandler)
         try:
             res = opener.open(req)
         except urllib2.HTTPError, e:
-            pass
-#             gobject.idle_add(
-#                 lambda x: self.statusbar.push(0, x), "%d %s" % (e.code, e.msg))
+            def push(code, msg):
+                message = "%d %s" % (code, msg)
+                self.statusbar.pop(self.statusbar_context_id)
+                self.statusbar.push(self.statusbar_context_id, message)
+            gobject.idle_add(push, e.code, e.msg)
         else:
             headers = res.info()
-#             gobject.idle_add(
-#                 lambda x: self.statusbar.push(0, x), "%d %s" % (res.code, res.msg))
+
+            if "Last-Modified" in headers:
+                la = headers["Last-Modified"]
+                def push(code, msg, lastm):
+                    message = "%d %s [%s]" % (code, msg, lastm)
+                    self.statusbar.pop(self.statusbar_context_id)
+                    self.statusbar.push(self.statusbar_context_id, message)
+                gobject.idle_add(push, res.code, res.msg, la)
+            else:
+                def push(code, msg):
+                    message = "%d %s" % (code, msg)
+                    self.statusbar.pop(self.statusbar_context_id)
+                    self.statusbar.push(self.statusbar_context_id, message)
+                gobject.idle_add(push, res.code, res.msg)
 
             maybe_incomplete = False
             for line in res: