forked from apiad/sublime-browser-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser_integration_launch.py
45 lines (32 loc) · 1.29 KB
/
browser_integration_launch.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
from .browser_integration import *
class BrowserIntegrationLaunchCommand(sublime_plugin.ApplicationCommand):
plugin_name = "Launch Browser"
plugin_description = "Launches a new browser instance."
@staticmethod
def visible():
return not browser.connected()
@async
def run(self):
browsers = ['Chrome', 'Firefox']
@async
def open_browser(i):
if i < 0:
return
b = browsers[i]
if browser.connected():
with loading("Shutting down current WebDriver instance."):
browser.quit()
with loading("Opening new %s instance." % b):
browser.connect(b)
if setting('maximize_on_startup', self):
browser.maximize_window()
else:
x, y = setting('window_position', self)
w, h = setting('window_size', self)
browser.set_window_position(x, y)
browser.set_window_size(w, h)
home = setting('startup_location', self)
with loading("Loading %s" % home):
browser.get(home)
status("%s is up and running!" % b)
sublime.active_window().show_quick_panel(browsers, open_browser)