Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_userpref.py
| Context not available. | |||||
| def draw_buttons(layout, context): | def draw_buttons(layout, context): | ||||
| prefs = context.preferences | prefs = context.preferences | ||||
| layout.scale_x = 1.0 | |||||
| layout.scale_y = 1.0 | |||||
| layout.operator_context = 'EXEC_AREA' | layout.operator_context = 'EXEC_AREA' | ||||
| # Show when header is visible | |||||
| header = True | |||||
| for region in context.area.regions: | |||||
| if region.type == 'HEADER' and region.height <= 1: | |||||
| header = False | |||||
| row = layout.row() | row = layout.row() | ||||
| row.menu("USERPREF_MT_save_load", text="", icon='COLLAPSEMENU') | |||||
| if prefs.use_preferences_save and (not bpy.app.use_userpref_skip_save_on_exit): | if header: | ||||
| pass | row.menu("USERPREF_MT_view") | ||||
| row.menu("USERPREF_MT_save_load", text="Preferences") | |||||
| row.separator_spacer() | |||||
| else: | else: | ||||
| row.menu("USERPREF_MT_save_load", text="", icon='COLLAPSEMENU') | |||||
| # The notification that auto-save is overridden. | |||||
| if bpy.app.use_userpref_skip_save_on_exit and prefs.use_preferences_save: | |||||
| sub = row.row(align=True) | |||||
| sub.operator_context = 'INVOKE_DEFAULT' | |||||
| sub.operator( | |||||
| "wm.message_box", | |||||
| text="", | |||||
| icon="ERROR", | |||||
| emboss=False, | |||||
| ) | |||||
| if not prefs.use_preferences_save: | |||||
| # Show '*' to let users know the preferences have been modified. | # Show '*' to let users know the preferences have been modified. | ||||
| row.operator( | row.operator( | ||||
| "wm.save_userpref", | "wm.save_userpref", | ||||
| Context not available. | |||||
| layout.template_header() | layout.template_header() | ||||
| layout.separator_spacer() | |||||
| self.draw_buttons(layout, context) | self.draw_buttons(layout, context) | ||||
| Context not available. | |||||
| col.prop(prefs, "active_section", expand=True) | col.prop(prefs, "active_section", expand=True) | ||||
| class USERPREF_MT_view(Menu): | |||||
| bl_label = "View" | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| layout.menu("INFO_MT_area") | |||||
| class USERPREF_MT_save_load(Menu): | class USERPREF_MT_save_load(Menu): | ||||
| bl_label = "Save & Load" | bl_label = "Save & Load" | ||||
| Context not available. | |||||
| layout = self.layout | layout = self.layout | ||||
| layout.operator_context = 'EXEC_AREA' | layout.operator_context = 'EXEC_AREA' | ||||
| layout.scale_x = 1.3 | |||||
| layout.scale_y = 1.3 | |||||
| USERPREF_HT_header.draw_buttons(layout, context) | USERPREF_HT_header.draw_buttons(layout, context) | ||||
| class USERPREF_OT_message_box(bpy.types.Operator): | |||||
| bl_idname = "wm.message_box" | |||||
| bl_label = "" | |||||
| bl_description = ("This session has factory settings applied\n" | |||||
| "which temporarily disables \"Auto-Save Preferences\".\n" | |||||
| "Saving preferences must be done manually") | |||||
| bl_options = {'INTERNAL'} | |||||
| def invoke(self, context, _event): | |||||
| def draw_menu(popover, context): | |||||
| layout = popover.layout | |||||
| col = layout.column(align=True) | |||||
| for line in (self.bl_description + ".").splitlines(): | |||||
| col.label(text=line) | |||||
| context.window_manager.popover( | |||||
| draw_menu, | |||||
| ui_units_x=15, | |||||
| from_active_button=True, | |||||
| ) | |||||
| return {'FINISHED'} | |||||
| # ----------------------------------------------------------------------------- | # ----------------------------------------------------------------------------- | ||||
| # Min-In Helpers | # Min-In Helpers | ||||
| Context not available. | |||||
| USERPREF_HT_header, | USERPREF_HT_header, | ||||
| USERPREF_PT_navigation_bar, | USERPREF_PT_navigation_bar, | ||||
| USERPREF_PT_save_preferences, | USERPREF_PT_save_preferences, | ||||
| USERPREF_MT_view, | |||||
| USERPREF_MT_save_load, | USERPREF_MT_save_load, | ||||
| USERPREF_OT_message_box, | |||||
| USERPREF_PT_interface_display, | USERPREF_PT_interface_display, | ||||
| USERPREF_PT_interface_editors, | USERPREF_PT_interface_editors, | ||||
| Context not available. | |||||