~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/ui/space_text.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# ##### BEGIN GPL LICENSE BLOCK #####
2
 
#
3
 
#  This program is free software; you can redistribute it and/or
4
 
#  modify it under the terms of the GNU General Public License
5
 
#  as published by the Free Software Foundation; either version 2
6
 
#  of the License, or (at your option) any later version.
7
 
#
8
 
#  This program is distributed in the hope that it will be useful,
9
 
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
#  GNU General Public License for more details.
12
 
#
13
 
#  You should have received a copy of the GNU General Public License
14
 
#  along with this program; if not, write to the Free Software Foundation,
15
 
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
 
#
17
 
# ##### END GPL LICENSE BLOCK #####
18
 
 
19
 
# <pep8 compliant>
20
 
import bpy
21
 
 
22
 
 
23
 
class TEXT_HT_header(bpy.types.Header):
24
 
    bl_space_type = 'TEXT_EDITOR'
25
 
 
26
 
    def draw(self, context):
27
 
        layout = self.layout
28
 
 
29
 
        st = context.space_data
30
 
        text = st.text
31
 
 
32
 
        row = layout.row(align=True)
33
 
        row.template_header()
34
 
 
35
 
        if context.area.show_menus:
36
 
            sub = row.row(align=True)
37
 
            sub.menu("TEXT_MT_text")
38
 
            if text:
39
 
                sub.menu("TEXT_MT_edit")
40
 
                sub.menu("TEXT_MT_format")
41
 
 
42
 
        if text and text.modified:
43
 
            row = layout.row()
44
 
            # row.color(redalert)
45
 
            row.operator("text.resolve_conflict", text="", icon='HELP')
46
 
 
47
 
        layout.template_ID(st, "text", new="text.new", unlink="text.unlink")
48
 
 
49
 
        row = layout.row(align=True)
50
 
        row.prop(st, "line_numbers", text="")
51
 
        row.prop(st, "word_wrap", text="")
52
 
        row.prop(st, "syntax_highlight", text="")
53
 
 
54
 
        if text:
55
 
            row = layout.row()
56
 
            row.operator("text.run_script")
57
 
 
58
 
            row = layout.row()
59
 
            row.active = text.name.endswith(".py")
60
 
            row.prop(text, "use_module")
61
 
 
62
 
            row = layout.row()
63
 
            if text.filepath:
64
 
                if text.dirty:
65
 
                    row.label(text="File: *%s (unsaved)" % text.filepath)
66
 
                else:
67
 
                    row.label(text="File: %s" % text.filepath)
68
 
            else:
69
 
                row.label(text="Text: External" if text.library else "Text: Internal")
70
 
 
71
 
 
72
 
class TEXT_PT_properties(bpy.types.Panel):
73
 
    bl_space_type = 'TEXT_EDITOR'
74
 
    bl_region_type = 'UI'
75
 
    bl_label = "Properties"
76
 
 
77
 
    def draw(self, context):
78
 
        layout = self.layout
79
 
 
80
 
        st = context.space_data
81
 
 
82
 
        flow = layout.column_flow()
83
 
        flow.prop(st, "line_numbers")
84
 
        flow.prop(st, "word_wrap")
85
 
        flow.prop(st, "syntax_highlight")
86
 
        flow.prop(st, "live_edit")
87
 
 
88
 
        flow = layout.column_flow()
89
 
        flow.prop(st, "font_size")
90
 
        flow.prop(st, "tab_width")
91
 
 
92
 
        text = st.text
93
 
        if text:
94
 
            flow.prop(text, "tabs_as_spaces")
95
 
 
96
 
 
97
 
class TEXT_PT_find(bpy.types.Panel):
98
 
    bl_space_type = 'TEXT_EDITOR'
99
 
    bl_region_type = 'UI'
100
 
    bl_label = "Find"
101
 
 
102
 
    def draw(self, context):
103
 
        layout = self.layout
104
 
 
105
 
        st = context.space_data
106
 
 
107
 
        # find
108
 
        col = layout.column(align=True)
109
 
        row = col.row()
110
 
        row.prop(st, "find_text", text="")
111
 
        row.operator("text.find_set_selected", text="", icon='TEXT')
112
 
        col.operator("text.find")
113
 
 
114
 
        # replace
115
 
        col = layout.column(align=True)
116
 
        row = col.row()
117
 
        row.prop(st, "replace_text", text="")
118
 
        row.operator("text.replace_set_selected", text="", icon='TEXT')
119
 
        col.operator("text.replace")
120
 
 
121
 
        # mark
122
 
        layout.operator("text.mark_all")
123
 
 
124
 
        # settings
125
 
        row = layout.row()
126
 
        row.prop(st, "find_wrap", text="Wrap")
127
 
        row.prop(st, "find_all", text="All")
128
 
 
129
 
 
130
 
class TEXT_MT_text(bpy.types.Menu):
131
 
    bl_label = "Text"
132
 
 
133
 
    def draw(self, context):
134
 
        layout = self.layout
135
 
 
136
 
        st = context.space_data
137
 
        text = st.text
138
 
 
139
 
        layout.column()
140
 
        layout.operator("text.new")
141
 
        layout.operator("text.open")
142
 
 
143
 
        if text:
144
 
            layout.operator("text.reload")
145
 
 
146
 
            layout.column()
147
 
            layout.operator("text.save")
148
 
            layout.operator("text.save_as")
149
 
 
150
 
            if text.filepath:
151
 
                layout.operator("text.make_internal")
152
 
 
153
 
            layout.column()
154
 
            layout.operator("text.run_script")
155
 
 
156
 
            #ifndef DISABLE_PYTHON
157
 
            # XXX if(BPY_is_pyconstraint(text))
