#NEWLINE# def init( self , ui , parent , style ) : #NEWLINE# #INDENT# 'Initialise the object.\n\n           FIXME: Note that we treat MODAL and POPUP as equivalent until we\n           have an example that demonstrates how POPUP is supposed to work.\n        ' #NEWLINE# self . ui = ui #NEWLINE# self . control = ui . control #NEWLINE# view = ui . view #NEWLINE# history = ui . history #NEWLINE# if ( self . control is not None ) : #NEWLINE# #INDENT# if ( history is not None ) : #NEWLINE# #INDENT# history . on_trait_change ( self . _on_undoable , 'undoable' , remove = True ) #NEWLINE# history . on_trait_change ( self . _on_redoable , 'redoable' , remove = True ) #NEWLINE# history . on_trait_change ( self . _on_revertable , 'undoable' , remove = True ) #NEWLINE# #UNINDENT# ui . reset ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . create_dialog ( parent , style ) #NEWLINE# #UNINDENT# self . set_icon ( view . icon ) #NEWLINE# buttons = [ self . coerce_button ( button ) for button in view . buttons ] #NEWLINE# nr_buttons = len ( buttons ) #NEWLINE# no_buttons = ( ( nr_buttons == 1 ) and self . is_button ( buttons [ 0 ] , '' ) ) #NEWLINE# has_buttons = ( ( not no_buttons ) and ( ( nr_buttons > 0 ) or view . undo or view . revert or view . ok or view . cancel ) ) #NEWLINE# if ( has_buttons or ( view . menubar is not None ) ) : #NEWLINE# #INDENT# if ( history is None ) : #NEWLINE# #INDENT# history = UndoHistory ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# history = None #NEWLINE# #UNINDENT# ui . history = history #NEWLINE# if ( ( not no_buttons ) and ( has_buttons or view . help ) ) : #NEWLINE# #INDENT# bbox = QtGui . QDialogButtonBox ( ) #NEWLINE# if ( nr_buttons == 0 ) : #NEWLINE# #INDENT# if view . undo : #NEWLINE# #INDENT# self . check_button ( buttons , UndoButton ) #NEWLINE# #UNINDENT# if view . revert : #NEWLINE# #INDENT# self . check_button ( buttons , RevertButton ) #NEWLINE# #UNINDENT# if view . ok : #NEWLINE# #INDENT# self . check_button ( buttons , OKButton ) #NEWLINE# #UNINDENT# if view . cancel : #NEWLINE# #INDENT# self . check_button ( buttons , CancelButton ) #NEWLINE# #UNINDENT# if view . help : #NEWLINE# #INDENT# self . check_button ( buttons , HelpButton ) #NEWLINE# #UNINDENT# #UNINDENT# for ( raw_button , button ) in zip ( view . buttons , buttons ) : #NEWLINE# #INDENT# default = ( raw_button == view . default_button ) #NEWLINE# if self . is_button ( button , 'Undo' ) : #NEWLINE# #INDENT# self . undo = self . add_button ( button , bbox , QtGui . QDialogButtonBox . ActionRole , self . _on_undo , False , default = default ) #NEWLINE# history . on_trait_change ( self . _on_undoable , 'undoable' , dispatch = 'ui' ) #NEWLINE# if history . can_undo : #NEWLINE# #INDENT# self . _on_undoable ( True ) #NEWLINE# #UNINDENT# self . redo = self . add_button ( button , bbox , QtGui . QDialogButtonBox . ActionRole , self . _on_redo , False , 'Redo' ) #NEWLINE# history . on_trait_change ( self . _on_redoable , 'redoable' , dispatch = 'ui' ) #NEWLINE# if history . can_redo : #NEWLINE# #INDENT# self . _on_redoable ( True ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if self . is_button ( button , 'Revert' ) : #NEWLINE# #INDENT# self . revert = self . add_button ( button , bbox , QtGui . QDialogButtonBox . ResetRole , self . _on_revert , False , default = default ) #NEWLINE# history . on_trait_change ( self . _on_revertable , 'undoable' , dispatch = 'ui' ) #NEWLINE# if history . can_undo : #NEWLINE# #INDENT# self . _on_revertable ( True ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if self . is_button ( button , 'OK' ) : #NEWLINE# #INDENT# self . ok = self . add_button ( button , bbox , QtGui . QDialogButtonBox . AcceptRole , self . control . accept , default = default ) #NEWLINE# ui . on_trait_change ( self . _on_error , 'errors' , dispatch = 'ui' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . is_button ( button , 'Cancel' ) : #NEWLINE# #INDENT# self . add_button ( button , bbox , QtGui . QDialogButtonBox . RejectRole , history . control . reject , default = default ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . is_button ( button , 'Help' ) : #NEWLINE# #INDENT# self . add_button ( button , bbox , QtGui . QDialogButtonBox . HelpRole , self . _on_help , default = default ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not self . is_button ( button , '' ) ) : #NEWLINE# #INDENT# self . add_button ( button , bbox , QtGui . QDialogButtonBox . ActionRole , default = default ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# bbox = None #NEWLINE# #UNINDENT# self . add_contents ( panel ( ui ) , bbox )