[Bf-blender-cvs] [4fe074e2b90] soc-2020-info-editor: Add SpaceInfoFilter to RNA

Mateusz Grzeliński noreply at git.blender.org
Tue Aug 11 16:26:36 CEST 2020


Commit: 4fe074e2b906194c7772cd2fbec479e7e3ae81b1
Author: Mateusz Grzeliński
Date:   Mon Aug 10 17:03:15 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB4fe074e2b906194c7772cd2fbec479e7e3ae81b1

Add SpaceInfoFilter to RNA

- add add, remove operators

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

M	release/scripts/startup/bl_ui/space_info.py
M	source/blender/editors/space_info/info_intern.h
M	source/blender/editors/space_info/info_ops.c
M	source/blender/editors/space_info/space_info.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index b8569be0a3a..f2a3fa2aeba 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -152,21 +152,34 @@ class INFO_PT_report_type_visibility(Panel):
 
             box = layout.box()
             row = box.row(align=True)
-            row.prop(sinfo, "use_log_file_line_filter", text="")
-            row.label(text="Filter File Line")
-            row.operator("preferences.autoexec_path_add", text="", icon='ADD', emboss=False)
+            row.prop(sinfo, "use_log_file_line_filter", text="Filter File Line")
+            row.operator("info.log_file_line_filter_add", text="", icon='ADD', emboss=False)
+            for i, filter in enumerate(sinfo.filter_log_file_line):
+                row = box.row()
+                row.active = sinfo.use_log_file_line_filter
+                row.prop(filter, "search_string", text="")
+                # row.prop(path_cmp, "use_glob", text="", icon='FILTER')
+                row.operator("info.log_file_line_filter_remove", text="", icon='X', emboss=False).index = i
 
             box = layout.box()
             row = box.row(align=True)
-            row.prop(sinfo, "use_log_type_filter", text="")
-            row.label(text="Filter Log Type")
-            row.operator("preferences.autoexec_path_add", text="", icon='ADD', emboss=False)
+            row.prop(sinfo, "use_log_type_filter", text="Filter Log Type")
+            row.operator("info.log_type_filter_add", text="", icon='ADD', emboss=False)
+            for i, filter in enumerate(sinfo.filter_log_type):
+                row = box.row()
+                row.active = sinfo.use_log_type_filter
+                row.prop(filter, "search_string", text="")
+                row.operator("info.log_type_filter_remove", text="", icon='X', emboss=False).index = i
 
             box = layout.box()
             row = box.row(align=True)
-            row.prop(sinfo, "use_log_function_filter", text="")
-            row.label(text="Filter Log Function")
-            row.operator("preferences.autoexec_path_add", text="", icon='ADD', emboss=False)
+            row.prop(sinfo, "use_log_function_filter", text="Filter Log Function")
+            row.operator("info.log_function_filter_add", text="", icon='ADD', emboss=False)
+            for i, filter in enumerate(sinfo.filter_log_function):
+                row = box.row()
+                row.active = sinfo.use_log_function_filter
+                row.prop(filter, "search_string", text="")
+                row.operator("info.log_function_filter_remove", text="", icon='X', emboss=False).index = i
 
             # col = layout.column(align=True)
             row = layout.row(align=True)
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h
index 2bb6f3d4b94..3442f2ee9b8 100644
--- a/source/blender/editors/space_info/info_intern.h
+++ b/source/blender/editors/space_info/info_intern.h
@@ -44,6 +44,12 @@ void FILE_OT_report_missing_files(struct wmOperatorType *ot);
 void FILE_OT_find_missing_files(struct wmOperatorType *ot);
 
 void INFO_OT_reports_display_update(struct wmOperatorType *ot);
