wingo - in flumotion/trunk: . flumotion/admin/gtk
flumotion/component/base
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Mon Jun 25 13:12:45 CEST 2007
Author: wingo
Date: Mon Jun 25 13:12:42 2007
New Revision: 5233
Modified:
flumotion/trunk/ChangeLog
flumotion/trunk/flumotion/admin/gtk/componentview.py
flumotion/trunk/flumotion/component/base/admin_gtk.py
Log:
2007-06-25 Andy Wingo <wingo at pobox.com>
* flumotion/component/base/admin_gtk.py (BaseAdminGtk.cleanup):
Set uiState to None when we stop listening.
(BaseAdminGtkNode.__init__, BaseAdminGtkNode.gotUIState)
(BaseAdminGtkNode.render): Fix bug that could cause cleanup() to
raise an exception, corrupting the state of the GTK+ UI.
* flumotion/admin/gtk/componentview.py
(ComponentView.get_widget_constructor): Rewrite to not be a
defgen.
(ComponentView.object_inactive_to_active.got_widget_constructor)
(ComponentView.object_active_to_inactive): Increment callstamp
when going to inactive, so we can simplify the check in
got_widget_constructor. Add an assertion in got_widget_constructor
that we don't already have a widget.
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Mon Jun 25 13:12:42 2007
@@ -1,3 +1,20 @@
+2007-06-25 Andy Wingo <wingo at pobox.com>
+
+ * flumotion/component/base/admin_gtk.py (BaseAdminGtk.cleanup):
+ Set uiState to None when we stop listening.
+ (BaseAdminGtkNode.__init__, BaseAdminGtkNode.gotUIState)
+ (BaseAdminGtkNode.render): Fix bug that could cause cleanup() to
+ raise an exception, corrupting the state of the GTK+ UI.
+
+ * flumotion/admin/gtk/componentview.py
+ (ComponentView.get_widget_constructor): Rewrite to not be a
+ defgen.
+ (ComponentView.object_inactive_to_active.got_widget_constructor)
+ (ComponentView.object_active_to_inactive): Increment callstamp
+ when going to inactive, so we can simplify the check in
+ got_widget_constructor. Add an assertion in got_widget_constructor
+ that we don't already have a widget.
+
2007-06-25 Michael Smith <msmith at fluendo.com>
* flumotion/component/feedcomponent010.py:
Modified: flumotion/trunk/flumotion/admin/gtk/componentview.py
==============================================================================
--- flumotion/trunk/flumotion/admin/gtk/componentview.py (original)
+++ flumotion/trunk/flumotion/admin/gtk/componentview.py Mon Jun 25 13:12:42 2007
@@ -58,6 +58,8 @@
OBJECT_UNSET, OBJECT_INACTIVE, OBJECT_ACTIVE = range(NUM_STATES)
class ComponentView(gtk.VBox, log.Loggable):
+ logCategory='componentview'
+
def __init__(self):
gtk.VBox.__init__(self)
self.widget_constructor = None
@@ -74,34 +76,37 @@
# override me to do e.g. multi.get_admin_for_object
return self.admin
- @defer_generator_method
def get_widget_constructor(self, state):
- def sleeping_component():
- return gtk.Label('Component %s is still sleeping' %
- state.get('name'))
def not_component_state():
return gtk.Label('')
+
+ def no_bundle(failure):
+ failure.trap(errors.NoBundleError)
+ return ("flumotion/component/base/admin_gtk.py", "BaseAdminGtk")
+ def got_file_name((filename, procname)):
+ modname = common.pathToModuleName(filename)
+ return admin.getBundledFunction(modname, procname)
+
+ def got_constructor(proc):
+ return lambda: NodeBook(proc(state, admin))
+
+ def sleeping_component(failure):
+ failure.trap(errors.SleepingComponentError)
+ return lambda: gtk.Label('Component %s is still sleeping' %
+ state.get('name'))
+
+
admin = self.get_admin_for_object(state)
if not isinstance(state, planet.AdminComponentState):
- yield not_component_state
+ return not_component_state
- try:
- d = admin.callRemote('getEntryByType', state, 'admin/gtk')
- yield d
- filename, procname = d.value()
- except errors.NoBundleError, e:
- # Use a default of BaseAdminGtk so our plumbing nodes work
- filename = "flumotion/component/base/admin_gtk.py"
- procname = "BaseAdminGtk"
- except errors.SleepingComponentError, e:
- yield sleeping_component
-
- modname = common.pathToModuleName(filename)
- d = admin.getBundledFunction(modname, procname)
- yield d
- proc = d.value()
- yield lambda: NodeBook(proc(state, admin))
+ d = admin.callRemote('getEntryByType', state, 'admin/gtk')
+ d.addErrback(no_bundle)
+ d.addCallback(got_file_name)
+ d.addCallback(got_constructor)
+ d.addErrback(sleeping_component)
+ return d
def object_unset_to_inactive(self):
def invalidate(_):
@@ -122,8 +127,7 @@
def object_inactive_to_active(self):
def got_widget_constructor(proc, callStamp):
- if (callStamp != self._callStamp
- or self._state != OBJECT_ACTIVE):
+ if callStamp != self._callStamp:
# in the time that get_widget_constructor was running,
# perhaps the user selected another object; only update
# the ui if that did not happen
@@ -131,6 +135,7 @@
'callstamps %d/%d', proc, self._state,
callStamp, self._callStamp)
return
+ assert self.widget == None
self.widget = proc()
self.widget.show()
self.pack_start(self.widget, True, True)
@@ -142,6 +147,8 @@
d.addCallback(got_widget_constructor, callStamp)
def object_active_to_inactive(self):
+ # prevent got_widget_constructor from adding the widget above
+ self._callStamp += 1
if self.widget:
self.remove(self.widget)
# widget maybe a gtk.Label or a NodeBook
Modified: flumotion/trunk/flumotion/component/base/admin_gtk.py
==============================================================================
--- flumotion/trunk/flumotion/component/base/admin_gtk.py (original)
+++ flumotion/trunk/flumotion/component/base/admin_gtk.py Mon Jun 25 13:12:42 2007
@@ -70,6 +70,7 @@
def cleanup(self):
if self.uiState:
self.uiState.removeListener(self)
+ self.uiState = None
for node in self.getNodes().values():
node.cleanup()
@@ -227,7 +228,9 @@
self.nodes = util.OrderedDict()
self.wtree = None
self.widget = None
- self.uiState = None
+ self.uiState = None # set if we are listening
+ self._pendingUIState = None # set if we are waiting for the ui
+ # to load
## Absolute path to the glade file.
## e.g. "/home/flu/.flumotion/cache/test/80...df7/flumotion/ui.glade
self._gladefilepath = None
@@ -236,7 +239,6 @@
if self.uiState:
self.uiState.removeListener(self)
-
def status_push(self, str):
if self.statusbar:
return self.statusbar.push('notebook', str)
@@ -339,9 +341,10 @@
self.debug("property %s changed to %r" % (name, value))
def gotUIState(self, state):
- self.uiState = state
if self.widget:
- self.setUIState(self.uiState)
+ self.setUIState(state)
+ else:
+ self._pendingUIState = state
def setUIState(self, state):
"""
@@ -399,9 +402,9 @@
self.debug('render: no self.widget, failing')
yield defer.fail(IndexError)
- if self.uiState:
+ if self._pendingUIState:
self.debug('calling setUIState on the node')
- self.setUIState(self.uiState)
+ self.setUIState(self._pendingUIState)
self.debug('render: yielding widget %s' % self.widget)
yield self.widget
More information about the flumotion-commit
mailing list