Skip to content

Commit

Permalink
Simplify plugin loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
thatsIch committed Jan 14, 2017
1 parent cdab6c6 commit 9ec977f
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions path_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,7 @@ def __copy_on_absence_or_newer(user_path, binary_path):
logger.info("You are using the most current version of '" + binary_path + "'. Continue loading...")


def plugin_loaded():
"""
Called automatically from ST3 if plugin is loaded.
Is required now due to async call and ignoring sublime.* from main routine
"""

packages = sublime.packages_path()
prompt_dir = os.path.join(packages, "User", "Rainmeter", "path")

__require_path(prompt_dir)

open_file_dialog_bat = os.path.join(prompt_dir, "open_file_dialog.ps1")
open_folder_dialog_bat = os.path.join(prompt_dir, "open_folder_dialog.ps1")

__copy_on_absence_or_newer(open_file_dialog_bat, "Packages/Rainmeter/path/open_file_dialog.ps1")
__copy_on_absence_or_newer(open_folder_dialog_bat, "Packages/Rainmeter/path/open_folder_dialog.ps1")

def __handle_program_path_init():
program_path = get_cached_program_path()
if not program_path:
# Open dialog and set program path.
Expand Down Expand Up @@ -110,6 +93,8 @@ def on_rainmeter_exe_browsed(message):

browse_file(on_rainmeter_exe_browsed)


def __handle_skin_path_init():
skin_path = get_cached_skin_path()
if not skin_path:
# Open folder dialog and set skin path.
Expand Down Expand Up @@ -147,6 +132,28 @@ def on_skins_folder_browsed(skin_dir):

browse_folder(on_skins_folder_browsed)


def plugin_loaded():
"""
Called automatically from ST3 if plugin is loaded.
Is required now due to async call and ignoring sublime.* from main routine
"""

packages = sublime.packages_path()
prompt_dir = os.path.join(packages, "User", "Rainmeter", "path")

__require_path(prompt_dir)

open_file_dialog_bat = os.path.join(prompt_dir, "open_file_dialog.ps1")
open_folder_dialog_bat = os.path.join(prompt_dir, "open_folder_dialog.ps1")

__copy_on_absence_or_newer(open_file_dialog_bat, "Packages/Rainmeter/path/open_file_dialog.ps1")
__copy_on_absence_or_newer(open_folder_dialog_bat, "Packages/Rainmeter/path/open_folder_dialog.ps1")

__handle_program_path_init()
__handle_skin_path_init()

padding = 16
logger.info("#PROGRAMPATH#:".ljust(padding) + get_cached_program_path()) # Rainmeter.exe
logger.info("#PROGRAMDRIVE#:".ljust(padding) + get_cached_program_drive())
Expand Down

0 comments on commit 9ec977f

Please sign in to comment.