-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
op_open_url.py
111 lines (89 loc) · 3.97 KB
/
op_open_url.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import bpy
import webbrowser
from .print_functions import print_and_report
class ANTEMPLATES_OT_open_url(bpy.types.Operator):
"""Open URL in web browser"""
bl_idname = "antemplates.open_url"
bl_label = "Open URL"
bl_options = {'REGISTER', 'INTERNAL'}
url : bpy.props.StringProperty()
@classmethod
def poll(cls, context):
winman = context.window_manager
properties_coll = winman.an_templates_properties
nodetree_collection = winman.an_templates_nodetrees
if properties_coll.nodetrees_index in range(0, len(nodetree_collection)):
return True
def execute(self, context):
if self.url == "":
print_and_report(self, "No URL", "WARNING") #debug
else:
webbrowser.open(self.url)
print_and_report(self, "Opening URL in Web Browser : %s" % self.url, "INFO") #debug
return {'FINISHED'}
# Image Preview
class ANTEMPLATES_OT_open_url_image(bpy.types.Operator):
"""Open Image Preview in Web Browser"""
bl_idname = "antemplates.open_url_image"
bl_label = "Open Image Preview"
bl_options = {'REGISTER', 'INTERNAL'}
@classmethod
def poll(cls, context):
winman = context.window_manager
properties_coll = winman.an_templates_properties
nodetree_collection = winman.an_templates_nodetrees
if properties_coll.nodetrees_index in range(0, len(nodetree_collection)):
if nodetree_collection[properties_coll.nodetrees_index].image_preview_url:
return True
def execute(self, context):
winman = context.window_manager
properties_coll = winman.an_templates_properties
nodetree_collection = winman.an_templates_nodetrees
url = nodetree_collection[properties_coll.nodetrees_index].image_preview_url
webbrowser.open(url)
print_and_report(self, "Opening URL in Web Browser : %s" % url, "INFO") #debug
return {'FINISHED'}
# Video Preview
class ANTEMPLATES_OT_open_url_video(bpy.types.Operator):
"""Open Video Preview in Web Browser"""
bl_idname = "antemplates.open_url_video"
bl_label = "Open Video Preview"
bl_options = {'REGISTER', 'INTERNAL'}
@classmethod
def poll(cls, context):
winman = context.window_manager
properties_coll = winman.an_templates_properties
nodetree_collection = winman.an_templates_nodetrees
if properties_coll.nodetrees_index in range(0, len(nodetree_collection)):
if nodetree_collection[properties_coll.nodetrees_index].video_preview_url:
return True
def execute(self, context):
winman = context.window_manager
properties_coll = winman.an_templates_properties
nodetree_collection = winman.an_templates_nodetrees
url = nodetree_collection[properties_coll.nodetrees_index].video_preview_url
webbrowser.open(url)
print_and_report(self, "Opening URL in Web Browser : %s" % url, "INFO") #debug
return {'FINISHED'}
# Readme
class ANTEMPLATES_OT_open_url_readme(bpy.types.Operator):
"""Open Readme in Web Browser"""
bl_idname = "antemplates.open_url_readme"
bl_label = "Open Readme"
bl_options = {'REGISTER', 'INTERNAL'}
@classmethod
def poll(cls, context):
winman = context.window_manager
properties_coll = winman.an_templates_properties
nodetree_collection = winman.an_templates_nodetrees
if properties_coll.nodetrees_index in range(0, len(nodetree_collection)):
if nodetree_collection[properties_coll.nodetrees_index].readme_url:
return True
def execute(self, context):
winman = context.window_manager
properties_coll = winman.an_templates_properties
nodetree_collection = winman.an_templates_nodetrees
url = nodetree_collection[properties_coll.nodetrees_index].readme_url
webbrowser.open(url)
print_and_report(self, "Opening URL in Web Browser : %s" % url, "INFO") #debug
return {'FINISHED'}