diff options
author | Jacques Lucke <mail@jlucke.com> | 2019-05-14 15:13:02 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-05-14 15:21:17 +0300 |
commit | 687385b963f4389b3d714fed264bb0ff24bc43f5 (patch) | |
tree | b45b5c6492361425533230e4267e848d7c383715 /source/blender/editors | |
parent | 37f87ae81bc31134cf985277d877afb7b922dbbc (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')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_topbar/space_topbar.c | 7 |
2 files changed, 16 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 40c85217bb3..9e91505f5e8 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -6761,12 +6761,17 @@ int uiTemplateRecentFiles(uiLayout *layout, int rows) for (recent = G.recent_files.first, i = 0; (i < rows) && (recent); recent = recent->next, i++) { const char *filename = BLI_path_basename(recent->filepath); - uiItemStringO(layout, - filename, - BLO_has_bfile_extension(filename) ? ICON_FILE_BLEND : ICON_FILE_BACKUP, - "WM_OT_open_mainfile", - "filepath", - recent->filepath); + PointerRNA ptr; + uiItemFullO(layout, + "WM_OT_open_mainfile", + filename, + BLO_has_bfile_extension(filename) ? ICON_FILE_BLEND : ICON_FILE_BACKUP, + NULL, + WM_OP_INVOKE_DEFAULT, + 0, + &ptr); + RNA_string_set(&ptr, "filepath", recent->filepath); + RNA_boolean_set(&ptr, "display_file_selector", false); } return i; 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 { |