-
Notifications
You must be signed in to change notification settings - Fork 19
/
Guna.py
79 lines (69 loc) · 2.93 KB
/
Guna.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf8 -*-
# -----------------------------------------------------------------------------
# Author : yongchan jeon (Kris) poucotm@gmail.com
# File : Guna.py
# Create : 2017-08-31 22:09:10
# Editor : sublime text3, tab size (4)
# -----------------------------------------------------------------------------
import sublime, sublime_plugin
import sys, imp
import traceback
## sub-modules ______________________________________________
try:
# reload
mods = ['Guna.core.persist', 'Guna.core.api', 'Guna.core.engine']
for mod in mods:
if any(mod == m for m in list(sys.modules)):
imp.reload(sys.modules[mod])
# import
from .core import persist
from .core import api
from .core.api import GunaApi
from .core import engine
from .core.engine import (GunaEventListener, GunaSwitchWidget, GunaSetTheme, GunaTweakTheme, GunaTweakWidget, GunaReadme,
GunaIssue, GunaUpscaleIcon, GunaSwitchFont, GunaAuxCmds)
from .core.util import (GunaColorEdit)
import_ok = True
except Exception:
print ('GUNA : ERROR ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――')
traceback.print_exc()
print ('――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――')
import_ok = False
# package control
try:
from package_control import events
package_control_installed = True
except Exception:
package_control_installed = False
## plugin_loaded ____________________________________________
def plugin_loaded():
# import
if not import_ok:
sublime.status_message("* GUNA : Error in importing sub-modules. Please, see the trace-back message in Sublime console")
return
if package_control_installed and (events.install('Guna') or events.post_upgrade('Guna')):
def installed():
# automatically set theme
sublime.active_window().run_command('guna_set_theme')
# reload for settings
engine.engine_reload()
# engine start
engine.start()
# show `Read Me` @ first
if events.install('Guna'):
sublime.active_window().run_command('guna_readme')
sublime.set_timeout_async(engine.icons(), 5000)
# show sidebar (as default)
sublime.active_window().run_command("guna_aux_cmds", {"cmd": "show_sidebar"})
sublime.set_timeout_async(installed, 1000)
else:
# engine start
engine.start()
return
## plugin_unloaded __________________________________________
def plugin_unloaded():
# engine stop
if package_control_installed:
if events.remove('Guna') or events.pre_upgrade('Guna'):
engine.stop()
return