[Bf-blender-cvs] [99acf30eddd] filebrowser_redesign: Gray out number increment/decrement button for file open operations

Julian Eisel noreply at git.blender.org
Mon Sep 2 16:40:29 CEST 2019


Commit: 99acf30eddd78b90c6795a672aa6c3c41ca2bddc
Author: Julian Eisel
Date:   Mon Sep 2 16:37:50 2019 +0200
Branches: filebrowser_redesign
https://developer.blender.org/rB99acf30eddd78b90c6795a672aa6c3c41ca2bddc

Gray out number increment/decrement button for file open operations

The buttons are shown in the file browser context menu.

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

M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_file/filesel.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/windowmanager/intern/wm_operator_props.c

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

diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 6d474ef7ccb..f51854eb61a 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -2361,6 +2361,17 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot)
   ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
 }
 
+static bool file_filenum_poll(bContext *C)
+{
+  SpaceFile *sfile = CTX_wm_space_file(C);
+
+  if (!ED_operator_file_active(C)) {
+    return false;
+  }
+
+  return (sfile->params->action_type == FILE_SAVE);
+}
+
 /**
  * Looks for a string of digits within name (using BLI_stringdec) and adjusts it by add.
  */
@@ -2418,7 +2429,7 @@ void FILE_OT_filenum(struct wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = file_filenum_exec;
-  ot->poll = ED_operator_file_active; /* <- important, handler is on window level */
+  ot->poll = file_filenum_poll;
 
   /* props */
   RNA_def_int(ot->srna, "increment", 1, -100, 100, "Increment", "", -100, 100);
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 261e4936564..3223fe0c6ce 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -271,6 +271,10 @@ short ED_fileselect_set_params(SpaceFile *sfile)
       params->sort = FILE_SORT_ALPHA;
     }
 
+    if ((prop = RNA_struct_find_property(op->ptr, "action_type"))) {
+      params->action_type = RNA_property_enum_get(op->ptr, prop);
+    }
+
     if (params->display == FILE_DEFAULTDISPLAY) {
       if (params->display_previous == FILE_DEFAULTDISPLAY) {
         if (U.uiflag & USER_SHOW_THUMBNAILS) {
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 5415b26c936..2fc42e904c2 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -679,7 +679,8 @@ typedef struct FileSelectParams {
   short display_previous;
   /** Details toggles (file size, creation date, etc.) */
   char details_flags;
-  char _pad2;
+  /* The type of file action (opening or saving) */
+  char action_type; /* eFileSel_Action */
   /** Filter when (flags & FILE_FILTER) is true. */
   int filter;
 
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 8efef043b79..663e4adf06b 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -78,6 +78,14 @@ void WM_operator_properties_filesel(wmOperatorType *ot,
       {FILE_IMGDISPLAY, "THUMBNAIL", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"},
       {0, NULL, 0, NULL, NULL},
   };
+  static const EnumPropertyItem file_action_types[] = {
+      {FILE_OPENFILE,
+       "OPENFILE",
+       0,
+       "Open",
+       "Use the file browser for opening files or a directory"},
+      {FILE_SAVE, "SAVE", 0, "Save", "Use the file browser for saving a file"},
+  };
 
   if (flag & WM_FILESEL_FILEPATH) {
     RNA_def_string_file_path(ot->srna, "filepath", NULL, FILE_MAX, "File Path", "Path to file");
@@ -195,6 +203,9 @@ void WM_operator_properties_filesel(wmOperatorType *ot,
   prop = RNA_def_enum(
       ot->srna, "sort_method", rna_enum_file_sort_items, sort, "File sorting mode", "");
   RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+
+  prop = RNA_def_enum(ot->srna, "action_type", file_action_types, action, "Action Type", "");
+  RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
 }
 
 static void wm_operator_properties_select_action_ex(wmOperatorType *ot,



More information about the Bf-blender-cvs mailing list