Package flumotion :: Package admin :: Package gtk :: Module statusbar
[hide private]

Source Code for Module flumotion.admin.gtk.statusbar

  1  # -*- Mode: Python; test-case-name: flumotion.test.test_parts -*- 
  2  # vi:si:et:sw=4:sts=4:ts=4 
  3  # 
  4  # Flumotion - a streaming media server 
  5  # Copyright (C) 2004,2005,2006,2007,2008 Fluendo, S.L. (www.fluendo.com). 
  6  # All rights reserved. 
  7   
  8  # This file may be distributed and/or modified under the terms of 
  9  # the GNU General Public License version 2 as published by 
 10  # the Free Software Foundation. 
 11  # This file is distributed without any warranty; without even the implied 
 12  # warranty of merchantability or fitness for a particular purpose. 
 13  # See "LICENSE.GPL" in the source distribution for more information. 
 14   
 15  # Licensees having purchased or holding a valid Flumotion Advanced 
 16  # Streaming Server license may use this file in accordance with the 
 17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
 18  # See "LICENSE.Flumotion" in the source distribution for more information. 
 19   
 20  # Headers in this file shall remain intact. 
 21   
 22  """statusbar widget used by in admin window""" 
 23   
 24  __version__ = "$Rev$" 
 25   
 26   
27 -class AdminStatusbar(object):
28 """ 29 I implement the status bar used in the admin UI. 30 """ 31
32 - def __init__(self, widget):
33 """ 34 @param widget: a gtk.Statusbar to wrap. 35 """ 36 self._widget = widget 37 38 self._cids = {} # hash of context -> context id 39 self._mids = {} # hash of context -> message id lists 40 self._contexts = ['main', 'notebook'] 41 42 for context in self._contexts: 43 self._cids[context] = widget.get_context_id(context) 44 self._mids[context] = []
45
46 - def clear(self, context=None):
47 """ 48 Clear the status bar for the given context, or for all contexts 49 if none specified. 50 """ 51 if context: 52 self._clearContext(context) 53 return 54 55 for context in self._contexts: 56 self._clearContext(context)
57
58 - def push(self, context, message):
59 """ 60 Push the given message for the given context. 61 62 @returns: message id 63 """ 64 mid = self._widget.push(self._cids[context], message) 65 self._mids[context].append(mid) 66 return mid
67
68 - def pop(self, context):
69 """ 70 Pop the last message for the given context. 71 72 @returns: message id popped, or None 73 """ 74 if len(self._mids[context]): 75 mid = self._mids[context].pop() 76 self._widget.remove(self._cids[context], mid) 77 return mid 78 79 return None
80
81 - def set(self, context, message):
82 """ 83 Replace the current top message for this context with this new one. 84 85 @returns: the message id of the message pushed 86 """ 87 self.pop(context) 88 return self.push(context, message)
89
90 - def remove(self, context, mid):
91 """ 92 Remove the message with the given id from the given context. 93 94 @returns: whether or not the given mid was valid. 95 """ 96 if not mid in self._mids[context]: 97 return False 98 99 self._mids[context].remove(mid) 100 self._widget.remove(self._cids[context], mid) 101 return True
102
103 - def _clearContext(self, context):
104 if not context in self._cids.keys(): 105 return 106 107 for mid in self._mids[context][:]: 108 self.remove(context, mid)
109