+void INFO_OT_log_file_line_filter_add(struct wmOperatorType *ot);
+void INFO_OT_log_file_line_filter_remove(struct wmOperatorType *ot);
+void INFO_OT_log_function_filter_add(struct wmOperatorType *ot);
+void INFO_OT_log_function_filter_remove(struct wmOperatorType *ot);
+void INFO_OT_log_type_filter_add(struct wmOperatorType *ot);
+void INFO_OT_log_type_filter_remove(struct wmOperatorType *ot);
 
 /* info_draw.c */
 void *info_text_pick(const struct SpaceInfo *sinfo,
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 30f36509b41..615b4696ccb 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -21,6 +21,7 @@
  * \ingroup spinfo
  */
 
+#include <ED_screen.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -632,3 +633,181 @@ void INFO_OT_reports_display_update(wmOperatorType *ot)
 }
 
 /* report operators */
+
+/* log operators */
+static int log_file_line_filter_add_exec(bContext *C, wmOperator *op)
+{
+  SpaceInfo *sinfo = CTX_wm_space_info(C);
+  SpaceInfoFilter *filter = MEM_callocN(sizeof(*filter), __func__);
+  RNA_string_get(op->ptr, "filter", filter->search_string);
+  BLI_addtail(&sinfo->filter_log_file_line, filter);
+  return OPERATOR_FINISHED;
+}
+
+void INFO_OT_log_file_line_filter_add(wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Add Log File Line Filter";
+  ot->idname = "INFO_OT_log_file_line_filter_add";
+  ot->description = "Add filter";
+
+  /* api callbacks */
+  ot->exec = log_file_line_filter_add_exec;
+  ot->poll = ED_operator_info_active;
+
+  /* flags */
+  ot->flag = OPTYPE_INTERNAL;
+
+  /* properties */
+  RNA_def_string(ot->srna, "filter", NULL, 255, "Filter", "a");
+}
+
+static int log_file_line_filter_remove_exec(bContext *C, wmOperator *op)
+
+{
+  SpaceInfo *sinfo = CTX_wm_space_info(C);
+  const int index = RNA_int_get(op->ptr, "index");
+
+  SpaceInfoFilter *filter = BLI_findlink(&sinfo->filter_log_file_line, index);
+  BLI_freelinkN(&sinfo->filter_log_file_line, filter);
+  if (BLI_listbase_is_empty(&sinfo->filter_log_file_line)) {
+    BLI_listbase_clear(&sinfo->filter_log_file_line);
+  }
+  return OPERATOR_FINISHED;
+}
+
+void INFO_OT_log_file_line_filter_remove(wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Remove Log File Line Filter";
+  ot->idname = "INFO_OT_log_file_line_filter_remove";
+  ot->description = "Remove Filter";
+
+  /* api callbacks */
+  ot->exec = log_file_line_filter_remove_exec;
+  ot->poll = ED_operator_info_active;
+
+  /* flags */
+  ot->flag = OPTYPE_INTERNAL;
+
+  /* properties */
+  RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX);
+}
+
+static int log_function_filter_add_exec(bContext *C, wmOperator *op)
+{
+  SpaceInfo *sinfo = CTX_wm_space_info(C);
+  SpaceInfoFilter *filter = MEM_callocN(sizeof(*filter), __func__);
+  RNA_string_get(op->ptr, "filter", filter->search_string);
+  BLI_addtail(&sinfo->filter_log_function, filter);
+  return OPERATOR_FINISHED;
+}
+
+void INFO_OT_log_function_filter_add(wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Add Log Function Filter";
+  ot->idname = "INFO_OT_log_function_filter_add";
+  ot->description = "Add filter";
+
+  /* api callbacks */
+  ot->exec = log_function_filter_add_exec;
+  ot->poll = ED_operator_info_active;
+
+  /* flags */
+  ot->flag = OPTYPE_INTERNAL;
+
+  /* properties */
+  RNA_def_string(ot->srna, "filter", NULL, 255, "Filter", "a");
+}
+
+static int log_function_filter_remove_exec(bContext *C, wmOperator *op)
+
+{
+  SpaceInfo *sinfo = CTX_wm_space_info(C);
+  const int index = RNA_int_get(op->ptr, "index");
+
+  SpaceInfoFilter *filter = BLI_findlink(&sinfo->filter_log_function, index);
+  BLI_freelinkN(&sinfo->filter_log_function, filter);
+  if (BLI_listbase_is_empty(&sinfo->filter_log_function)) {
+    BLI_listbase_clear(&sinfo->filter_log_function);
+  }
+  return OPERATOR_FINISHED;
+}
+
+void INFO_OT_log_function_filter_remove(wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Remove Log Function Filter";
+  ot->idname = "INFO_OT_log_function_filter_remove";
+  ot->description = "Remove Filter";
+
+  /* api callbacks */
+  ot->exec = log_function_filter_remove_exec;
+  ot->poll = ED_operator_info_active;
+
+  /* flags */
+  ot->flag = OPTYPE_INTERNAL;
+
+  /* properties */
+  RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX);
+}
+
+static int log_type_filter_add_exec(bContext *C, wmOperator *op)
+{
+  SpaceInfo *sinfo = CTX_wm_space_info(C);
+  SpaceInfoFilter *filter = MEM_callocN(sizeof(*filter), __func__);
+  RNA_string_get(op->ptr, "filter", filter->search_string);
+  BLI_addtail(&sinfo->filter_log_type, filter);
+  return OPERATOR_FINISHED;
+}
+
+void INFO_OT_log_type_filter_add(wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Add Log Type Filter";
+  ot->idname = "INFO_OT_log_type_filter_add";
+  ot->description = "Add filter";
+
+  /* api callbacks */
+  ot->exec = log_type_filter_add_exec;
+  ot->poll = ED_operator_info_active;
+
+  /* flags */
+  ot->flag = OPTYPE_INTERNAL;
+
+  /* properties */
+  RNA_def_string(ot->srna, "filter", NULL, 255, "Filter", "a");
+}
+
+static int log_type_filter_remove_exec(bContext *C, wmOperator *op)
+
+{
+  SpaceInfo *sinfo = CTX_wm_space_info(C);
+  const int index = RNA_int_get(op->ptr, "index");
+
+  SpaceInfoFilter *filter = BLI_findlink(&sinfo->filter_log_type, index);
+  BLI_freelinkN(&sinfo->filter_log_type, filter);
+  if (BLI_listbase_is_empty(&sinfo->filter_log_type)) {
+    BLI_listbase_clear(&sinfo->filter_log_type);
+  }
+  return OPERATOR_FINISHED;
+}
+
+void INFO_OT_log_type_filter_remove(wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Remove Log type Filter";
+  ot->idname = "INFO_OT_log_type_filter_remove";
+  ot->description = "Remove Filter";
+
+  /* api callbacks */
+  ot->exec = log_type_filter_remove_exec;
+  ot->poll = ED_operator_info_active;
+
+  /* flags */
+  ot->flag = OPTYPE_INTERNAL;
+
+  /* properties */
+  RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX);
+}
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 9fe278c0967..3acb6f6d075 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -101,6 +101,9 @@ static void info_free(SpaceLink *sl)
     BKE_reports_clear(sinfo->active_reports);
     MEM_freeN(sinfo->active_reports);
   }
+  BLI_freelist(&sinfo->filter_log_file_line);
+  BLI_freelist(&sinfo->filter_log_type);
+  BLI_freelist(&sinfo->filter_log_function);
 }
 
 static void info_report_source_update(wmWindowManager *wm, SpaceInfo *sinfo)
@@ -144,9 +147,15 @@ static void info_init(struct wmWindowManager *wm, ScrArea *area)
 
 static SpaceLink *info_duplicate(SpaceLink *sl)
 {
+  SpaceInfo *sinfo = (SpaceInfo *)sl;
   SpaceInfo *sinfo_new = MEM_dupallocN(sl);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list