Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Adds public functions to App object: #6

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,50 @@ def init_app(self):
"""
Called as the application is being initialized
"""

tk_multi_workfiles = self.import_module("tk_multi_workfiles")

# register commands:
self._work_files_handler = tk_multi_workfiles.WorkFiles(self)
self.engine.register_command("Tank File Manager...", self._work_files_handler.show_dlg)

self._save_as_handler = tk_multi_workfiles.SaveAs
self._versioning_handler = tk_multi_workfiles.Versioning

# other commands are only valid if we have valid work and publish templates:
if self.get_template("template_work") and self.get_template("template_publish"):
cmd = lambda app=self: tk_multi_workfiles.SaveAs.show_save_as_dlg(app)
if self.can_save_as():
cmd = lambda app=self: app.show_save_as_dlg()
self.engine.register_command("Tank Save As...", cmd)
cmd = lambda app=self: tk_multi_workfiles.Versioning.show_change_version_dlg(app)

cmd = lambda app=self: app.show_change_version_dlg()
self.engine.register_command("Version up Current Scene...", cmd)

def destroy_app(self):
self.log_debug("Destroying tk-multi-workfiles")
self._work_files_handler = None
self._work_files_handler = None
self._save_as_handler = None
self._versioning_handler = None

def show_save_as_dlg(self):
"""
If save as is available, will show the save as dialog.
"""
if self.can_save_as():
return self._save_as_handler.show_save_as_dlg(self)
return False

def show_change_version_dlg(self):
"""
If save as is available, will show the change version dialog.
"""
if self.can_save_as():
return self._versioning_handler.show_change_version_dlg(self)
return False

def can_save_as(self):
"""
Returns True if save as is available, False otherwise.
"""
if self.get_template("template_work") and self.get_template("template_publish"):
return True
return False