diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-01 16:52:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-01 16:53:39 +0300 |
commit | 33b03f7f68922efada6ec7518c4fa60e9acb620a (patch) | |
tree | 369a3c221b204ea027337c94c523994b10c617d9 | |
parent | 3804636ee57b58c0ca02dd5360f6df62603ae929 (diff) |
Cleanup: move theme reset into it's own operator file
-rw-r--r-- | release/scripts/startup/bl_ui/space_userpref.py | 4 | ||||
-rw-r--r-- | source/blender/editors/include/ED_userpref.h | 26 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 26 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_api/spacetypes.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_userpref/userpref_ops.c | 54 |
8 files changed, 87 insertions, 36 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 0697d794c6b..811bf7e50fd 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -694,7 +694,7 @@ class USERPREF_MT_interface_theme_presets(Menu): draw = Menu.draw_preset def reset_cb(context): - bpy.ops.ui.reset_default_theme() + bpy.ops.preferences.reset_default_theme() class USERPREF_PT_theme(Panel): @@ -720,7 +720,7 @@ class USERPREF_PT_theme(Panel): row = split.row(align=True) row.operator("preferences.theme_install", text="Install...", icon='IMPORT') - row.operator("ui.reset_default_theme", text="Reset", icon='LOOP_BACK') + row.operator("preferences.reset_default_theme", text="Reset", icon='LOOP_BACK') class USERPREF_PT_theme_user_interface(PreferencePanel): diff --git a/source/blender/editors/include/ED_userpref.h b/source/blender/editors/include/ED_userpref.h new file mode 100644 index 00000000000..29470608933 --- /dev/null +++ b/source/blender/editors/include/ED_userpref.h @@ -0,0 +1,26 @@ +/* + * 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. + */ + +/** \file + * \ingroup editors + */ + +#ifndef __ED_USERPREF_H__ +#define __ED_USERPREF_H__ + +void ED_operatortypes_userpref(void); + +#endif /* __ED_USERPREF_H__ */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 79f80c67a1a..9c771994c4b 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1402,6 +1402,10 @@ void UI_widgetbase_draw_cache_begin(void); void UI_widgetbase_draw_cache_flush(void); void UI_widgetbase_draw_cache_end(void); +/* Use for resetting the theme. */ +void UI_theme_init_default(void); +void UI_style_init_default(void); + /* Special drawing for toolbar, mainly workarounds for inflexible icon sizing. */ #define USE_UI_TOOLBAR_HACK diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 656e7277fc2..19390a634fa 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -818,8 +818,6 @@ void icon_draw_rect_input( /* resources.c */ void init_userdef_do_versions(struct Main *bmain); -void ui_theme_init_default(void); -void ui_style_init_default(void); void ui_resources_init(void); void ui_resources_free(void); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index fdf666564b9..615259077b5 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -70,31 +70,6 @@ #include "BKE_main.h" #include "BLI_ghash.h" -/* Reset Default Theme ------------------------ */ - -static int reset_default_theme_exec(bContext *C, wmOperator *UNUSED(op)) -{ - ui_theme_init_default(); - ui_style_init_default(); - WM_event_add_notifier(C, NC_WINDOW, NULL); - - return OPERATOR_FINISHED; -} - -static void UI_OT_reset_default_theme(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Reset to Default Theme"; - ot->idname = "UI_OT_reset_default_theme"; - ot->description = "Reset to the default theme colors"; - - /* callbacks */ - ot->exec = reset_default_theme_exec; - - /* flags */ - ot->flag = OPTYPE_REGISTER; -} - /* Copy Data Path Operator ------------------------ */ static bool copy_data_path_button_poll(bContext *C) @@ -1603,7 +1578,6 @@ static void UI_OT_drop_color(wmOperatorType *ot) void ED_operatortypes_ui(void) { - WM_operatortype_append(UI_OT_reset_default_theme); WM_operatortype_append(UI_OT_copy_data_path_button); WM_operatortype_append(UI_OT_copy_python_command_button); WM_operatortype_append(UI_OT_reset_default_button); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index eaa3da8c305..48b24da8f5c 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -744,9 +744,8 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) * \note: when you add new colors, created & saved themes need initialized * use function below, init_userdef_do_versions() */ -void ui_theme_init_default(void) +void UI_theme_init_default(void) { - /* we search for the theme with name Default */ bTheme *btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name)); if (btheme == NULL) { @@ -761,7 +760,7 @@ void ui_theme_init_default(void) btheme->active_theme_area = active_theme_area; } -void ui_style_init_default(void) +void UI_style_init_default(void) { BLI_freelistN(&U.uistyles); /* gets automatically re-allocated */ diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 60094c4edb7..0288d7888d8 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -57,6 +57,7 @@ #include "ED_space_api.h" #include "ED_sound.h" #include "ED_uvedit.h" +#include "ED_userpref.h" #include "ED_lattice.h" #include "ED_mball.h" #include "ED_logic.h" @@ -99,6 +100,7 @@ void ED_spacetypes_init(void) // ... /* register operator types for screen and all spaces */ + ED_operatortypes_userpref(); ED_operatortypes_workspace(); ED_operatortypes_scene(); ED_operatortypes_screen(); diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c index 4ba3c988c4d..f6aaf01747c 100644 --- a/source/blender/editors/space_userpref/userpref_ops.c +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2008 Blender Foundation. + * The Original Code is Copyright (C) 2009 Blender Foundation. * All rights reserved. */ @@ -21,6 +21,54 @@ * \ingroup spuserpref */ - #include <string.h> -#include <stdio.h> + +#include "DNA_screen_types.h" + +#include "BKE_context.h" +#include "BKE_report.h" + +#include "RNA_types.h" + +#include "UI_interface.h" + +#include "../interface/interface_intern.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_userpref.h" + +/* -------------------------------------------------------------------- */ +/** \name Reset Default Theme + * \{ */ + +static int reset_default_theme_exec(bContext *C, wmOperator *UNUSED(op)) +{ + UI_theme_init_default(); + UI_style_init_default(); + WM_event_add_notifier(C, NC_WINDOW, NULL); + + return OPERATOR_FINISHED; +} + +static void PREFERENCES_OT_reset_default_theme(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Reset to Default Theme"; + ot->idname = "PREFERENCES_OT_reset_default_theme"; + ot->description = "Reset to the default theme colors"; + + /* callbacks */ + ot->exec = reset_default_theme_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER; +} + +/** \} */ + +void ED_operatortypes_userpref(void) +{ + WM_operatortype_append(PREFERENCES_OT_reset_default_theme); +} |