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
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')
-rw-r--r--source/blender/editors/space_file/file_intern.h2
-rw-r--r--source/blender/editors/space_file/file_ops.c65
-rw-r--r--source/blender/editors/space_file/file_panels.c13
-rw-r--r--source/blender/editors/space_file/space_file.c4
4 files changed, 78 insertions, 6 deletions
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index 6ce30bb48cb..fd37bb75685 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -58,6 +58,8 @@ void FILE_OT_select(struct wmOperatorType *ot);
void FILE_OT_select_all_toggle(struct wmOperatorType *ot);
void FILE_OT_select_border(struct wmOperatorType *ot);
void FILE_OT_select_bookmark(struct wmOperatorType *ot);
+void FILE_OT_add_bookmark(struct wmOperatorType *ot);
+void FILE_OT_delete_bookmark(struct wmOperatorType *ot);
void FILE_OT_loadimages(struct wmOperatorType *ot);
void FILE_OT_exec(struct wmOperatorType *ot);
void FILE_OT_cancel(struct wmOperatorType *ot);
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);
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 815345f34c8..b370624d312 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -26,7 +26,7 @@ static void do_file_panel_events(bContext *C, void *arg, int event)
}
-static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, int icon)
+static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, int icon, int allow_delete)
{
uiBlock *block;
uiStyle *style= U.uistyles.first;
@@ -41,26 +41,29 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat
uiBlockSetEmboss(block, UI_EMBOSSP);
uiBlockBeginAlign(block);
for (i=0; i< nentries;++i) {
+ uiLayout* layout = uiLayoutRow(pa->layout, UI_LAYOUT_ALIGN_LEFT);
char *fname = fsmenu_get_entry(fsmenu, category, i);
- uiItemStringO(pa->layout, fname, icon, "FILE_OT_select_bookmark", "dir", fname);
+ uiItemStringO(layout, fname, icon, "FILE_OT_select_bookmark", "dir", fname);
+ if (allow_delete)
+ uiItemIntO(layout, "", ICON_X, "FILE_OT_delete_bookmark", "index", i);
}
uiBlockEndAlign(block);
}
static void file_panel_system(const bContext *C, Panel *pa)
{
- file_panel_category(C, pa, FS_CATEGORY_SYSTEM, ICON_DISK_DRIVE);
+ file_panel_category(C, pa, FS_CATEGORY_SYSTEM, ICON_DISK_DRIVE, 0);
}
static void file_panel_bookmarks(const bContext *C, Panel *pa)
{
- file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, ICON_BOOKMARKS);
+ file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, ICON_BOOKMARKS, 1);
}
static void file_panel_recent(const bContext *C, Panel *pa)
{
- file_panel_category(C, pa, FS_CATEGORY_RECENT, ICON_FILE_FOLDER);
+ file_panel_category(C, pa, FS_CATEGORY_RECENT, ICON_FILE_FOLDER, 0);
}
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 4ed92d3f5d9..3824c23cb48 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -292,6 +292,8 @@ void file_operatortypes(void)
WM_operatortype_append(FILE_OT_parent);
WM_operatortype_append(FILE_OT_refresh);
WM_operatortype_append(FILE_OT_bookmark_toggle);
+ WM_operatortype_append(FILE_OT_add_bookmark);
+ WM_operatortype_append(FILE_OT_delete_bookmark);
}
/* NOTE: do not add .blend file reading on this level */
@@ -304,7 +306,7 @@ void file_keymap(struct wmWindowManager *wm)
WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "FILE_OT_highlight", MOUSEMOVE, KM_ANY, 0, 0);
WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0);
-
+ WM_keymap_add_item(keymap, "FILE_OT_add_bookmark", BKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "FILE_OT_loadimages", TIMER1, KM_ANY, KM_ANY, 0);
keymap= WM_keymap_listbase(wm, "FileBookmark", SPACE_FILE, 0);