OSDN Git Service

bug fix: can't show cached status in user timeline tab
authorHirotaka Kawata <info@techno-st.net>
Tue, 17 Aug 2010 19:08:48 +0000 (04:08 +0900)
committerHirotaka Kawata <info@techno-st.net>
Tue, 17 Aug 2010 19:08:48 +0000 (04:08 +0900)
gwit/listsselection.py
gwit/main.py
gwit/streamingview.py
gwit/timeline.py
gwit/twitterapi.py

index e7a1a43..caa332d 100644 (file)
@@ -92,7 +92,7 @@ class ListsView(gtk.ScrolledWindow):
                     c = int(mydata["next_cursor"])
                 lists[0:0] = mylists
         
-        for l in lists:
+        for l in reversed(lists):
             user = l["user"]
             userid = int(user["id"])
             screen_name = user["screen_name"]
index ba11a2b..69fa4a5 100644 (file)
@@ -49,13 +49,9 @@ import twittertools
 
 # Main Class
 class Main:
-    # init status timelines
-    timelines = list()
-    tlhash = dict()
-    
     # Default settings
     interval = (60, 300, -1)
-    msgfooter = unicode()
+    msgfooter = u""
     alloc = gtk.gdk.Rectangle(0, 0, 240, 320)
     scounts = (20, 200)
     iconmode = True
@@ -76,6 +72,10 @@ class Main:
         gtk.gdk.threads_init()
         gobject.threads_init()
         
+        # init status timelines
+        self.timelines = list()
+        self.tlhash = dict()
+        
         # Twitter class instance
         self.twitter = TwitterAPI(screen_name, *keys)
         self.twitter.init_twitpic(self.twitpic_apikey)
@@ -144,7 +144,7 @@ class Main:
         self.label_apilimit = gtk.Label()
         self.statusbar = self.builder.get_object("statusbar1")
         self.statusbar.pack_start(self.label_apilimit, expand = False, padding = 10)
-        self.statusbar.show_all()        
+        self.statusbar.show_all()
         
         # Users tab append
         users = UserSelection(self.twitter, self.icons)
@@ -203,7 +203,7 @@ class Main:
         tl.view.on_status_activated = self.on_status_activated
         
         tl.view.add_popup(self.menu_tweet)
-        tl.start_timeline()        
+        tl.start_timeline()
     
     # Append Tab to Notebook
     def new_tab(self, widget, label, timeline = None):
@@ -242,7 +242,7 @@ class Main:
         
     def get_current_tab(self):
         return self.notebook.get_current_page()
-
+    
     # Get text
     def get_textview(self):
         buf = self.textview.get_buffer()
@@ -516,7 +516,7 @@ class Main:
         self.builder.get_object("menuitem_tweet").set_sensitive(False)
         menuitem_timeline = self.builder.get_object("menuitem_timeline")
         menuitem_timeline.set_sensitive(False)
-        if page_num < 0: return
+        if page_num < 0: return False
         
         tl = self.timelines[page_num].timeline
         if tl != None and "interval" in dir(tl) and "api_method" in dir(tl):
index 411077e..f9c9799 100644 (file)
@@ -36,9 +36,6 @@ from statusview import StatusView
 from timeline import Timeline
 
 class StreamingThread(threading.Thread):
-    die = False
-    timeline = set()
-    
     def __init__(self, twitter, params = {}):
         threading.Thread.__init__(self)
         self.setDaemon(True)
@@ -46,6 +43,9 @@ class StreamingThread(threading.Thread):
         self.twitter = twitter
         self.params = params
         self.sapi = twoauth.streaming.StreamingAPI(self.twitter.api.oauth)
+        
+        self.timeline = set()    
+        self.die = False
     
     def run(self):
         #stream = self.sapi.sample()
index 8d4e646..505afa3 100644 (file)
@@ -32,12 +32,11 @@ import gtk
 from statusview import StatusView
 
 class Timeline(gtk.ScrolledWindow):
-    timeline = None
-    
     def __init__(self, api, icons, iconmode):
         gtk.ScrolledWindow.__init__(self)
         self.twitter = api
         self.icons = icons
+        self.timeline = None
         
         # Add treeview to scrolledwindow
         self.view = StatusView(api, icons, iconmode)
index e915ab3..a105757 100644 (file)
@@ -65,7 +65,7 @@ class TwitterAPI():
     def create_timeline(self, method, interval, counts, args = (), kwargs = {}):
         # Add New Timeline Thread
         th = TimelineThread(getattr(self.api, method), interval, counts, args, kwargs)
-        th.added_event = self.add_status
+        th.on_status_added = self.add_status
         th.statuses = self.statuses
         #self.threads.append(th)
         return th
@@ -137,16 +137,16 @@ class TwitterAPI():
 
 # Timeline Thread
 class TimelineThread(threading.Thread):
-    die = False
-    lastid = None
-    timeline = set()
-    
     def __init__(self, method, interval, counts, args, kwargs):
         # Thread Initialize
         threading.Thread.__init__(self)
         self.setDaemon(True)
         self.setName(method.func_name + str(args))
         
+        self.timeline = set()
+        self.die = False
+        self.lastid = None
+        
         # Event lock
         self.lock = threading.Event()
         self.addlock = mutex.mutex()
@@ -173,7 +173,7 @@ class TimelineThread(threading.Thread):
                 if i.user.id == self.kwargs["user"]:
                     cached.add(i.id)
             
-            if cached:
+            if len(cached) > 0:
                 self.add(cached)
         
         # Auto reloading loop
@@ -186,7 +186,7 @@ class TimelineThread(threading.Thread):
                 new = set()
                 for i in statuses:
                     new.add(i.id)
-                    self.added_event(i)
+                    self.on_status_added(i)
                 
                 # Add statuses to timeline
                 self.add(new)
@@ -251,3 +251,4 @@ class TimelineThread(threading.Thread):
     
     def on_timeline_refresh(self): pass
     def reloadEventHandler(self): pass
+    def on_status_added(self, status): pass