From c00bc8cb3e2d2befe085de046516ebdeb3b1aca2 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 12 Apr 2023 14:14:53 -0700 Subject: [PATCH] Fix #102574: Don't Show "Rename" for Volume and & System lists For File Browser "System" and "Volumes" lists, the item names cannot be changed by users yet the tooltip says "Double click to rename". This PR just removes that text for these non-editable lists. --- .../editors/interface/interface_template_list.cc | 12 ++++++++++-- source/blender/makesrna/intern/rna_space.c | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/interface/interface_template_list.cc b/source/blender/editors/interface/interface_template_list.cc index 28ffee73ca3..3b17381e9ff 100644 --- a/source/blender/editors/interface/interface_template_list.cc +++ b/source/blender/editors/interface/interface_template_list.cc @@ -643,7 +643,12 @@ static void *uilist_item_use_dynamic_tooltip(PointerRNA *itemptr, const char *pr static char *uilist_item_tooltip_func(bContext * /*C*/, void *argN, const char *tip) { char *dyn_tooltip = static_cast(argN); - return BLI_sprintfN("%s - %s", tip, dyn_tooltip); + std::string tooltip_string = dyn_tooltip; + if (tip && tip[0]) { + tooltip_string += '\n'; + tooltip_string += tip; + } + return BLI_strdupn(tooltip_string.c_str(), tooltip_string.size()); } /** @@ -744,6 +749,9 @@ static void ui_template_list_layout_draw(const bContext *C, int i = 0; if (input_data->dataptr.data && input_data->prop) { + + const bool editable = (RNA_property_flag(input_data->prop) & PROP_EDITABLE); + /* create list items */ for (i = visual_info.start_idx; i < visual_info.end_idx; i++) { PointerRNA *itemptr = &items->item_vec[i].item; @@ -774,7 +782,7 @@ static void ui_template_list_layout_draw(const bContext *C, org_i, 0, 0, - TIP_("Double click to rename")); + editable ? TIP_("Double click to rename") : ""); if ((dyntip_data = uilist_item_use_dynamic_tooltip(itemptr, input_data->item_dyntip_propname))) { UI_but_func_tooltip_set(but, uilist_item_tooltip_func, dyntip_data, MEM_freeN); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index b4c1058969c..e3383861170 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -7152,7 +7152,7 @@ static void rna_def_space_filebrowser(BlenderRNA *brna) NULL, NULL, NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE); prop = RNA_def_int(srna, "bookmarks_active", @@ -7183,7 +7183,7 @@ static void rna_def_space_filebrowser(BlenderRNA *brna) NULL, NULL, NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE); prop = RNA_def_int(srna, "recent_folders_active", -- 2.30.2