OSDN Git Service

Colored status relationship
authorHirotaka Kawata <hktechno@hotmail.com>
Wed, 17 Feb 2010 18:33:29 +0000 (03:33 +0900)
committerHirotaka Kawata <hktechno@hotmail.com>
Wed, 17 Feb 2010 18:33:29 +0000 (03:33 +0900)
iconstore.py
main.py
timeline.py

index e16c9a2..1b39dbe 100644 (file)
@@ -84,7 +84,7 @@ class NewIcon(threading.Thread):
         for store in self.stores:
             i = store.get_iter_first()
             while i:
-                uid = store.get_value(i, 2)
+                uid = store.get_value(i, 3)
                 if uid == self.user.id:
                     store.set_value(i, 0, icopix)
                 i = store.iter_next(i)
diff --git a/main.py b/main.py
index 5bbbae8..bdfaefc 100644 (file)
--- a/main.py
+++ b/main.py
@@ -92,7 +92,10 @@ class Main:
         # Add Popup Menu
         tl.add_popup(self.obj.menu_timeline)
         
-        # row-activated signal connect
+        # Click, Double Click signal connect
+        tl.treeview.connect(
+            "cursor-changed",
+            self.on_treeview_cursor_changed)
         tl.treeview.connect(
             "row-activated",
             self.on_treeview_row_activated)
@@ -150,3 +153,42 @@ class Main:
         text = status.text
         buf = self.obj.textview1.get_buffer()
         buf.set_text("RT @%s: %s" % (name, text))
+
+    # Status Clicked
+    def on_treeview_cursor_changed(self, treeview):
+        n = self.obj.notebook1.get_current_page()
+        status = self.timelines[n].get_selected_status()
+
+        id = status.id
+        uid = status.user.id
+        to = status.in_reply_to_status_id
+        to_uid = status.in_reply_to_user_id
+        
+        me = self.twitter.api.user.id
+        
+        store = self.timelines[n].store
+        i = store.get_iter_first()
+        
+        # Colord status
+        while i:
+            iid, iuid, ito, ito_uid = store.get(i, 2, 3, 4, 5)
+            if iuid == me:
+                # My status (Green)
+                bg = "#CCFFCC"
+            elif ito_uid == me:
+                # Reply to me (Red)
+                bg = "#FFCCCC"
+            elif iid == to:
+                # Reply to (Orange)
+                bg = "#FFCC99"
+            elif iuid == to_uid:
+                # Reply to other (Yellow)
+                bg = "#FFFFCC"
+            elif iuid == uid:
+                # Selected user (Blue)
+                bg = "#CCCCFF"
+            else:
+                bg = None
+            
+            store.set_value(i, 6, bg)
+            i = store.iter_next(i)
index b46a4f9..9416331 100644 (file)
@@ -20,7 +20,9 @@ class timeline:
         
         # Liststore column setting
         self.store = gtk.ListStore(
-            gtk.gdk.Pixbuf, str, int, str)
+            gtk.gdk.Pixbuf, str,
+            long, long, object, object,
+            str)
         self.treeview = gtk.TreeView(self.store)
         
         # Add treeview to scrolledwindow
@@ -49,7 +51,7 @@ class timeline:
         # Add Column
         for i in tcol:
             i.add_attribute(
-                i.get_cell_renderers()[0], "cell-background", 3)
+                i.get_cell_renderers()[0], "cell-background", 6)
             self.treeview.append_column(i)
         
         # Auto scroll to top setup
@@ -182,11 +184,14 @@ class timeline:
             # New Status Prepend to Liststore (Add row)
             gtk.gdk.threads_enter()
             self.store.prepend(
-                (self.icons.get(i.user), t,
-                 i.user.id, background))
+                (self.icons.get(i.user),
+                 t,
+                 i.id,
+                 i.user.id,
+                 i.in_reply_to_status_id,
+                 i.in_reply_to_user_id,
+                 background))
             gtk.gdk.threads_leave()
-        
-        #print self.timeline.timeline[-1].id
     
     # Menu popup
     def on_treeview_button_press(self, widget, event):