Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-05-14 15:13:02 +0300
committerJacques Lucke <mail@jlucke.com>2019-05-14 15:21:17 +0300
commit687385b963f4389b3d714fed264bb0ff24bc43f5 (patch)
treeb45b5c6492361425533230e4267e848d7c383715 /source/blender/editors/space_topbar
parent37f87ae81bc31134cf985277d877afb7b922dbbc (diff)
UI: Confirm dialog when closing an unsaved file
The complexity in this patch comes from the fact that the current operator system does not support multi-step user interactions well. More specifically, for this to work, we need to show a confirm dialog and a file browser afterwards. We decided that it is easier to keep everything in a single operator, instead of creating separate operators that invoke each other. So, now the `WM_OT_open_mainfile` operator invokes itself in different states. It implements a simple finite state machine to manage the states. The dialog itself is expected to be improved in a future commit. See D4829 for more details. Reviewers: brecht Differential Revision: https://developer.blender.org/D4829
Diffstat (limited to 'source/blender/editors/space_topbar')
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
index 8b290009a97..725a49e417e 100644
--- a/source/blender/editors/space_topbar/space_topbar.c
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -213,12 +213,15 @@ static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
{
struct RecentFile *recent;
uiLayout *layout = menu->layout;
- uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
+ uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
if (!BLI_listbase_is_empty(&G.recent_files)) {
for (recent = G.recent_files.first; (recent); recent = recent->next) {
const char *file = BLI_path_basename(recent->filepath);
const int icon = BLO_has_bfile_extension(file) ? ICON_FILE_BLEND : ICON_FILE_BACKUP;
- uiItemStringO(layout, file, icon, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ PointerRNA ptr;
+ uiItemFullO(layout, "WM_OT_open_mainfile", file, icon, NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr);
+ RNA_string_set(&ptr, "filepath", recent->filepath);
+ RNA_boolean_set(&ptr, "display_file_selector", false);
}
}
else {