|
@@ -0,0 +1,60 @@
|
|
1
|
+import bpy
|
|
2
|
+
|
|
3
|
+class OBJECT_PT_pushpuller(bpy.types.Header):
|
|
4
|
+ bl_label = "Push Puller"
|
|
5
|
+ bl_space_type = "TEXT_EDITOR"
|
|
6
|
+ bl_region_type = "HEADER"
|
|
7
|
+ bl_context = "object"
|
|
8
|
+
|
|
9
|
+ def draw_header(self, context):
|
|
10
|
+ layout = self.layout
|
|
11
|
+ layout.label(text="", icon="PHYSICS")
|
|
12
|
+
|
|
13
|
+ def draw(self, context):
|
|
14
|
+ layout = self.layout
|
|
15
|
+ row = layout.row()
|
|
16
|
+ split = row.split(percentage=0.5)
|
|
17
|
+ col_left = split.column()
|
|
18
|
+ col_right = split.column()
|
|
19
|
+ col_right.operator("object.puller", text="Pull")
|
|
20
|
+ col_left.operator("object.pusher", text="Push")
|
|
21
|
+
|
|
22
|
+class OBJECT_OT_pusher(bpy.types.Operator):
|
|
23
|
+ bl_label = "Pusher"
|
|
24
|
+ bl_idname = "object.pusher"
|
|
25
|
+ bl_description = "Push text data block changes"
|
|
26
|
+
|
|
27
|
+ def execute(self, context):
|
|
28
|
+ area = bpy.context.area
|
|
29
|
+ for text in bpy.data.texts:
|
|
30
|
+ area.spaces[0].text = text
|
|
31
|
+ if text.filepath != '' and text.is_dirty:
|
|
32
|
+ bpy.ops.text.save()
|
|
33
|
+ self.report({'INFO'}, "Performing push")
|
|
34
|
+ return {'FINISHED'}
|
|
35
|
+
|
|
36
|
+class OBJECT_OT_pullerer(bpy.types.Operator):
|
|
37
|
+ bl_label = "Puller"
|
|
38
|
+ bl_idname = "object.puller"
|
|
39
|
+ bl_description = "Pull text data block changes"
|
|
40
|
+
|
|
41
|
+ def execute(self, context):
|
|
42
|
+ area = bpy.context.area
|
|
43
|
+ for text in bpy.data.texts:
|
|
44
|
+ area.spaces[0].text = text
|
|
45
|
+ if text.filepath != '':
|
|
46
|
+ bpy.ops.text.reload()
|
|
47
|
+ if text.filepath != '' and text.is_dirty:
|
|
48
|
+ bpy.ops.text.save()
|
|
49
|
+
|
|
50
|
+ self.report({'INFO'}, "Performing pull")
|
|
51
|
+ return {'FINISHED'}
|
|
52
|
+
|
|
53
|
+def register():
|
|
54
|
+ bpy.utils.register_module(__name__)
|
|
55
|
+
|
|
56
|
+def unregister():
|
|
57
|
+ bpy.utils.unregister_module(__name__)
|
|
58
|
+
|
|
59
|
+if __name__ == "__main__":
|
|
60
|
+ register()
|