class WorkspaceWindowManager(object): """ window manager mixin for a wm with workspaces """ def __wm_screen_init__( self ): log.debug( "WorkspaceWindowManager.__wm_screen_init__" ) self.workspaces = Cycle() self.workspaceDict = {} def __wm_init__( self ): log.debug( "WorkspaceWindowManager.__wm_init__" ) workspace = self.workspaces.current() if workspace: workspace.activate() def current_frame( self ): ws = self.workspaces.current() if ws: return ws.current_frame def set_current_frame( self, frame ): if frame: self.workspaces.current().current_frame = frame else: log.error( "wtf, set_current_frame got a null frame" ) def set_current_workspace( self, index ): if( index != self.workspaces.index and index >= 0 and index < len( self.workspaces ) ): self.workspaces.current().deactivate() self.workspaces.index = index self.workspaces.current().activate() def get_workspace_by_name( self, name ): (ws,index) = self.workspaceDict[ name ] return ws def new_workspace( self, screen, type=TABBED, name="" ): try: (ws,index) = self.workspaceDict[ name ] except KeyError: ws = Workspace( screen, type, name ) index = len(self.workspaces) self.workspaceDict[ name ] = (ws,index) self.workspaces.append( ws ) self.set_current_workspace( index ) return ws
class WorkspaceWindowManager(object): """ window manager mixin for a wm with workspaces """ def __wm_screen_init__(self): log.debug("WorkspaceWindowManager.__wm_screen_init__") self.workspaces = Cycle() self.workspaceDict = {} def __wm_init__(self): log.debug("WorkspaceWindowManager.__wm_init__") workspace = self.workspaces.current() if workspace: workspace.activate() def current_frame(self): ws = self.workspaces.current() if ws: return ws.current_frame def set_current_frame(self, frame): if frame: self.workspaces.current().current_frame = frame else: log.error("wtf, set_current_frame got a null frame") def set_current_workspace(self, index): if (index != self.workspaces.index and index >= 0 and index < len(self.workspaces)): self.workspaces.current().deactivate() self.workspaces.index = index self.workspaces.current().activate() def get_workspace_by_name(self, name): (ws, index) = self.workspaceDict[name] return ws def new_workspace(self, screen, type=TABBED, name=""): try: (ws, index) = self.workspaceDict[name] except KeyError: ws = Workspace(screen, type, name) index = len(self.workspaces) self.workspaceDict[name] = (ws, index) self.workspaces.append(ws) self.set_current_workspace(index) return ws