Some refactoring

This commit is contained in:
Philip Ridout 2013-11-07 20:35:02 +00:00
parent 2535bda1bb
commit 61da0e8ad9
4 changed files with 14 additions and 6 deletions

View File

@ -28,3 +28,4 @@ tests.kdev4
*.nja *.nja
*.orig *.orig
__pycache__ __pycache__
*.dll

View File

@ -121,15 +121,16 @@ class PptviewDocument(PresentationDocument):
the background PptView task started earlier. the background PptView task started earlier.
""" """
log.debug('LoadPresentation') log.debug('LoadPresentation')
temp_folder = self.get_temp_folder()
size = ScreenList().current['size'] size = ScreenList().current['size']
rect = RECT(size.x(), size.y(), size.right(), size.bottom()) rect = RECT(size.x(), size.y(), size.right(), size.bottom())
file_path = os.path.normpath(self.filepath) file_path = os.path.normpath(self.filepath)
preview_path = os.path.join(self.get_temp_folder(), 'slide') preview_path = os.path.join(temp_folder, 'slide')
# Ensure that the paths are null terminated # Ensure that the paths are null terminated
file_path = file_path.encode('utf-16-le') + b'\0' file_path = file_path.encode('utf-16-le') + b'\0'
preview_path = preview_path.encode('utf-16-le') + b'\0' preview_path = preview_path.encode('utf-16-le') + b'\0'
if not os.path.isdir(self.get_temp_folder()): if not os.path.isdir(temp_folder):
os.makedirs(self.get_temp_folder()) os.makedirs(temp_folder)
self.ppt_id = self.controller.process.OpenPPT(file_path, None, rect, preview_path) self.ppt_id = self.controller.process.OpenPPT(file_path, None, rect, preview_path)
if self.ppt_id >= 0: if self.ppt_id >= 0:
self.create_thumbnails() self.create_thumbnails()

View File

@ -223,12 +223,12 @@ DllExport int OpenPPT(wchar_t *filename, HWND hParentWnd, RECT rect,
{ {
if (steps <= pptView[id].steps) if (steps <= pptView[id].steps)
{ {
Sleep(100); Sleep(25);
DEBUG(L"OpenPPT: Step %d/%d\n", steps, pptView[id].steps); DEBUG(L"OpenPPT: Step %d/%d\n", steps, pptView[id].steps);
steps++; steps++;
NextStep(id); NextStep(id);
} }
Sleep(10); Sleep(75);
} }
DEBUG(L"OpenPPT: Slides %d, Steps %d, first slide steps %d\n", DEBUG(L"OpenPPT: Slides %d, Steps %d, first slide steps %d\n",
pptView[id].slideCount, pptView[id].steps, pptView[id].slideCount, pptView[id].steps,

View File

@ -96,8 +96,14 @@ class PresentationDocument(object):
""" """
Constructor for the PresentationController class Constructor for the PresentationController class
""" """
self.slidenumber = 0
self.controller = controller self.controller = controller
self._setup(name)
def _setup(self, name):
"""
Run some initial setup. This method is separate from __init__ in order to mock it out in tests.
"""
self.slidenumber = 0
self.filepath = name self.filepath = name
check_directory_exists(self.get_thumbnail_folder()) check_directory_exists(self.get_thumbnail_folder())