~jconti/recent-notifications/trunk

« back to all changes in this revision

Viewing changes to unity/MessageList.py

  • Committer: Jason Conti
  • Date: 2011-04-25 20:05:41 UTC
  • Revision ID: jason.conti@gmail.com-20110425200541-fsnj07k0ydlhovsw
Added theme support. User themes are stored in ~/.config/recent-notifications/themes/, see themes/default for the proper format. The desired theme is set with the theme property in ~/.config/recent-notifications/preferences. Still need to add support for acquiring the colors from the system gtk theme.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
from gi.repository import GObject, Gtk
11
11
 
12
12
from MessageItem import MessageItem
 
13
from Theme import Color
13
14
 
14
15
logger = logging.getLogger("MessageList")
15
16
 
24
25
    self._messages = []
25
26
    self._message_limit = 20
26
27
    self._width = 400
 
28
    self._current_theme = None
 
29
 
 
30
    self._viewport = Gtk.Viewport()
 
31
    self.add(self._viewport)
27
32
 
28
33
    self._vbox = Gtk.VBox()
29
34
    self._vbox.set_border_width(5)
30
 
    self.add_with_viewport(self._vbox)
 
35
    self._viewport.add(self._vbox)
31
36
 
32
37
  def add_message(self, message):
33
38
    """Adds a message to the box"""
34
39
    item = MessageItem(message)
35
40
    item.set_width(self._width)
 
41
 
 
42
    if self._current_theme != None:
 
43
      item.set_theme(self._current_theme)
 
44
 
36
45
    self._messages.insert(0, item)
37
46
 
38
47
    if self._filter == None or self._filter == message.app_name:
71
80
      else:
72
81
        break
73
82
 
 
83
  def set_theme(self, theme):
 
84
    """Sets the theme of this message list"""
 
85
    self._current_theme = theme
 
86
 
 
87
    for item in self._messages:
 
88
      item.set_theme(theme)
 
89
 
 
90
    color = theme.get_background()
 
91
    color.set_bg_normal(self._viewport)
 
92
 
74
93
  def set_width(self, width):
75
94
    """Updates the default width and the width of all the childen message items."""
76
95
    self._width = width