2
# THIS FILE IS PART OF THE JOKOSHER PROJECT AND LICENSED UNDER THE GPL. SEE
3
# THE 'COPYING' FILE FOR DETAILS
7
# This module is a better status bar than the one included
8
# with gtk because it allows pango markup (bold, etc.).
10
#-------------------------------------------------------------------------------
14
#=========================================================================
16
class StatusBar(gtk.HBox):
18
Implements an improved status bar which allows pango markup styles (bold, italics, etc).
20
#_____________________________________________________________________
24
Creates a new instance of StatusBar with no messages shown.
26
gtk.HBox.__init__(self)
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
35
#_____________________________________________________________________
37
def Push(self, message):
39
Insert a new message into the messages stack.
42
message -- string containing the new message to be added to the StatusBar.
45
the value of the next valid message ID.
47
# increment message_id - this will be key for
48
# message and highest message_id will be 'top of stack'
50
self.stack[self.latest_id] = message
51
self.DisplayTopOfStack()
55
#_____________________________________________________________________
57
def Remove(self, message_id):
59
Removes a new message from the messages stack.
62
message_id -- numerical id of the message to be removed from the StatusBar.
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]
68
self.DisplayTopOfStack()
70
#_____________________________________________________________________
72
def DisplayTopOfStack(self):
74
Updates the StatusBar display when a message is added or removed.
76
# if stack is now empty then clear status bar
77
if len(self.stack) == 0:
78
self.label.set_markup("")
81
# find the message at the top of the stack and display it
82
self.label.set_markup(self.stack[max(self.stack.keys())])
84
#_____________________________________________________________________
86
#=========================================================================