~jconti/recent-notifications/trunk

« back to all changes in this revision

Viewing changes to unity/MessageItem.py

  • Committer: Jason Conti
  • Date: 2011-04-23 18:59:12 UTC
  • Revision ID: jason.conti@gmail.com-20110423185912-ggrbhv0hoa1lmcru
Using a bit of cairo to display icons with rounded edges and message items with rounded backgrounds. Still need to get the proper colors from the gtk theme and possibly add options for custom colors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
import Icon
13
13
import Timestamp
14
14
 
 
15
from RoundedWidgets import RoundedBox, RoundedIcon
15
16
from Translations import _
16
17
 
17
18
logger = logging.getLogger("MessageItem")
29
30
def escape_text(text):
30
31
  return GLib.markup_escape_text(text, len(text))
31
32
 
32
 
class MessageItem(Gtk.Frame):
 
33
class MessageItem(RoundedBox):
33
34
  """A widget to represent a notification"""
34
35
  def __init__(self, message):
35
 
    GObject.GObject.__init__(self)
 
36
    RoundedBox.__init__(self)
36
37
 
37
38
    self.set_border_width(2)
38
39
 
42
43
    self._message_icon_size = 48
43
44
 
44
45
    self._hbox = Gtk.HBox()
45
 
    self._hbox.set_border_width(5)
 
46
    self._hbox.set_border_width(10)
46
47
    self.add(self._hbox)
47
48
 
48
 
    self._image = Gtk.Image()
49
 
    self._image.set_alignment(0, 0)
 
49
    self._image = RoundedIcon()
 
50
    #self._image = Gtk.Image()
 
51
    #self._image.set_alignment(0, 0)
50
52
    self._hbox.pack_start(self._image, False, False, 10)
51
53
    self.update_image()
52
54
 
114
116
  def set_width(self, width):
115
117
    """Updates the wrap width of the labels in this message item, minus the icon
116
118
    size and various padding."""
117
 
    new_width = width - self._message_icon_size - 50
 
119
    new_width = width - self._message_icon_size - 60
118
120
    self._label_summary.set_size_request(new_width, -1)
119
121
    self._label_body.set_size_request(new_width, -1)
120
122
    self._label_info.set_size_request(new_width, -1)