forked from CGCookie/blender-addon-updater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
145 lines (114 loc) · 4.13 KB
/
__init__.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Addon Updater Demo",
"description": "Demo addon for showcasing the blender-addon-updater module",
"author": "Patrick W. Crawford",
"version": (1, 0, 2),
"blender": (2, 7, 8),
"location": "View 3D > Tool Shelf > Demo Updater",
"warning": "", # used for warning icon and text in addons panel
"wiki_url": "https://github.com/CGCookie/blender-addon-updater",
"tracker_url": "https://github.com/CGCookie/blender-addon-updater/issues",
"category": "System"
}
import bpy
# updater ops import, all setup in this file
from . import addon_updater_ops
class DemoUpdaterPanel(bpy.types.Panel):
"""Panel to demo popup notice and ignoring functionality"""
bl_label = "Updater Demo Panel"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = "objectmode"
bl_category = "Tools"
def draw(self, context):
layout = self.layout
# Call to check for update in background
# note: built-in checks ensure it runs at most once
# and will run in the background thread, not blocking
# or hanging blender
# Internal also checks to see if auto-check enabeld
# and if the time interval has passed
addon_updater_ops.check_for_update_background(context)
layout.label("Demo Updater Addon")
layout.label("")
layout.label("If an update is ready,")
layout.label("popup triggered by opening")
layout.label("this panel & plus a box ui")
# could also use your own custom drawing
# based on shared variables
if addon_updater_ops.updater.update_ready == True:
layout.label("Custom update message", icon="INFO")
layout.label("")
# call built-in function with draw code/checks
addon_updater_ops.update_notice_box_ui(self, context)
# demo bare-bones preferences
class DemoPreferences(bpy.types.AddonPreferences):
bl_idname = __package__
# addon updater preferences
auto_check_update = bpy.props.BoolProperty(
name = "Auto-check for Update",
description = "If enabled, auto-check for updates using an interval",
default = False,
)
updater_intrval_months = bpy.props.IntProperty(
name='Months',
description = "Number of months between checking for updates",
default=0,
min=0
)
updater_intrval_days = bpy.props.IntProperty(
name='Days',
description = "Number of days between checking for updates",
default=7,
min=0,
)
updater_intrval_hours = bpy.props.IntProperty(
name='Hours',
description = "Number of hours between checking for updates",
default=0,
min=0,
max=23
)
updater_intrval_minutes = bpy.props.IntProperty(
name='Minutes',
description = "Number of minutes between checking for updates",
default=0,
min=0,
max=59
)
def draw(self, context):
layout = self.layout
# updater draw function
addon_updater_ops.update_settings_ui(self,context)
def register():
# addon updater code and configurations
# in case of broken version, try to register the updater first
# so that users can revert back to a working version
addon_updater_ops.register(bl_info)
# register the example panel, to show updater buttons
bpy.utils.register_class(DemoPreferences)
bpy.utils.register_class(DemoUpdaterPanel)
def unregister():
# addon updater unregister
addon_updater_ops.unregister()
# register the example panel, to show updater buttons
bpy.utils.unregister_class(DemoPreferences)
bpy.utils.unregister_class(DemoUpdaterPanel)