Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Weikert <elubie@gmx.net>2009-06-30 02:16:48 +0400
committerAndrea Weikert <elubie@gmx.net>2009-06-30 02:16:48 +0400
commit17d5bfd9709583cb58c030ecea3f7d3fb44a81ad (patch)
tree85b689a0f000f0bdabbbe856154745084488a91a /source/blender/editors/space_file/file_ops.c
parent84cd5a6cfbd607e73f8b2f522983520b18b1b63b (diff)
2.5 file browser
* bookmark operators: add and delete bookmark * first start at menus in file browser: Directory and Bookmarks * Adding a bookmark via menu or via CTRL+B * Remove a bookmark with the X button next to it.
Diffstat (limited to 'source/blender/editors/space_file/file_ops.c')
-rw-r--r--source/blender/editors/space_file/file_ops.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index ebece6dd5e6..dd20c8e8224 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -336,6 +336,71 @@ void FILE_OT_select_bookmark(wmOperatorType *ot)
RNA_def_string(ot->srna, "dir", "", 256, "Dir", "");
}
+static int bookmark_add_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ScrArea *sa= CTX_wm_area(C);
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+ struct FSMenu* fsmenu = fsmenu_get();
+ struct FileSelectParams* params= ED_fileselect_get_params(sfile);
+
+ if (params->dir[0] != '\0') {
+ char name[FILE_MAX];
+
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, 0, 1);
+ BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
+ fsmenu_write_file(fsmenu, name);
+ }
+
+ ED_area_tag_redraw(sa);
+ return OPERATOR_FINISHED;
+}
+
+void FILE_OT_add_bookmark(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Add Bookmark";
+ ot->idname= "FILE_OT_add_bookmark";
+
+ /* api callbacks */
+ ot->invoke= bookmark_add_invoke;
+ ot->poll= ED_operator_file_active;
+}
+
+static int bookmark_delete_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ScrArea *sa= CTX_wm_area(C);
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(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");
+ if ( (index >-1) && (index < nentries)) {
+ char name[FILE_MAX];
+
+ fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index);
+ BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
+ fsmenu_write_file(fsmenu, name);
+ ED_area_tag_redraw(sa);
+ }
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void FILE_OT_delete_bookmark(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Delete Bookmark";
+ ot->idname= "FILE_OT_delete_bookmark";
+
+ /* api callbacks */
+ ot->invoke= bookmark_delete_invoke;
+ ot->poll= ED_operator_file_active;
+
+ RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000);
+}
+
+
static int loadimages_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ScrArea *sa= CTX_wm_area(C);