~michael-sheldon/jokosher/telepathy

« back to all changes in this revision

Viewing changes to Jokosher/ui/StatusBar.py

  • Committer: Mike Sheldon
  • Date: 2009-06-19 17:12:30 UTC
  • mfrom: (1076.1.19 joko-main)
  • Revision ID: mike@mikeasoft.com-20090619171230-h80vj2sykyg9kms6
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
#=========================================================================
15
15
 
16
 
class StatusBar(gtk.HBox):
 
16
class StatusBar(gtk.Statusbar):
17
17
        """
18
18
        Implements an improved status bar which allows pango markup styles (bold, italics, etc).
19
19
        """
23
23
                """
24
24
                Creates a new instance of StatusBar with no messages shown.
25
25
                """
26
 
                gtk.HBox.__init__(self)
27
 
                self.latest_id = 0
28
 
                self.label = gtk.Label()
29
 
                self.label.set_justify(gtk.JUSTIFY_LEFT)
30
 
                self.pack_start(self.label, False)
31
 
                # message stack is a dictionary as this is a very easy type
32
 
                # to add and remove from
33
 
                self.stack = {}
 
26
                gtk.Statusbar.__init__(self)
 
27
                # gtk.Statusbar contains a label inside a frame inside itself
 
28
                self.label = self.get_children()[0].get_children()[0]
 
29
                self.label.set_use_markup(True)
34
30
                
35
31
        #_____________________________________________________________________
36
32
 
44
40
                Return:
45
41
                        the value of the next valid message ID.
46
42
                """
47
 
                # increment message_id - this will be key for
48
 
                # message and highest message_id will be 'top of stack'
49
 
                self.latest_id += 1
50
 
                self.stack[self.latest_id] = message
51
 
                self.DisplayTopOfStack()
52
 
                
53
 
                return self.latest_id
 
43
                message_id = self.push(0, message)
 
44
                self.label.set_use_markup(True)
 
45
                return message_id
54
46
        
55
47
        #_____________________________________________________________________
56
48
 
61
53
                Parameters:
62
54
                        message_id -- numerical id of the message to be removed from the StatusBar.
63
55
                """
64
 
                # remove message from stack (first check if it's really there)
65
 
                if message_id in self.stack:
66
 
                        del self.stack[message_id]
67
 
                        
68
 
                self.DisplayTopOfStack()
69
 
                
70
 
        #_____________________________________________________________________
71
 
 
72
 
        def DisplayTopOfStack(self):
73
 
                """
74
 
                Updates the StatusBar display when a message is added or removed.
75
 
                """
76
 
                # if stack is now empty then clear status bar
77
 
                if len(self.stack) == 0:
78
 
                        self.label.set_markup("")
79
 
                        return
80
 
                
81
 
                # find the message at the top of the stack and display it
82
 
                self.label.set_markup(self.stack[max(self.stack.keys())])
 
56
                self.remove(0, message_id)
 
57
                self.label.set_use_markup(True)
83
58
                
84
59
        #_____________________________________________________________________
85
60