2.5 filebrowser

* show only name of the last directory for the bookmark
* small fix of projectfile: header BLI_fileops.h was moved
Note: full path should appear in tool tip later, also for renaming bookmarks later on.
This commit is contained in:
2009-06-30 20:34:00 +00:00
parent 406b16e7d1
commit 60c2599a1a
4 changed files with 33 additions and 3 deletions

View File

@@ -652,7 +652,7 @@
>
</File>
<File
RelativePath="..\..\..\source\blender\blenlib\intern\BLI_fileops.h"
RelativePath="..\..\..\source\blender\blenlib\BLI_fileops.h"
>
</File>
<File

View File

@@ -50,6 +50,7 @@ void BLI_make_existing_file(char *name);
void BLI_split_dirfile(char *string, char *dir, char *file);
void BLI_split_dirfile_basic(const char *string, char *dir, char *file);
void BLI_join_dirfile(char *string, const char *dir, const char *file);
void BLI_getlastdir(const char* dir, char *last, int maxlen);
int BLI_testextensie(const char *str, const char *ext);
void BLI_uniquename(struct ListBase *list, void *vlink, char defname[], char delim, short name_offs, short len);
void BLI_newname(char * name, int add);

View File

@@ -736,6 +736,25 @@ void BLI_splitdirstring(char *di, char *fi)
}
}
void BLI_getlastdir(const char* dir, char *last, int maxlen)
{
char *s = dir;
char *lslash = NULL;
char *prevslash = NULL;
while (*s) {
if ((*s == '\\') || (*s == '/')) {
prevslash = lslash;
lslash = s;
}
s++;
}
if (prevslash) {
BLI_strncpy(last, prevslash+1, maxlen);
} else {
BLI_strncpy(last, dir, maxlen);
}
}
char *BLI_gethome(void) {
#if !defined(WIN32)
return getenv("HOME");

View File

@@ -69,9 +69,19 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat
uiBlockSetEmboss(block, UI_EMBOSSP);
uiBlockBeginAlign(block);
for (i=0; i< nentries;++i) {
char dir[FILE_MAX];
char temp[FILE_MAX];
uiLayout* layout = uiLayoutRow(pa->layout, UI_LAYOUT_ALIGN_LEFT);
char *fname = fsmenu_get_entry(fsmenu, category, i);
uiItemStringO(layout, fname, icon, "FILE_OT_select_bookmark", "dir", fname);
char *entry = fsmenu_get_entry(fsmenu, category, i);
/* create nice bookmark name, shows last directory in the full path currently */
BLI_strncpy(temp, entry, FILE_MAX);
BLI_add_slash(temp);
BLI_getlastdir(temp, dir, FILE_MAX);
BLI_del_slash(dir);
/* operator shows the short bookmark name, should eventually have tooltip */
uiItemStringO(layout, dir, icon, "FILE_OT_select_bookmark", "dir", entry);
if (allow_delete && fsmenu_can_save(fsmenu, category, i) )
uiItemIntO(layout, "", ICON_X, "FILE_OT_delete_bookmark", "index", i);
}