[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2870] contrib/py/scripts/addons/ system_theme_manager.py: removing theme manager

Brendon Murphy meta.androcto1 at gmail.com
Fri Jan 6 12:02:09 CET 2012


Revision: 2870
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2870
Author:   meta-androcto
Date:     2012-01-06 11:02:03 +0000 (Fri, 06 Jan 2012)
Log Message:
-----------
removing theme manager
built in system is in place, projects page closed.

Removed Paths:
-------------
    contrib/py/scripts/addons/system_theme_manager.py

Deleted: contrib/py/scripts/addons/system_theme_manager.py
===================================================================
--- contrib/py/scripts/addons/system_theme_manager.py	2012-01-05 19:10:19 UTC (rev 2869)
+++ contrib/py/scripts/addons/system_theme_manager.py	2012-01-06 11:02:03 UTC (rev 2870)
@@ -1,510 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-#  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 2
-#  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, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-# <pep8 compliant>
-
-
-bl_info = {
-    'name': "Theme manager",
-    'author': "Bart Crouch",
-    'version': (1, 4, 0),
-    'blender': (2, 5, 9),
-    'api': 39720,
-    'location': "User Preferences > Themes > Header",
-    'warning': "",
-    'description': "Load or save a custom theme",
-    'wiki_url': "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
-        "Scripts/System/Theme_manager",
-    'tracker_url': "http://projects.blender.org/tracker/index.php?"\
-        "func=detail&aid=26659",
-    'category': 'System'}
-
-
-import bpy
-import gzip
-from bpy_extras.io_utils import ExportHelper, ImportHelper
-import os
-import pickle
-import shutil
-
-
-# function to change the theme
-def apply_theme(self, context):
-    theme = context.window_manager.theme_list
-    if theme == "internal_tm_42_default":
-        bpy.ops.ui.reset_default_theme()
-        print("Applied Default theme")
-        return
-    
-    match = False
-    for (sort_name, theme_name, author, version, filename) in \
-    context.window_manager["theme_list_id"]:
-        if theme_name == theme:
-            match = True
-            break
-    if not match:
-        # should be impossible
-        print("Could not find theme(internal mismatch)")
-        return
-    else:
-        filepath = filename
-    
-    # load file
-    try:
-        file = gzip.open(filepath, mode='r')
-        dump = pickle.load(file)
-        file.close()
-        dump["info"]["script"]
-    except:
-        print("Could not read theme")
-        return
-    
-    # apply theme
-    theme = bpy.context.user_preferences.themes["Default"]
-    for ts, props in dump["values"].items():
-        theme_struct = getattr(theme, ts)
-        for prop, val in props.items():
-            if type(val) != type({}):
-                setattr(theme_struct, prop, val)
-            else:
-                # one level deeper
-                if type(prop) == type(1):
-                    # collection property (bone color set)
-                    prop_struct = theme_struct[prop]
-                else:
-                    prop_struct = getattr(theme_struct, prop)
-                for subprop, subval in val.items():
-                    setattr(prop_struct, subprop, subval)
-    
-    # restore default values for miscellaneous items, before assigning
-    bpy.context.user_preferences.view.object_origin_size = 6
-    bpy.context.user_preferences.view.mini_axis_size = 25
-    bpy.context.user_preferences.view.mini_axis_brightness = 8
-    bpy.context.user_preferences.view.manipulator_size = 15
-    bpy.context.user_preferences.view.manipulator_handle_size = 25
-    bpy.context.user_preferences.view.manipulator_hotspot = 14
-    bpy.context.user_preferences.edit.sculpt_paint_overlay_color = \
-        [0.0, 0.0, 0.0]
-    bpy.context.user_preferences.system.dpi = 72
-    bpy.context.user_preferences.system.use_weight_color_range = False
-    color_range = bpy.context.user_preferences.system.weight_color_range
-    color_range.interpolation = 'LINEAR'
-    while len(color_range.elements) > 1:
-        color_range.elements.remove(color_range.elements[0])
-    if len(color_range.elements) == 1:
-        color_range.elements[0].position = 1.0
-        color_range.elements[0].color = [0.0, 1.0, 0.0, 0.0]
-    lights = bpy.context.user_preferences.system.solid_lights
-    light_settings = [{"diffuse_color":[0.8, 0.8, 0.8],
-        "direction":[-0.892, 0.3, 0.9], "specular_color":[0.5, 0.5, 0.5],
-        "use":True}, {"diffuse_color":[0.498, 0.5, 0.6], 
-        "direction":[0.588, 0.460, 0.248],
-        "specular_color":[0.2, 0.2, 0.2], "use":True},
-        {"diffuse_color":[0.798, 0.838, 1.0],
-        "direction":[0.216, -0.392, -0.216],
-        "specular_color":[0.066, 0.0, 0.0], "use":True}]
-    for i, light in enumerate(lights):
-        settings = light_settings[i]
-        for prop, value in settings.items():
-            setattr(light, prop, value)
-    
-    # theme file created with script version >= 1.3
-    if "misc" in dump:
-        for category, props in dump["misc"].items():
-            category_struct = getattr(bpy.context.user_preferences,
-                category)
-            for prop_name, val in props.items():
-                if type(val) != type({}):
-                    # simple miscellaneous setting
-                    setattr(category_struct, prop_name, val)
-                else:
-                    structs = getattr(category_struct, prop_name)
-                    for subkey, subval in val.items():
-                        if type(subkey) == type(1):
-                            # solid_lights
-                            struct = structs[subkey]
-                            for subprop_name, subprop_val in \
-                            subval.items():
-                                setattr(struct, subprop_name, subprop_val)
-                        else:
-                            # weight paint color-range
-                            if type(subval) != type({}):
-                                setattr(structs, subkey, subval)
-                            else:
-                                elements = getattr(structs, subkey)
-                                add_new = len(subval) - len(elements)
-                                for i in range(add_new):
-                                    elements.new(i / len(subval))
-                                for i, element_prop in subval.items():
-                                    for element_key, element_value in \
-                                    element_prop.items():
-                                        setattr(elements[i], element_key,
-                                            element_value)
-    
-    # report to user
-    author = dump["info"]["author"]
-    theme_name = dump["info"]["theme_name"]
-    print("Applied " + theme_name + " by " + author)
-
-
-# create list for dynamic EnumProperty
-def dynamic_list(self, context):
-    d_list = [('internal_tm_42_default', "Default", "Reset to the "\
-        "default theme colors")]
-    if "theme_list_id" in context.window_manager:
-        for i, theme, author, version, path in \
-        context.window_manager["theme_list_id"]:
-            if version:
-                version = " " + version
-            d_list.append((theme, theme + version + " by " + author,
-                "Apply " + theme + version))
-    
-    return(d_list)
-
-
-# return path of the folder where all themes are located
-def get_paths():
-    # locate theme preset folder
-    paths = bpy.utils.preset_paths("theme")
-    if not paths:
-        # theme preset folder doesn't exist, so create it
-        paths = [os.path.join(bpy.utils.user_resource('SCRIPTS'), "presets",
-            "theme")]
-        if not os.path.exists(paths[0]):
-            os.makedirs(paths[0])
-    
-    return(paths)
-
-
-# create list of all themes available
-def load_presets():
-    # find theme files
-    paths = get_paths()
-    theme_files = []
-    for path in paths:
-        for root, dirs, files in os.walk(path):
-            for file in files:
-                if file.endswith(".blt"):
-                    theme_files.append(os.path.join(root, file))
-    
-    # read author and theme names
-    theme_list = []
-    for filename in theme_files:
-        # load file
-        try:
-            file = gzip.open(filename, mode='r')
-            dump = pickle.load(file)
-            file.close()
-            author = dump["info"]["author"]
-            theme_name = dump["info"]["theme_name"]
-            sort_name = theme_name.lower()
-            # theme_version available if created with script version >= 1.4
-            theme_version = dump["info"].get("theme_version", "")
-            theme_list.append([sort_name, theme_name, author, theme_version,
-                filename])
-        except:
-            continue
-    theme_list.sort()
-    
-    # store list in window-manager
-    bpy.context.window_manager["theme_list_id"] = theme_list
-    try:
-        # check if EnumProp exists: overwrite might cause memory corruption
-        bpy.context.window_manager.theme_list
-    except:
-        # create EnumProp, because it doesn't exist yet
-        bpy.types.WindowManager.theme_list = bpy.props.EnumProperty(\
-            name="Load Theme",
-            items=dynamic_list,
-            description="Load a theme",
-            update=apply_theme)
-
-
-def unload_presets():
-    # remove settings from window-manager
-    del bpy.context.window_manager["theme_list_id"]
-    try:
-        del bpy.types.WindowManager.theme_list
-        print('successfully removed theme_list enum property')
-    except:
-        pass
-
-
-# install operator
-class InstallTheme(bpy.types.Operator, ImportHelper):
-    bl_idname = "ui.install_theme"
-    bl_label = "Install new theme"
-    bl_description = "Install a new theme"
-    
-    filename_ext = ".blt"
-    filter_glob = bpy.props.StringProperty(default="*.blt", options={'HIDDEN'})
-    
-    def execute(self, context):
-        # copy theme to presets folder
-        filename = os.path.basename(self.filepath)
-        try:
-            shutil.copyfile(self.filepath,
-                os.path.join(get_paths()[0], filename))
-        except:
-            self.report({'ERROR'}, "Installing failed")

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list