From a4c845bcb3bfee464c1c6a891dce917837b99c0e Mon Sep 17 00:00:00 2001 From: Jonas Holzman Date: Sat, 23 Dec 2023 17:02:35 +0100 Subject: [PATCH 1/3] Implemented the Clear Recent Files List Operator --- .../editors/space_topbar/space_topbar.cc | 2 ++ .../blender/windowmanager/intern/wm_files.cc | 24 +++++++++++++++++++ .../windowmanager/intern/wm_operators.cc | 1 + source/blender/windowmanager/wm_files.hh | 2 ++ 4 files changed, 29 insertions(+) diff --git a/source/blender/editors/space_topbar/space_topbar.cc b/source/blender/editors/space_topbar/space_topbar.cc index 59af59d5059..89816deca03 100644 --- a/source/blender/editors/space_topbar/space_topbar.cc +++ b/source/blender/editors/space_topbar/space_topbar.cc @@ -206,6 +206,8 @@ static void recent_files_menu_draw(const bContext * /*C*/, Menu *menu) RNA_string_set(&ptr, "filepath", recent->filepath); RNA_boolean_set(&ptr, "display_file_selector", false); } + uiItemS(layout); + uiItemO(layout, nullptr, ICON_NONE, "WM_OT_clear_recent_files"); } else { uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE); diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index 138925289dc..4ada65a58d4 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -3544,6 +3544,30 @@ void WM_OT_save_mainfile(wmOperatorType *ot) /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Clear Recent Files List Operator + * \{ */ + +static int wm_clear_recent_files_exec(bContext * /*C*/, wmOperator * /*op*/) +{ + wm_history_files_free(); + wm_history_file_write(); + + return OPERATOR_FINISHED; +} + +void WM_OT_clear_recent_files(wmOperatorType *ot) +{ + ot->name = "Clear Recent Files"; + ot->idname = "WM_OT_clear_recent_files"; + ot->description = "Clear the Recent Files List"; + + ot->invoke = WM_operator_confirm; + ot->exec = wm_clear_recent_files_exec; +} + +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Auto Script Execution Warning Dialog * \{ */ diff --git a/source/blender/windowmanager/intern/wm_operators.cc b/source/blender/windowmanager/intern/wm_operators.cc index 428463cdb71..0763ec88b88 100644 --- a/source/blender/windowmanager/intern/wm_operators.cc +++ b/source/blender/windowmanager/intern/wm_operators.cc @@ -3888,6 +3888,7 @@ void wm_operatortypes_register() WM_operatortype_append(WM_OT_recover_auto_save); WM_operatortype_append(WM_OT_save_as_mainfile); WM_operatortype_append(WM_OT_save_mainfile); + WM_operatortype_append(WM_OT_clear_recent_files); WM_operatortype_append(WM_OT_redraw_timer); WM_operatortype_append(WM_OT_memory_statistics); WM_operatortype_append(WM_OT_debug_menu); diff --git a/source/blender/windowmanager/wm_files.hh b/source/blender/windowmanager/wm_files.hh index 6d0c7d6891f..d62ef68dc27 100644 --- a/source/blender/windowmanager/wm_files.hh +++ b/source/blender/windowmanager/wm_files.hh @@ -116,6 +116,8 @@ void WM_OT_recover_auto_save(wmOperatorType *ot); void WM_OT_save_as_mainfile(wmOperatorType *ot); void WM_OT_save_mainfile(wmOperatorType *ot); +void WM_OT_clear_recent_files(wmOperatorType *ot); + /* `wm_files_link.cc` */ void WM_OT_link(wmOperatorType *ot); -- 2.30.2 From 8473de1a3a430715a814e346beab2ff67b5e889f Mon Sep 17 00:00:00 2001 From: Jonas Holzman Date: Thu, 28 Dec 2023 01:51:26 +0100 Subject: [PATCH 2/3] Use ICON_TRASH for the Operator Button --- source/blender/editors/space_topbar/space_topbar.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_topbar/space_topbar.cc b/source/blender/editors/space_topbar/space_topbar.cc index 89816deca03..c107eb10740 100644 --- a/source/blender/editors/space_topbar/space_topbar.cc +++ b/source/blender/editors/space_topbar/space_topbar.cc @@ -207,7 +207,7 @@ static void recent_files_menu_draw(const bContext * /*C*/, Menu *menu) RNA_boolean_set(&ptr, "display_file_selector", false); } uiItemS(layout); - uiItemO(layout, nullptr, ICON_NONE, "WM_OT_clear_recent_files"); + uiItemO(layout, nullptr, ICON_TRASH, "WM_OT_clear_recent_files"); } else { uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE); -- 2.30.2 From 3d2641aa00320ef785bdb4b4d860f6e8f7e1bf6b Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 3 Jan 2024 11:52:48 -0800 Subject: [PATCH 3/3] Clear Recent Files -> Clear Recent Files List --- source/blender/windowmanager/intern/wm_files.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index d0987f018af..161b797a419 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -3585,7 +3585,7 @@ static int wm_clear_recent_files_exec(bContext * /*C*/, wmOperator * /*op*/) void WM_OT_clear_recent_files(wmOperatorType *ot) { - ot->name = "Clear Recent Files"; + ot->name = "Clear Recent Files List"; ot->idname = "WM_OT_clear_recent_files"; ot->description = "Clear the Recent Files List"; -- 2.30.2