Cleanup: move theme reset into it's own operator file
This commit is contained in:
parent
3804636ee5
commit
33b03f7f68
|
@ -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):
|
||||
|
|
|
@ -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__ */
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue