Browse Source

turned variables private, since I was crashing with the function names

master
Julio Biason 15 years ago
parent
commit
2eb3f1f202
  1. 31
      mitterlib/ui/helpers/gtk_smartbar.py

31
mitterlib/ui/helpers/gtk_smartbar.py

@ -37,8 +37,8 @@ class SmartStatusbar(gtk.Statusbar):
def __init__(self):
super(SmartStatusbar, self).__init__()
self.static = None
self.pairs = {}
self._static = None
self._pairs = {}
self._context = self.get_context_id('Mitter')
return
@ -48,11 +48,13 @@ class SmartStatusbar(gtk.Statusbar):
message can be in the message stack at a time; if there is any static
messages in the stack, it will be removed before the new one is
added."""
if self.static:
if self._static:
# remove any previous static messages
self.remove_message(self._context, self.static)
_log.debug('Removing previous static message %d' % (self._static))
self.remove_message(self._context, self._static)
self.static = self.push(self._context, message)
self._static = self.push(self._context, message)
_log.debug('Added new static message %d' % (self._static))
return
def volatile(self, message, seconds=10, pair=None):
@ -65,28 +67,31 @@ class SmartStatusbar(gtk.Statusbar):
appear, when it will be finally removed; the second message, in this
case, will be removed after the number of seconds, like any
non-paired message."""
message_id = self.push(self._context, message))
message_id = self.push(self._context, message)
# pair checking
if pair:
if pair in self.pairs:
# this is the second message. We remove the first one and
if pair in self._pairs:
# this is the second message. We remove the first one and
# this one will be removed like any other message.
first = self.pairs[pair]
first = self._pairs[pair]
self.remove_message(self._context, first)
del self.pairs[pair]
del self._pairs[pair]
_log.debug('Removed message %d from pair %s' % (first, pair))
else:
# this is the first message of the pair. It will not be
# removed but the timeout.
self.pairs[pairs] = message_id
self._pairs[pair] = message_id
_log.debug('added message %d of pair %s' % (message_id, pair))
return
self.timeout = gobject.timeout_add(
seconds * 1000, # removal after 20 seconds
seconds * 1000, # removal after the number of seconds
self.remove_volatile, message_id)
return
def kill_volatiles(self, message_id):
def remove_volatile(self, message_id):
"""Kill all messages that are marked as volatiles."""
_log.debug('Killing volatile message %d' % (message_id))
self.remove_message(self._context, message_id)
return

Loading…
Cancel
Save