[Bf-blender-cvs] [4b1f410] asset-experiments: Add buttons to add/remove bookmarks, and to reset recent list.
Bastien Montagne
noreply at git.blender.org
Tue Dec 23 12:30:12 CET 2014
Commit: 4b1f4100128618a94e8db37414c89db31550c8a0
Author: Bastien Montagne
Date: Mon Dec 22 15:20:33 2014 +0100
Branches: asset-experiments
https://developer.blender.org/rB4b1f4100128618a94e8db37414c89db31550c8a0
Add buttons to add/remove bookmarks, and to reset recent list.
===================================================================
M release/scripts/startup/bl_ui/space_filebrowser.py
M source/blender/editors/space_file/file_ops.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 739e7d1..b029505 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -107,17 +107,10 @@ class FILEBROWSER_UL_dir(bpy.types.UIList):
if active_propname == "recent_folders_active":
icon = 'FILE_FOLDER'
- #~ if (space.params.directory == direntry.path):
- #~ setattr(active_data, active_propname, index)
-
if self.layout_type in {'DEFAULT', 'COMPACT'}:
row = layout.row(align=True)
-
row.prop(direntry, "name", text="", emboss=False, icon=icon)
- if direntry.use_save:
- row.label("CaN DeLeTe")
-
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.prop(direntry, "path", text="")
@@ -130,12 +123,12 @@ class FILEBROWSER_PT_system_folders(Panel):
def draw(self, context):
layout = self.layout
-
space = context.space_data
if space.system_folders:
- #~ print(space.system_folders_active)
- layout.template_list("FILEBROWSER_UL_dir", "system_folders", space, "system_folders", space, "system_folders_active", rows=1, maxrows=6)
+ row = layout.row()
+ row.template_list("FILEBROWSER_UL_dir", "system_folders", space, "system_folders",
+ space, "system_folders_active", rows=1, maxrows=6)
class FILEBROWSER_PT_system_bookmarks(Panel):
@@ -149,12 +142,12 @@ class FILEBROWSER_PT_system_bookmarks(Panel):
def draw(self, context):
layout = self.layout
-
space = context.space_data
if space.system_bookmarks:
- #~ print(space.system_folders_active)
- layout.template_list("FILEBROWSER_UL_dir", "system_bookmarks", space, "system_bookmarks", space, "system_bookmarks_active", rows=1, maxrows=6)
+ row = layout.row()
+ row.template_list("FILEBROWSER_UL_dir", "system_bookmarks", space, "system_bookmarks",
+ space, "system_bookmarks_active", rows=1, maxrows=6)
class FILEBROWSER_PT_bookmarks(Panel):
@@ -164,12 +157,16 @@ class FILEBROWSER_PT_bookmarks(Panel):
def draw(self, context):
layout = self.layout
-
space = context.space_data
if space.bookmarks:
- #~ print(space.system_folders_active)
- layout.template_list("FILEBROWSER_UL_dir", "bookmarks", space, "bookmarks", space, "bookmarks_active", rows=1, maxrows=6)
+ row = layout.row()
+ row.template_list("FILEBROWSER_UL_dir", "bookmarks", space, "bookmarks",
+ space, "bookmarks_active", rows=1, maxrows=6)
+
+ col = row.column(align=True)
+ col.operator("file.bookmark_add", icon='ZOOMIN', text="")
+ col.operator("file.bookmark_delete", icon='ZOOMOUT', text="")
class FILEBROWSER_PT_recent_folders(Panel):
@@ -183,12 +180,15 @@ class FILEBROWSER_PT_recent_folders(Panel):
def draw(self, context):
layout = self.layout
-
space = context.space_data
if space.recent_folders:
- #~ print(space.system_folders_active)
- layout.template_list("FILEBROWSER_UL_dir", "recent_folders", space, "recent_folders", space, "recent_folders_active", rows=1, maxrows=6)
+ row = layout.row()
+ row.template_list("FILEBROWSER_UL_dir", "recent_folders", space, "recent_folders",
+ space, "recent_folders_active", rows=1, maxrows=6)
+
+ col = row.column(align=True)
+ col.operator("file.reset_recent", icon='X', text="")
if __name__ == "__main__": # only for live edit.
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 65c341d..a8ccb3f 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -504,11 +504,20 @@ void FILE_OT_bookmark_add(wmOperatorType *ot)
static int bookmark_delete_exec(bContext *C, wmOperator *op)
{
ScrArea *sa = CTX_wm_area(C);
+ SpaceFile *sfile = CTX_wm_space_file(C);
struct FSMenu *fsmenu = fsmenu_get();
int nentries = fsmenu_get_nentries(fsmenu, FS_CATEGORY_BOOKMARKS);
-
- if (RNA_struct_find_property(op->ptr, "index")) {
- int index = RNA_int_get(op->ptr, "index");
+
+ PropertyRNA *prop = RNA_struct_find_property(op->ptr, "index");
+
+ if (prop) {
+ int index;
+ if (RNA_property_is_set(op->ptr, prop)) {
+ index = RNA_int_get(op->ptr, "index");
+ }
+ else { /* if index unset, use active bookmark... */
+ index = sfile->bookmarknr;
+ }
if ((index > -1) && (index < nentries)) {
char name[FILE_MAX];
@@ -552,7 +561,7 @@ static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op))
BLI_make_file_string("/", name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
fsmenu_write_file(fsmenu, name);
ED_area_tag_redraw(sa);
-
+
return OPERATOR_FINISHED;
}
More information about the Bf-blender-cvs
mailing list