Browse Source

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

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

Loading…
Cancel
Save