# Scene Workspaces - Blender Add-On
# Copyright (C) 2024  Francesco Bellini

# 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 3 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, see <https://www.gnu.org/licenses/>.
import bpy
from .sw.funcs import select_all, workspace_menu
from .sw.ops import SW_OT_workspace, SW_OT_link_workspace, SW_OT_move, SW_OT_link_all, SW_OT_remove, SW_OT_switch, SW_OT_rename, SW_OT_copy_from_scene
from .sw.topbar import TOPBAR_HT_upper_bar
from .sw.panel import SW_PT_select_scene_workspaces
from .sw.menu import SW_MT_missing_workspaces, SW_MT_copy_from
from .sw.prefs import SW_Preferences

bl_info = {
    "id": "scene_workspaces",
    "name": "Scene Workspaces",
    "tagline": "Filter and sort your workspaces for each scene independently",
    "blender": (4, 2, 0),
    "location": "Workspaces topbar, Properties > Scene",
    "category": ["Scene", "System", "User Interface"],
    "support": "COMMUNITY",
    "blender_manifest": "blender_manifest.toml"
}

classes = [
    SW_OT_workspace, 
    SW_OT_switch,
    SW_OT_move, 
    SW_OT_remove,
    SW_OT_rename,
    SW_OT_link_workspace,
    SW_OT_link_all, 
    SW_OT_copy_from_scene,
    SW_MT_copy_from,
    SW_MT_missing_workspaces,
    SW_PT_select_scene_workspaces,
    SW_Preferences,
    TOPBAR_HT_upper_bar
]

og_header = None;

def register():
    global og_header
    og_header = bpy.types.TOPBAR_HT_upper_bar;
    for c in classes:
        bpy.utils.register_class(c)
    bpy.types.TOPBAR_MT_workspace_menu.prepend(workspace_menu)

def unregister():
    for c in reversed(classes):
        bpy.utils.unregister_class(c)
    bpy.utils.register_class(og_header)
    bpy.types.TOPBAR_MT_workspace_menu.remove(workspace_menu)
    
if __name__ == "__main__":
    register()