Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_topbar.py
| # SPDX-License-Identifier: GPL-2.0-or-later | # SPDX-License-Identifier: GPL-2.0-or-later | ||||
| import bpy | import bpy | ||||
| from bpy.types import Header, Menu, Panel | from bpy.types import Header, Menu, Panel | ||||
| from bpy.app.translations import pgettext_iface as iface_ | from bpy.app.translations import ( | ||||
| pgettext_iface as iface_, | |||||
| contexts as i18n_contexts, | |||||
| ) | |||||
| class TOPBAR_HT_upper_bar(Header): | class TOPBAR_HT_upper_bar(Header): | ||||
| bl_space_type = 'TOPBAR' | bl_space_type = 'TOPBAR' | ||||
| def draw(self, context): | def draw(self, context): | ||||
| region = context.region | region = context.region | ||||
| ▲ Show 20 Lines • Show All 250 Lines • ▼ Show 20 Lines | |||||
| class TOPBAR_MT_file(Menu): | class TOPBAR_MT_file(Menu): | ||||
| bl_label = "File" | bl_label = "File" | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| layout.operator_context = 'INVOKE_AREA' | layout.operator_context = 'INVOKE_AREA' | ||||
| layout.menu("TOPBAR_MT_file_new", text="New", icon='FILE_NEW') | layout.menu("TOPBAR_MT_file_new", text="New", | ||||
| text_context=i18n_contexts.id_windowmanager, | |||||
| icon='FILE_NEW') | |||||
| layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER') | layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER') | ||||
| layout.menu("TOPBAR_MT_file_open_recent") | layout.menu("TOPBAR_MT_file_open_recent") | ||||
| layout.operator("wm.revert_mainfile") | layout.operator("wm.revert_mainfile") | ||||
| layout.menu("TOPBAR_MT_file_recover") | layout.menu("TOPBAR_MT_file_recover") | ||||
| layout.separator() | layout.separator() | ||||
| layout.operator_context = 'EXEC_AREA' if context.blend_data.is_saved else 'INVOKE_AREA' | layout.operator_context = 'EXEC_AREA' if context.blend_data.is_saved else 'INVOKE_AREA' | ||||
| ▲ Show 20 Lines • Show All 438 Lines • ▼ Show 20 Lines | |||||
| class TOPBAR_MT_file_context_menu(Menu): | class TOPBAR_MT_file_context_menu(Menu): | ||||
| bl_label = "File Context Menu" | bl_label = "File Context Menu" | ||||
| def draw(self, _context): | def draw(self, _context): | ||||
| layout = self.layout | layout = self.layout | ||||
| layout.operator_context = 'INVOKE_AREA' | layout.operator_context = 'INVOKE_AREA' | ||||
| layout.menu("TOPBAR_MT_file_new", text="New", icon='FILE_NEW') | layout.menu("TOPBAR_MT_file_new", text="New", text_context=i18n_contexts.id_windowmanager, icon='FILE_NEW') | ||||
| layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER') | layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER') | ||||
| layout.separator() | layout.separator() | ||||
| layout.operator("wm.link", text="Link...", icon='LINK_BLEND') | layout.operator("wm.link", text="Link...", icon='LINK_BLEND') | ||||
| layout.operator("wm.append", text="Append...", icon='APPEND_BLEND') | layout.operator("wm.append", text="Append...", icon='APPEND_BLEND') | ||||
| layout.separator() | layout.separator() | ||||
| ▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines | |||||