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-07-26 22:52:27 +0400
committerAndrea Weikert <elubie@gmx.net>2009-07-26 22:52:27 +0400
commitcbb9dfaab80ed52950a4ea4c1570370eddacfa64 (patch)
tree3df161c74b8d43634bfb032f2ada65d6496b3cad /source/blender/editors/space_file/file_draw.c
parent4741137fc9639a3902a0a7bbbebb7256841ac027 (diff)
2.5 file browser
* operator for create new directory activated (IKEY) * operator for rename (works on files and directories so far) (CTRL+LMB) Note: fail to rename is rather quiet, no message popup, just doesn't rename if it can't. So far checked that (On Windows Vista) rename fails on system directories, which I think acceptable. Note: I removed the code that (silently) deletes file if I rename file to an existing one. Considered harmful :)
Diffstat (limited to 'source/blender/editors/space_file/file_draw.c')
-rw-r--r--source/blender/editors/space_file/file_draw.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 780b99c3cae..f2906686db5 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -495,6 +495,25 @@ void file_draw_previews(const bContext *C, ARegion *ar)
uiSetRoundBox(0);
}
+static void renamebutton_cb(bContext *C, void *arg1, char *oldname)
+{
+ char newname[FILE_MAX+12];
+ char orgname[FILE_MAX+12];
+ char filename[FILE_MAX+12];
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+ struct direntry *file = (struct direntry *)arg1;
+
+ BLI_make_file_string(G.sce, orgname, sfile->params->dir, oldname);
+ BLI_strncpy(filename, file->relname, sizeof(filename));
+ BLI_make_file_string(G.sce, newname, sfile->params->dir, filename);
+
+ if( strcmp(orgname, newname) != 0 ) {
+ BLI_rename(orgname, newname);
+
+ /* to refresh the file list, does sorting again */
+ filelist_free(sfile->files);
+ }
+}
void file_draw_list(const bContext *C, ARegion *ar)
{
@@ -554,15 +573,17 @@ void file_draw_list(const bContext *C, ARegion *ar)
sy = v2d->tot.ymax - sy;
file = filelist_file(files, i);
-
- if (params->active_file == i) {
- if (file->flags & ACTIVE) colorid= TH_HILITE;
- else colorid = TH_BACK;
- draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,20);
- } else if (file->flags & ACTIVE) {
- colorid = TH_HILITE;
- draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,0);
- }
+
+ if (!(file->flags & EDITING)) {
+ if (params->active_file == i) {
+ if (file->flags & ACTIVE) colorid= TH_HILITE;
+ else colorid = TH_BACK;
+ draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,20);
+ } else if (file->flags & ACTIVE) {
+ colorid = TH_HILITE;
+ draw_tile(sx-2, sy-3, layout->tile_w+2, sfile->layout->tile_h+layout->tile_border_y, colorid,0);
+ }
+ }
spos = sx;
file_draw_icon(spos, sy-3, get_file_icon(file), ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH);
@@ -571,7 +592,19 @@ void file_draw_list(const bContext *C, ARegion *ar)
UI_ThemeColor4(TH_TEXT);
sw = file_string_width(file->relname);
- file_draw_string(spos, sy, file->relname, sw, layout->tile_h, FILE_SHORTEN_END);
+ if (file->flags & EDITING) {
+ uiBlock *block = uiBeginBlock(C, ar, "FileName", UI_EMBOSS);
+ uiBut *but = uiDefBut(block, TEX, 1, "", spos, sy-layout->tile_h-3,
+ layout->column_widths[COLUMN_NAME], layout->tile_h, file->relname, 1.0f, (float)FILE_MAX,0,0,"");
+ uiButSetRenameFunc(but, renamebutton_cb, file);
+ if ( 0 == uiButActiveOnly(C, block, but)) {
+ file->flags &= ~EDITING;
+ }
+ uiEndBlock(C, block);
+ uiDrawBlock(C, block);
+ } else {
+ file_draw_string(spos, sy, file->relname, sw, layout->tile_h, FILE_SHORTEN_END);
+ }
spos += layout->column_widths[COLUMN_NAME] + 12;
if (params->display == FILE_SHOWSHORT) {
if (!(file->type & S_IFDIR)) {