1
|
|
|
""" |
2
|
|
|
This module is for the feature "Open Skin as Project". |
3
|
|
|
|
4
|
|
|
This feature provides a command which lists all Rainmeter Skins |
5
|
|
|
installed in the Rainmeter Skin folder and allows a quick panel |
6
|
|
|
to open the skin in a new window. |
7
|
|
|
|
8
|
|
|
This is done by creating a new sublime text instance using subprocesses. |
9
|
|
|
""" |
10
|
|
|
|
11
|
|
|
import os |
12
|
|
|
import subprocess |
13
|
|
|
|
14
|
|
|
import sublime |
15
|
|
|
import sublime_plugin |
16
|
|
|
|
17
|
|
|
from .path.skin_path_provider import get_cached_skin_path |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
def on_skin_selected(selected_skin_id): |
21
|
|
|
""" |
22
|
|
|
This is a callback upon user selecting a skin. |
23
|
|
|
|
24
|
|
|
This can handle user canceling the input. |
25
|
|
|
Upon selection a respective path is evaluated |
26
|
|
|
and send to a new sublime text instance. |
27
|
|
|
""" |
28
|
|
|
if selected_skin_id == -1: |
29
|
|
|
return |
30
|
|
|
|
31
|
|
|
skins_path = get_cached_skin_path() |
32
|
|
|
skins = os.listdir(skins_path) |
33
|
|
|
selected_skin = skins[selected_skin_id] |
34
|
|
|
selected_skin_path = os.path.join(skins_path, selected_skin) |
35
|
|
|
|
36
|
|
|
# to open a folder in new window, just create a new process with the folder as argument |
37
|
|
|
st_path = sublime.executable_path() |
38
|
|
|
subprocess.Popen([ |
39
|
|
|
st_path, |
40
|
|
|
selected_skin_path |
41
|
|
|
]) |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
class RainmeterOpenSkinAsProjectCommand(sublime_plugin.ApplicationCommand): |
45
|
|
|
"""You can execute this command via the sublime API like sublime.run_command("rainmeter_open_skin_as_project").""" |
46
|
|
|
|
47
|
|
|
def run(self): |
48
|
|
|
"""Automatically called upon calling the command.""" |
49
|
|
|
skins_path = get_cached_skin_path() |
50
|
|
|
skins = os.listdir(skins_path) |
51
|
|
|
|
52
|
|
|
sublime.active_window().show_quick_panel(skins, on_skin_selected, 0, 0, None) |
53
|
|
|
|