158
 
            # XXX   uiMenuItemO(head, 0, "text.refresh_pyconstraints");
159
 
            #endif
160
 
 
161
 
        layout.separator()
162
 
 
163
 
        layout.operator("text.properties", icon='MENU_PANEL')
164
 
 
165
 
        layout.menu("TEXT_MT_templates")
166
 
 
167
 
        layout.separator()
168
 
 
169
 
        layout.operator("screen.area_dupli")
170
 
        layout.operator("screen.screen_full_area")
171
 
 
172
 
 
173
 
class TEXT_MT_templates(bpy.types.Menu):
174
 
    '''
175
 
    Creates the menu items by scanning scripts/templates
176
 
    '''
177
 
    bl_label = "Script Templates"
178
 
 
179
 
    def draw(self, context):
180
 
        self.path_menu(bpy.utils.script_paths("templates"), "text.open", {"internal": True})
181
 
 
182
 
 
183
 
class TEXT_MT_edit_view(bpy.types.Menu):
184
 
    bl_label = "View"
185
 
 
186
 
    def draw(self, context):
187
 
        layout = self.layout
188
 
 
189
 
        layout.operator("text.move", text="Top of File").type = 'FILE_TOP'
190
 
        layout.operator("text.move", text="Bottom of File").type = 'FILE_BOTTOM'
191
 
 
192
 
 
193
 
class TEXT_MT_edit_select(bpy.types.Menu):
194
 
    bl_label = "Select"
195
 
 
196
 
    def draw(self, context):
197
 
        layout = self.layout
198
 
 
199
 
        layout.operator("text.select_all")
200
 
        layout.operator("text.select_line")
201
 
 
202
 
 
203
 
class TEXT_MT_edit_markers(bpy.types.Menu):
204
 
    bl_label = "Markers"
205
 
 
206
 
    def draw(self, context):
207
 
        layout = self.layout
208
 
 
209
 
        layout.operator("text.markers_clear")
210
 
        layout.operator("text.next_marker")
211
 
        layout.operator("text.previous_marker")
212
 
 
213
 
 
214
 
class TEXT_MT_format(bpy.types.Menu):
215
 
    bl_label = "Format"
216
 
 
217
 
    def draw(self, context):
218
 
        layout = self.layout
219
 
 
220
 
        layout.operator("text.indent")
221
 
        layout.operator("text.unindent")
222
 
 
223
 
        layout.separator()
224
 
 
225
 
        layout.operator("text.comment")
226
 
        layout.operator("text.uncomment")
227
 
 
228
 
        layout.separator()
229
 
 
230
 
        layout.operator_menu_enum("text.convert_whitespace", "type")
231
 
 
232
 
 
233
 
class TEXT_MT_edit_to3d(bpy.types.Menu):
234
 
    bl_label = "Text To 3D Object"
235
 
 
236
 
    def draw(self, context):
237
 
        layout = self.layout
238
 
 
239
 
        layout.operator("text.to_3d_object", text="One Object").split_lines = False
240
 
        layout.operator("text.to_3d_object", text="One Object Per Line").split_lines = True
241
 
 
242
 
 
243
 
class TEXT_MT_edit(bpy.types.Menu):
244
 
    bl_label = "Edit"
245
 
 
246
 
    def poll(self, context):
247
 
        return (context.space_data.text)
248
 
 
249
 
    def draw(self, context):
250
 
        layout = self.layout
251
 
 
252
 
        layout.operator("ed.undo")
253
 
        layout.operator("ed.redo")
254
 
 
255
 
        layout.separator()
256
 
 
257
 
        layout.operator("text.cut")
258
 
        layout.operator("text.copy")
259
 
        layout.operator("text.paste")
260
 
 
261
 
        layout.separator()
262
 
 
263
 
        layout.menu("TEXT_MT_edit_view")
264
 
        layout.menu("TEXT_MT_edit_select")
265
 
        layout.menu("TEXT_MT_edit_markers")
266
 
 
267
 
        layout.separator()
268
 
 
269
 
        layout.operator("text.jump")
270
 
        layout.operator("text.properties", text="Find...")
271
 
 
272
 
        layout.separator()
273
 
 
274
 
        layout.menu("TEXT_MT_edit_to3d")
275
 
 
276
 
 
277
 
class TEXT_MT_toolbox(bpy.types.Menu):
278
 
    bl_label = ""
279
 
 
280
 
    def draw(self, context):
281
 
        layout = self.layout
282
 
        layout.operator_context = 'INVOKE_DEFAULT'
283
 
 
284
 
        layout.operator("text.cut")
285
 
        layout.operator("text.copy")
286
 
        layout.operator("text.paste")
287
 
 
288
 
        layout.separator()
289
 
 
290
 
        layout.operator("text.run_script")
291
 
 
292
 
 
293
 
classes = [
294
 
    TEXT_HT_header,
295
 
    TEXT_PT_properties,
296
 
    TEXT_PT_find,
297
 
    TEXT_MT_text,
298
 
    TEXT_MT_templates,
299
 
    TEXT_MT_format,
300
 
    TEXT_MT_edit,
301
 
    TEXT_MT_edit_view,
302
 
    TEXT_MT_edit_select,
303
 
    TEXT_MT_edit_markers,
304
 
    TEXT_MT_edit_to3d,
305
 
    TEXT_MT_toolbox]
306
 
 
307
 
 
308
 
def register():
309
 
    register = bpy.types.register
310
 
    for cls in classes:
311
 
        register(cls)
312
 
 
313
 
 
314
 
def unregister():
315
 
    unregister = bpy.types.unregister
316
 
    for cls in classes:
317
 
        unregister(cls)
318
 
 
319
 
if __name__ == "__main__":
320
 
    register()