[Bf-blender-cvs] [33b03f7f689] master: Cleanup: move theme reset into it's own operator file

Campbell Barton noreply at git.blender.org
Fri Mar 1 15:01:18 CET 2019


Commit: 33b03f7f68922efada6ec7518c4fa60e9acb620a
Author: Campbell Barton
Date:   Sat Mar 2 00:52:00 2019 +1100
Branches: master
https://developer.blender.org/rB33b03f7f68922efada6ec7518c4fa60e9acb620a

Cleanup: move theme reset into it's own operator file

===================================================================

M	release/scripts/startup/bl_ui/space_userpref.py
A	source/blender/editors/include/ED_userpref.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/interface/resources.c
M	source/blender/editors/space_api/spacetypes.c
M	source/blender/editors/space_userpref/userpref_ops.c

===================================================================

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/space_userpref/userpref_ops.c b/source/blender/editors/include/ED_userpref.h
similarity index 82%
copy from source/blender/editors/space_userpref/userpref_ops.c
copy to source/blender/editors/include/ED_userpref.h
index 4ba3c988c4d..29470608933 100644
--- a/source/blender/editors/space_userpref/userpref_ops.c
+++ b/source/blender/editors/include/ED_userpref.h
@@ -12,15 +12,15 @@
  * 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.
- *
- * The Original Code is Copyright (C) 2008 Blender Foundation.
- * All rights reserved.
  */
 
 /** \file
- * \ingroup spuserpref
+ * \ingroup editors
  */
 
+#ifndef __ED_USERPREF_H__
+#define __ED_USERPREF_H__
+
+void ED_operatortypes_userpref(void);
 
-#include <string.h>
-#include <stdio.h>
+#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);
+}



More information about the Bf-blender-cvs mailing list