OSDN Git Service

Selected text colors follow the focus in ThreadView.
[fukui-no-namari/fukui-no-namari.git] / src / FukuiNoNamari / thread_view.py
index 006fad4..d7b0b43 100644 (file)
@@ -218,16 +218,20 @@ class ElementText:
     def draw(self, drawingarea, y_offset, pango_layout,
              selection=False, start_index=0, end_index=0xffffff):
 
-        selection_fg = drawingarea.style.text[1]
-        selection_bg = drawingarea.style.base[1]
+        if drawingarea.get_property("has-focus"):
+            selection_fg = drawingarea.style.text[gtk.STATE_SELECTED]
+            selection_bg = drawingarea.style.base[gtk.STATE_SELECTED]
+        else:
+            selection_fg = drawingarea.style.text[gtk.STATE_ACTIVE]
+            selection_bg = drawingarea.style.base[gtk.STATE_ACTIVE]
 
         for line in self.line_list:
 
             text = self.text[line.start_index:line.end_index]
             u_text = text.encode("utf8")
             gc = drawingarea.window.new_gc()
-            gc.set_foreground(drawingarea.style.text[0])
-            gc.set_background(drawingarea.style.base[0])
+            gc.set_foreground(drawingarea.style.text[gtk.STATE_NORMAL])
+            gc.set_background(drawingarea.style.base[gtk.STATE_NORMAL])
             attrs = self._get_attrs()
             if selection: