2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-18 19:21:30 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-18 19:21:30 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
2009-01-06 14:42:54 +00:00
|
|
|
* Contributor(s): Andrea Weikert (c) 2008 Blender Foundation.
|
2008-12-18 19:21:30 +00:00
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_file/fsmenu.c
|
|
|
|
* \ingroup spfile
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-12-18 19:21:30 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2009-01-06 14:42:54 +00:00
|
|
|
#include <stdio.h>
|
2008-12-18 19:21:30 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2012-05-18 14:08:54 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-18 19:21:30 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
#include "BKE_appdir.h"
|
|
|
|
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
|
|
|
|
#include "ED_fileselect.h"
|
|
|
|
|
2009-01-06 14:42:54 +00:00
|
|
|
#ifdef WIN32
|
2012-04-15 07:54:07 +00:00
|
|
|
# include <windows.h> /* need to include windows.h so _WIN32_IE is defined */
|
|
|
|
# ifndef _WIN32_IE
|
|
|
|
# define _WIN32_IE 0x0400 /* minimal requirements for SHGetSpecialFolderPath on MINGW MSVC has this defined already */
|
|
|
|
# endif
|
|
|
|
# include <shlobj.h> /* for SHGetSpecialFolderPath, has to be done before BLI_winstuff
|
|
|
|
* because 'near' is disabled through BLI_windstuff */
|
|
|
|
# include "BLI_winstuff.h"
|
2009-01-06 14:42:54 +00:00
|
|
|
#endif
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2009-05-02 03:09:40 +00:00
|
|
|
#ifdef __APPLE__
|
2013-11-05 17:35:47 +00:00
|
|
|
#include <Carbon/Carbon.h>
|
2012-04-15 07:54:07 +00:00
|
|
|
#endif /* __APPLE__ */
|
2009-05-02 03:09:40 +00:00
|
|
|
|
2009-07-28 22:44:50 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
#include <mntent.h>
|
|
|
|
#endif
|
|
|
|
|
2008-12-18 19:21:30 +00:00
|
|
|
#include "fsmenu.h" /* include ourselves */
|
|
|
|
|
|
|
|
|
|
|
|
/* FSMENU HANDLING */
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
typedef struct FSMenu {
|
2009-03-12 19:36:59 +00:00
|
|
|
FSMenuEntry *fsmenu_system;
|
2012-10-21 14:47:16 +00:00
|
|
|
FSMenuEntry *fsmenu_system_bookmarks;
|
2009-03-12 19:36:59 +00:00
|
|
|
FSMenuEntry *fsmenu_bookmarks;
|
|
|
|
FSMenuEntry *fsmenu_recent;
|
|
|
|
} FSMenu;
|
|
|
|
|
|
|
|
static FSMenu *g_fsmenu = NULL;
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
FSMenu *ED_fsmenu_get(void)
|
2009-03-12 19:36:59 +00:00
|
|
|
{
|
|
|
|
if (!g_fsmenu) {
|
2012-05-12 11:01:29 +00:00
|
|
|
g_fsmenu = MEM_callocN(sizeof(struct FSMenu), "fsmenu");
|
2009-03-12 19:36:59 +00:00
|
|
|
}
|
|
|
|
return g_fsmenu;
|
|
|
|
}
|
2009-03-10 23:14:41 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
struct FSMenuEntry *ED_fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory category)
|
2009-03-10 23:14:41 +00:00
|
|
|
{
|
2012-09-17 04:29:43 +00:00
|
|
|
FSMenuEntry *fsm_head = NULL;
|
2009-03-10 23:14:41 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (category) {
|
2009-03-10 23:14:41 +00:00
|
|
|
case FS_CATEGORY_SYSTEM:
|
2012-09-17 04:29:43 +00:00
|
|
|
fsm_head = fsmenu->fsmenu_system;
|
2009-03-10 23:14:41 +00:00
|
|
|
break;
|
2012-10-21 14:47:16 +00:00
|
|
|
case FS_CATEGORY_SYSTEM_BOOKMARKS:
|
|
|
|
fsm_head = fsmenu->fsmenu_system_bookmarks;
|
|
|
|
break;
|
2009-03-10 23:14:41 +00:00
|
|
|
case FS_CATEGORY_BOOKMARKS:
|
2012-09-17 04:29:43 +00:00
|
|
|
fsm_head = fsmenu->fsmenu_bookmarks;
|
2009-03-10 23:14:41 +00:00
|
|
|
break;
|
|
|
|
case FS_CATEGORY_RECENT:
|
2012-09-17 04:29:43 +00:00
|
|
|
fsm_head = fsmenu->fsmenu_recent;
|
2009-03-10 23:14:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-17 04:29:43 +00:00
|
|
|
return fsm_head;
|
2009-03-10 23:14:41 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
void ED_fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category, FSMenuEntry *fsm_head)
|
2009-03-10 23:14:41 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (category) {
|
2009-03-10 23:14:41 +00:00
|
|
|
case FS_CATEGORY_SYSTEM:
|
2012-09-17 04:29:43 +00:00
|
|
|
fsmenu->fsmenu_system = fsm_head;
|
2009-03-10 23:14:41 +00:00
|
|
|
break;
|
2012-10-21 14:47:16 +00:00
|
|
|
case FS_CATEGORY_SYSTEM_BOOKMARKS:
|
|
|
|
fsmenu->fsmenu_system_bookmarks = fsm_head;
|
|
|
|
break;
|
2009-03-10 23:14:41 +00:00
|
|
|
case FS_CATEGORY_BOOKMARKS:
|
2012-09-17 04:29:43 +00:00
|
|
|
fsmenu->fsmenu_bookmarks = fsm_head;
|
2009-03-10 23:14:41 +00:00
|
|
|
break;
|
|
|
|
case FS_CATEGORY_RECENT:
|
2012-09-17 04:29:43 +00:00
|
|
|
fsmenu->fsmenu_recent = fsm_head;
|
2009-03-10 23:14:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
int ED_fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category)
|
2008-12-18 19:21:30 +00:00
|
|
|
{
|
2012-09-17 04:29:43 +00:00
|
|
|
FSMenuEntry *fsm_iter;
|
2012-05-12 11:01:29 +00:00
|
|
|
int count = 0;
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
for (fsm_iter = ED_fsmenu_get_category(fsmenu, category); fsm_iter; fsm_iter = fsm_iter->next) {
|
2008-12-18 19:21:30 +00:00
|
|
|
count++;
|
2012-09-17 04:29:43 +00:00
|
|
|
}
|
2008-12-18 19:21:30 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2009-03-10 23:14:41 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
FSMenuEntry *ED_fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index)
|
2008-12-18 19:21:30 +00:00
|
|
|
{
|
2012-09-17 04:29:43 +00:00
|
|
|
FSMenuEntry *fsm_iter;
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
for (fsm_iter = ED_fsmenu_get_category(fsmenu, category); fsm_iter && index; fsm_iter = fsm_iter->next) {
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fsm_iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *ED_fsmenu_entry_get_path(struct FSMenuEntry *fsentry)
|
|
|
|
{
|
|
|
|
return fsentry->path;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_fsmenu_entry_set_path(struct FSMenuEntry *fsentry, const char *path)
|
|
|
|
{
|
|
|
|
if ((!fsentry->path || !path || !STREQ(path, fsentry->path)) && (fsentry->path != path)) {
|
|
|
|
char tmp_name[FILE_MAXFILE];
|
|
|
|
|
|
|
|
MEM_SAFE_FREE(fsentry->path);
|
|
|
|
|
|
|
|
fsentry->path = (path && path[0]) ? BLI_strdup(path) : NULL;
|
|
|
|
|
|
|
|
BLI_make_file_string("/", tmp_name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
|
|
|
|
fsmenu_write_file(ED_fsmenu_get(), tmp_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fsmenu_entry_generate_name(struct FSMenuEntry *fsentry, char *name, size_t name_size)
|
|
|
|
{
|
|
|
|
char temp[FILE_MAX];
|
|
|
|
|
|
|
|
BLI_strncpy(temp, fsentry->path, FILE_MAX);
|
|
|
|
BLI_add_slash(temp);
|
|
|
|
BLI_getlastdir(temp, name, name_size);
|
|
|
|
BLI_del_slash(name);
|
|
|
|
if (!name[0]) {
|
|
|
|
name[0] = '/';
|
|
|
|
name[1] = '\0';
|
2012-09-17 04:29:43 +00:00
|
|
|
}
|
2015-02-11 00:09:45 +01:00
|
|
|
}
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
char *ED_fsmenu_entry_get_name(struct FSMenuEntry *fsentry)
|
|
|
|
{
|
|
|
|
if (fsentry->name[0]) {
|
|
|
|
return fsentry->name;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Here we abuse fsm_iter->name, keeping first char NULL. */
|
|
|
|
char *name = fsentry->name + 1;
|
|
|
|
size_t name_size = sizeof(fsentry->name) - 1;
|
|
|
|
|
|
|
|
fsmenu_entry_generate_name(fsentry, name, name_size);
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name)
|
|
|
|
{
|
|
|
|
if (!STREQ(name, fsentry->name)) {
|
|
|
|
char tmp_name[FILE_MAXFILE];
|
|
|
|
size_t tmp_name_size = sizeof(tmp_name);
|
|
|
|
|
|
|
|
fsmenu_entry_generate_name(fsentry, tmp_name, tmp_name_size);
|
|
|
|
if (!name[0] || STREQ(tmp_name, name)) {
|
|
|
|
/* reset name to default behavior. */
|
|
|
|
fsentry->name[0] = '\0';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_strncpy(fsentry->name, name, sizeof(fsentry->name));
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_make_file_string("/", tmp_name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
|
|
|
|
fsmenu_write_file(ED_fsmenu_get(), tmp_name);
|
|
|
|
}
|
2008-12-18 19:21:30 +00:00
|
|
|
}
|
2009-03-10 23:14:41 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int idx)
|
2008-12-18 19:21:30 +00:00
|
|
|
{
|
2012-09-17 04:29:43 +00:00
|
|
|
FSMenuEntry *fsm_iter;
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
for (fsm_iter = ED_fsmenu_get_category(fsmenu, category); fsm_iter && idx; fsm_iter = fsm_iter->next) {
|
2008-12-18 19:21:30 +00:00
|
|
|
idx--;
|
2012-09-17 04:29:43 +00:00
|
|
|
}
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2012-09-17 04:29:43 +00:00
|
|
|
return fsm_iter ? fsm_iter->save : 0;
|
2008-12-18 19:21:30 +00:00
|
|
|
}
|
2009-03-10 23:14:41 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, const char *name, FSMenuInsert flag)
|
2008-12-18 19:21:30 +00:00
|
|
|
{
|
2012-09-17 04:29:43 +00:00
|
|
|
FSMenuEntry *fsm_prev;
|
|
|
|
FSMenuEntry *fsm_iter;
|
|
|
|
FSMenuEntry *fsm_head;
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
fsm_head = ED_fsmenu_get_category(fsmenu, category);
|
2012-09-17 04:29:43 +00:00
|
|
|
fsm_prev = fsm_head; /* this is odd and not really correct? */
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2012-09-17 04:29:43 +00:00
|
|
|
for (fsm_iter = fsm_head; fsm_iter; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next) {
|
|
|
|
if (fsm_iter->path) {
|
|
|
|
const int cmp_ret = BLI_path_cmp(path, fsm_iter->path);
|
2011-04-06 06:03:48 +00:00
|
|
|
if (cmp_ret == 0) {
|
2012-09-17 20:16:34 +00:00
|
|
|
if (flag & FS_INSERT_FIRST) {
|
2012-09-17 04:29:43 +00:00
|
|
|
if (fsm_iter != fsm_head) {
|
|
|
|
fsm_prev->next = fsm_iter->next;
|
|
|
|
fsm_iter->next = fsm_head;
|
2015-02-11 00:09:45 +01:00
|
|
|
ED_fsmenu_set_category(fsmenu, category, fsm_iter);
|
2012-09-17 02:19:41 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-18 19:21:30 +00:00
|
|
|
return;
|
2011-04-06 06:03:48 +00:00
|
|
|
}
|
2012-09-17 02:01:09 +00:00
|
|
|
else if ((flag & FS_INSERT_SORTED) && cmp_ret < 0) {
|
2008-12-18 19:21:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-07-06 23:56:59 +00:00
|
|
|
/* if we're bookmarking this, file should come
|
|
|
|
* before the last separator, only automatically added
|
|
|
|
* current dir go after the last sep. */
|
2012-09-17 02:01:09 +00:00
|
|
|
if (flag & FS_INSERT_SAVE) {
|
2008-12-18 19:21:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2012-09-17 04:29:43 +00:00
|
|
|
fsm_iter = MEM_mallocN(sizeof(*fsm_iter), "fsme");
|
|
|
|
fsm_iter->path = BLI_strdup(path);
|
|
|
|
fsm_iter->save = (flag & FS_INSERT_SAVE) != 0;
|
2015-02-11 00:09:45 +01:00
|
|
|
if (name && name[0]) {
|
|
|
|
BLI_strncpy(fsm_iter->name, name, sizeof(fsm_iter->name));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fsm_iter->name[0] = '\0';
|
|
|
|
}
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2012-09-17 04:29:43 +00:00
|
|
|
if (fsm_prev) {
|
2012-09-17 21:29:30 +00:00
|
|
|
if (flag & FS_INSERT_FIRST) {
|
|
|
|
fsm_iter->next = fsm_head;
|
2015-02-11 00:09:45 +01:00
|
|
|
ED_fsmenu_set_category(fsmenu, category, fsm_iter);
|
2012-09-17 22:34:42 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-09-17 21:29:30 +00:00
|
|
|
fsm_iter->next = fsm_prev->next;
|
|
|
|
fsm_prev->next = fsm_iter;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-09-17 04:29:43 +00:00
|
|
|
fsm_iter->next = fsm_head;
|
2015-02-11 00:09:45 +01:00
|
|
|
ED_fsmenu_set_category(fsmenu, category, fsm_iter);
|
2008-12-18 19:21:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx)
|
2008-12-18 19:21:30 +00:00
|
|
|
{
|
2012-09-17 04:29:43 +00:00
|
|
|
FSMenuEntry *fsm_prev = NULL;
|
|
|
|
FSMenuEntry *fsm_iter;
|
|
|
|
FSMenuEntry *fsm_head;
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
fsm_head = ED_fsmenu_get_category(fsmenu, category);
|
2012-09-17 04:29:43 +00:00
|
|
|
|
|
|
|
for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next)
|
2008-12-18 19:21:30 +00:00
|
|
|
idx--;
|
|
|
|
|
2012-09-17 04:29:43 +00:00
|
|
|
if (fsm_iter) {
|
2008-12-18 19:21:30 +00:00
|
|
|
/* you should only be able to remove entries that were
|
2012-03-03 16:31:46 +00:00
|
|
|
* not added by default, like windows drives.
|
|
|
|
* also separators (where path == NULL) shouldn't be removed */
|
2012-09-17 04:29:43 +00:00
|
|
|
if (fsm_iter->save && fsm_iter->path) {
|
2008-12-18 19:21:30 +00:00
|
|
|
|
|
|
|
/* remove fsme from list */
|
2012-09-17 04:29:43 +00:00
|
|
|
if (fsm_prev) {
|
|
|
|
fsm_prev->next = fsm_iter->next;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-09-17 04:29:43 +00:00
|
|
|
fsm_head = fsm_iter->next;
|
2015-02-11 00:09:45 +01:00
|
|
|
ED_fsmenu_set_category(fsmenu, category, fsm_head);
|
2008-12-18 19:21:30 +00:00
|
|
|
}
|
|
|
|
/* free entry */
|
2012-09-17 04:29:43 +00:00
|
|
|
MEM_freeN(fsm_iter->path);
|
|
|
|
MEM_freeN(fsm_iter);
|
2008-12-18 19:21:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename)
|
2008-12-18 19:21:30 +00:00
|
|
|
{
|
2012-09-17 04:29:43 +00:00
|
|
|
FSMenuEntry *fsm_iter = NULL;
|
2015-02-11 00:09:45 +01:00
|
|
|
char fsm_name[FILE_MAX];
|
2012-09-17 21:29:30 +00:00
|
|
|
int nwritten = 0;
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2012-03-20 02:17:37 +00:00
|
|
|
FILE *fp = BLI_fopen(filename, "w");
|
2008-12-18 19:21:30 +00:00
|
|
|
if (!fp) return;
|
2015-02-11 00:09:45 +01:00
|
|
|
|
2009-03-12 19:36:59 +00:00
|
|
|
fprintf(fp, "[Bookmarks]\n");
|
2015-02-11 00:09:45 +01:00
|
|
|
for (fsm_iter = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsm_iter; fsm_iter = fsm_iter->next) {
|
2012-09-17 04:29:43 +00:00
|
|
|
if (fsm_iter->path && fsm_iter->save) {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_entry_generate_name(fsm_iter, fsm_name, sizeof(fsm_name));
|
|
|
|
if (fsm_iter->name[0] && !STREQ(fsm_iter->name, fsm_name)) {
|
|
|
|
fprintf(fp, "!%s\n", fsm_iter->name);
|
|
|
|
}
|
2012-09-17 04:29:43 +00:00
|
|
|
fprintf(fp, "%s\n", fsm_iter->path);
|
2009-03-12 19:36:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf(fp, "[Recent]\n");
|
2015-02-11 00:09:45 +01:00
|
|
|
for (fsm_iter = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsm_iter && (nwritten < FSMENU_RECENT_MAX); fsm_iter = fsm_iter->next, ++nwritten) {
|
2012-09-17 04:29:43 +00:00
|
|
|
if (fsm_iter->path && fsm_iter->save) {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_entry_generate_name(fsm_iter, fsm_name, sizeof(fsm_name));
|
|
|
|
if (fsm_iter->name[0] && !STREQ(fsm_iter->name, fsm_name)) {
|
|
|
|
fprintf(fp, "!%s\n", fsm_iter->name);
|
|
|
|
}
|
2012-09-17 04:29:43 +00:00
|
|
|
fprintf(fp, "%s\n", fsm_iter->path);
|
2008-12-18 19:21:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
|
2010-07-04 15:35:23 +00:00
|
|
|
{
|
2013-03-16 17:33:16 +00:00
|
|
|
char line[FILE_MAXDIR];
|
2015-02-11 00:09:45 +01:00
|
|
|
char name[FILE_MAXFILE];
|
2010-07-04 15:35:23 +00:00
|
|
|
FSMenuCategory category = FS_CATEGORY_BOOKMARKS;
|
|
|
|
FILE *fp;
|
|
|
|
|
2012-03-20 02:17:37 +00:00
|
|
|
fp = BLI_fopen(filename, "r");
|
2010-07-04 15:35:23 +00:00
|
|
|
if (!fp) return;
|
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
name[0] = '\0';
|
|
|
|
|
2013-03-16 17:33:16 +00:00
|
|
|
while (fgets(line, sizeof(line), fp) != NULL) { /* read a line */
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQLEN(line, "[Bookmarks]", 11)) {
|
2010-07-04 15:35:23 +00:00
|
|
|
category = FS_CATEGORY_BOOKMARKS;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQLEN(line, "[Recent]", 8)) {
|
2010-07-04 15:35:23 +00:00
|
|
|
category = FS_CATEGORY_RECENT;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2015-02-11 00:09:45 +01:00
|
|
|
else if (line[0] == '!') {
|
|
|
|
int len = strlen(line);
|
|
|
|
if (len > 0) {
|
|
|
|
if (line[len - 1] == '\n') {
|
|
|
|
line[len - 1] = '\0';
|
|
|
|
}
|
|
|
|
BLI_strncpy(name, line + 1, sizeof(name));
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else {
|
2010-07-04 15:35:23 +00:00
|
|
|
int len = strlen(line);
|
2012-05-11 17:41:38 +00:00
|
|
|
if (len > 0) {
|
|
|
|
if (line[len - 1] == '\n') {
|
|
|
|
line[len - 1] = '\0';
|
2010-07-04 15:35:23 +00:00
|
|
|
}
|
2012-05-11 17:41:38 +00:00
|
|
|
/* don't do this because it can be slow on network drives,
|
|
|
|
* having a bookmark from a drive thats ejected or so isn't
|
|
|
|
* all _that_ bad */
|
|
|
|
#if 0
|
|
|
|
if (BLI_exists(line))
|
|
|
|
#endif
|
|
|
|
{
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, category, line, name, FS_INSERT_SAVE);
|
2010-07-04 15:35:23 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-11 00:09:45 +01:00
|
|
|
/* always reset name. */
|
|
|
|
name[0] = '\0';
|
2010-07-04 15:35:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
2012-05-18 12:49:25 +00:00
|
|
|
void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
2013-03-16 17:33:16 +00:00
|
|
|
char line[FILE_MAXDIR];
|
2009-07-28 16:46:14 +00:00
|
|
|
#ifdef WIN32
|
2009-01-06 14:42:54 +00:00
|
|
|
/* Add the drive names to the listing */
|
|
|
|
{
|
|
|
|
__int64 tmp;
|
|
|
|
char tmps[4];
|
|
|
|
int i;
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
tmp = GetLogicalDrives();
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
for (i = 0; i < 26; i++) {
|
|
|
|
if ((tmp >> i) & 1) {
|
|
|
|
tmps[0] = 'A' + i;
|
|
|
|
tmps[1] = ':';
|
|
|
|
tmps[2] = '\\';
|
|
|
|
tmps[3] = 0;
|
2009-01-06 14:42:54 +00:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, NULL, FS_INSERT_SORTED);
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adding Desktop and My Documents */
|
2012-05-18 12:49:25 +00:00
|
|
|
if (read_bookmarks) {
|
|
|
|
SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0);
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2012-05-18 12:49:25 +00:00
|
|
|
SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0);
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2012-05-18 12:49:25 +00:00
|
|
|
}
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
2009-07-28 16:46:14 +00:00
|
|
|
#else
|
2009-05-02 03:09:40 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
{
|
2013-10-14 15:37:16 +00:00
|
|
|
#if (MAC_OS_X_VERSION_MIN_REQUIRED <= 1050)
|
2012-05-12 11:01:29 +00:00
|
|
|
OSErr err = noErr;
|
2009-05-02 03:09:40 +00:00
|
|
|
int i;
|
2011-02-26 15:28:56 +00:00
|
|
|
const char *home;
|
2009-05-02 03:09:40 +00:00
|
|
|
|
|
|
|
/* loop through all the OS X Volumes, and add them to the SYSTEM section */
|
2012-04-28 06:31:57 +00:00
|
|
|
for (i = 1; err != nsvErr; i++) {
|
2009-05-02 03:09:40 +00:00
|
|
|
FSRef dir;
|
2011-11-26 04:07:38 +00:00
|
|
|
unsigned char path[FILE_MAX];
|
2009-05-02 03:09:40 +00:00
|
|
|
|
|
|
|
err = FSGetVolumeInfo(kFSInvalidVolumeRefNum, i, NULL, kFSVolInfoNone, NULL, NULL, &dir);
|
|
|
|
if (err != noErr)
|
|
|
|
continue;
|
|
|
|
|
2011-11-26 04:07:38 +00:00
|
|
|
FSRefMakePath(&dir, path, FILE_MAX);
|
2015-01-26 16:03:11 +01:00
|
|
|
if (!STREQ((char *)path, "/home") && !STREQ((char *)path, "/net")) {
|
2012-03-06 18:40:15 +00:00
|
|
|
/* /net and /home are meaningless on OSX, home folders are stored in /Users */
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, NULL, FS_INSERT_SORTED);
|
2009-12-17 09:23:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* As 10.4 doesn't provide proper API to retrieve the favorite places,
|
2012-03-03 16:31:46 +00:00
|
|
|
* assume they are the standard ones
|
2014-11-23 15:54:29 +01:00
|
|
|
* TODO : replace hardcoded paths with proper BKE_appdir_folder_id calls */
|
2010-07-16 16:02:07 +00:00
|
|
|
home = getenv("HOME");
|
2012-05-18 12:49:25 +00:00
|
|
|
if (read_bookmarks && home) {
|
2013-03-16 17:33:16 +00:00
|
|
|
BLI_snprintf(line, sizeof(line), "%s/", home);
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2013-03-16 17:33:16 +00:00
|
|
|
BLI_snprintf(line, sizeof(line), "%s/Desktop/", home);
|
2009-12-17 09:23:47 +00:00
|
|
|
if (BLI_exists(line)) {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2009-12-17 09:23:47 +00:00
|
|
|
}
|
2013-03-16 17:33:16 +00:00
|
|
|
BLI_snprintf(line, sizeof(line), "%s/Documents/", home);
|
2009-12-17 09:23:47 +00:00
|
|
|
if (BLI_exists(line)) {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2009-12-17 09:23:47 +00:00
|
|
|
}
|
2013-03-16 17:33:16 +00:00
|
|
|
BLI_snprintf(line, sizeof(line), "%s/Pictures/", home);
|
2009-12-17 09:23:47 +00:00
|
|
|
if (BLI_exists(line)) {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2009-12-17 09:23:47 +00:00
|
|
|
}
|
2013-03-16 17:33:16 +00:00
|
|
|
BLI_snprintf(line, sizeof(line), "%s/Music/", home);
|
2009-12-17 09:23:47 +00:00
|
|
|
if (BLI_exists(line)) {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2009-12-17 09:23:47 +00:00
|
|
|
}
|
2013-03-16 17:33:16 +00:00
|
|
|
BLI_snprintf(line, sizeof(line), "%s/Movies/", home);
|
2009-12-17 09:23:47 +00:00
|
|
|
if (BLI_exists(line)) {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2009-12-17 09:23:47 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-14 15:37:16 +00:00
|
|
|
#else /* OSX 10.6+ */
|
|
|
|
/* Get mounted volumes better method OSX 10.6 and higher, see: */
|
2013-10-13 18:14:38 +00:00
|
|
|
/*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/
|
2013-10-13 18:51:21 +00:00
|
|
|
/* we get all volumes sorted including network and do not relay on user-defined finder visibility, less confusing */
|
2009-12-17 09:23:47 +00:00
|
|
|
|
2013-10-13 18:14:38 +00:00
|
|
|
CFURLRef cfURL = NULL;
|
|
|
|
CFURLEnumeratorResult result = kCFURLEnumeratorSuccess;
|
|
|
|
CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(NULL, kCFURLEnumeratorSkipInvisibles, NULL);
|
2009-12-17 09:23:47 +00:00
|
|
|
|
2013-10-13 18:14:38 +00:00
|
|
|
while (result != kCFURLEnumeratorEnd) {
|
|
|
|
unsigned char defPath[FILE_MAX];
|
2013-10-13 17:12:36 +00:00
|
|
|
|
2013-10-13 18:14:38 +00:00
|
|
|
result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL);
|
|
|
|
if (result != kCFURLEnumeratorSuccess)
|
|
|
|
continue;
|
2009-12-17 09:23:47 +00:00
|
|
|
|
2013-10-23 02:52:27 +00:00
|
|
|
CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX);
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)defPath, NULL, FS_INSERT_SORTED);
|
2013-10-23 02:52:27 +00:00
|
|
|
}
|
2009-12-17 09:23:47 +00:00
|
|
|
|
2013-10-13 18:14:38 +00:00
|
|
|
CFRelease(volEnum);
|
2009-12-17 09:23:47 +00:00
|
|
|
|
2009-12-18 16:35:41 +00:00
|
|
|
/* Finally get user favorite places */
|
2012-05-22 16:24:09 +00:00
|
|
|
if (read_bookmarks) {
|
2013-10-13 18:14:38 +00:00
|
|
|
UInt32 seed;
|
|
|
|
OSErr err = noErr;
|
|
|
|
CFArrayRef pathesArray;
|
|
|
|
LSSharedFileListRef list;
|
|
|
|
LSSharedFileListItemRef itemRef;
|
|
|
|
CFIndex i, pathesCount;
|
|
|
|
CFURLRef cfURL = NULL;
|
|
|
|
CFStringRef pathString = NULL;
|
2012-05-18 12:49:25 +00:00
|
|
|
list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL);
|
|
|
|
pathesArray = LSSharedFileListCopySnapshot(list, &seed);
|
|
|
|
pathesCount = CFArrayGetCount(pathesArray);
|
2009-12-17 09:23:47 +00:00
|
|
|
|
2012-05-18 12:49:25 +00:00
|
|
|
for (i = 0; i < pathesCount; i++) {
|
|
|
|
itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i);
|
|
|
|
|
|
|
|
err = LSSharedFileListItemResolve(itemRef,
|
2012-06-18 13:01:24 +00:00
|
|
|
kLSSharedFileListNoUserInteraction |
|
|
|
|
kLSSharedFileListDoNotMountVolumes,
|
|
|
|
&cfURL, NULL);
|
2012-05-18 12:49:25 +00:00
|
|
|
if (err != noErr)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle);
|
|
|
|
|
2014-06-04 10:54:21 +02:00
|
|
|
if (pathString == NULL || !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingASCII))
|
2012-05-18 12:49:25 +00:00
|
|
|
continue;
|
2014-10-07 23:44:58 +02:00
|
|
|
|
2014-10-09 17:11:47 +02:00
|
|
|
/* Exclude "all my files" as it makes no sense in blender fileselector */
|
|
|
|
/* Exclude "airdrop" if wlan not active as it would show "" ) */
|
2014-10-13 15:51:31 +02:00
|
|
|
if (!strstr(line, "myDocuments.cannedSearch") && (*line != '\0')) {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_LAST);
|
2014-10-09 17:11:47 +02:00
|
|
|
}
|
2012-05-18 12:49:25 +00:00
|
|
|
|
|
|
|
CFRelease(pathString);
|
|
|
|
CFRelease(cfURL);
|
|
|
|
}
|
2009-12-17 09:23:47 +00:00
|
|
|
|
2012-05-18 12:49:25 +00:00
|
|
|
CFRelease(pathesArray);
|
|
|
|
CFRelease(list);
|
2009-12-17 09:23:47 +00:00
|
|
|
}
|
2013-10-14 15:37:16 +00:00
|
|
|
#endif /* OSX 10.6+ */
|
2009-05-02 03:09:40 +00:00
|
|
|
}
|
2009-07-28 16:46:14 +00:00
|
|
|
#else
|
|
|
|
/* unix */
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
const char *home = getenv("HOME");
|
2009-07-28 16:46:14 +00:00
|
|
|
|
2012-05-18 12:49:25 +00:00
|
|
|
if (read_bookmarks && home) {
|
2013-03-16 17:33:16 +00:00
|
|
|
BLI_snprintf(line, sizeof(line), "%s/", home);
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2013-03-16 17:33:16 +00:00
|
|
|
BLI_snprintf(line, sizeof(line), "%s/Desktop/", home);
|
2010-07-04 15:52:32 +00:00
|
|
|
if (BLI_exists(line)) {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_SORTED);
|
2009-07-29 22:37:33 +00:00
|
|
|
}
|
2009-07-28 16:46:14 +00:00
|
|
|
}
|
2009-07-28 22:44:50 +00:00
|
|
|
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
int found = 0;
|
2009-07-29 21:35:03 +00:00
|
|
|
#ifdef __linux__
|
2009-07-28 22:44:50 +00:00
|
|
|
/* loop over mount points */
|
|
|
|
struct mntent *mnt;
|
2009-07-29 21:35:03 +00:00
|
|
|
int len;
|
2010-09-15 16:13:32 +00:00
|
|
|
FILE *fp;
|
2009-07-29 21:35:03 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
fp = setmntent(MOUNTED, "r");
|
2009-07-28 22:44:50 +00:00
|
|
|
if (fp == NULL) {
|
|
|
|
fprintf(stderr, "could not get a list of mounted filesystemts\n");
|
|
|
|
}
|
|
|
|
else {
|
2012-05-12 11:01:29 +00:00
|
|
|
while ((mnt = getmntent(fp))) {
|
2009-07-29 21:35:03 +00:00
|
|
|
/* not sure if this is right, but seems to give the relevant mnts */
|
2015-01-26 16:03:11 +01:00
|
|
|
if (!STREQLEN(mnt->mnt_fsname, "/dev", 4))
|
2009-07-28 22:44:50 +00:00
|
|
|
continue;
|
2009-07-29 21:35:03 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
len = strlen(mnt->mnt_dir);
|
|
|
|
if (len && mnt->mnt_dir[len - 1] != '/') {
|
2013-03-16 17:33:16 +00:00
|
|
|
BLI_snprintf(line, sizeof(line), "%s/", mnt->mnt_dir);
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, NULL, FS_INSERT_SORTED);
|
2012-09-17 02:01:09 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, NULL, FS_INSERT_SORTED);
|
2009-07-28 22:44:50 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
found = 1;
|
2009-07-28 22:44:50 +00:00
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
if (endmntent(fp) == 0) {
|
2009-07-28 22:44:50 +00:00
|
|
|
fprintf(stderr, "could not close the list of mounted filesystemts\n");
|
|
|
|
}
|
|
|
|
}
|
2009-07-29 21:35:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* fallback */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!found)
|
2015-02-11 00:09:45 +01:00
|
|
|
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", NULL, FS_INSERT_SORTED);
|
2009-07-28 22:44:50 +00:00
|
|
|
}
|
2009-07-28 16:46:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-05-02 03:09:40 +00:00
|
|
|
#endif
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
|
2010-07-04 15:35:23 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
static void fsmenu_free_category(struct FSMenu *fsmenu, FSMenuCategory category)
|
2008-12-18 19:21:30 +00:00
|
|
|
{
|
2015-02-11 00:09:45 +01:00
|
|
|
FSMenuEntry *fsm_iter = ED_fsmenu_get_category(fsmenu, category);
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2012-09-17 04:29:43 +00:00
|
|
|
while (fsm_iter) {
|
|
|
|
FSMenuEntry *fsm_next = fsm_iter->next;
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2012-09-17 04:29:43 +00:00
|
|
|
if (fsm_iter->path) {
|
|
|
|
MEM_freeN(fsm_iter->path);
|
|
|
|
}
|
|
|
|
MEM_freeN(fsm_iter);
|
2008-12-18 19:21:30 +00:00
|
|
|
|
2012-09-17 04:29:43 +00:00
|
|
|
fsm_iter = fsm_next;
|
2008-12-18 19:21:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-18 12:49:25 +00:00
|
|
|
void fsmenu_refresh_system_category(struct FSMenu *fsmenu)
|
|
|
|
{
|
|
|
|
fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM);
|
2015-02-11 00:09:45 +01:00
|
|
|
ED_fsmenu_set_category(fsmenu, FS_CATEGORY_SYSTEM, NULL);
|
2012-05-18 12:49:25 +00:00
|
|
|
|
2012-10-21 14:47:16 +00:00
|
|
|
fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS);
|
2015-02-11 00:09:45 +01:00
|
|
|
ED_fsmenu_set_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, NULL);
|
2012-10-21 14:47:16 +00:00
|
|
|
|
2012-05-18 12:49:25 +00:00
|
|
|
/* Add all entries to system category */
|
2014-04-01 11:34:00 +11:00
|
|
|
fsmenu_read_system(fsmenu, true);
|
2012-05-18 12:49:25 +00:00
|
|
|
}
|
|
|
|
|
2013-12-20 17:39:22 +01:00
|
|
|
void fsmenu_free(void)
|
2009-03-10 23:14:41 +00:00
|
|
|
{
|
2013-12-20 17:39:22 +01:00
|
|
|
if (g_fsmenu) {
|
|
|
|
fsmenu_free_category(g_fsmenu, FS_CATEGORY_SYSTEM);
|
|
|
|
fsmenu_free_category(g_fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS);
|
|
|
|
fsmenu_free_category(g_fsmenu, FS_CATEGORY_BOOKMARKS);
|
|
|
|
fsmenu_free_category(g_fsmenu, FS_CATEGORY_RECENT);
|
|
|
|
MEM_freeN(g_fsmenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_fsmenu = NULL;
|
2009-03-10 23:14:41 +00:00
|
|
|
}
|
2013-12-20 17:39:22 +01:00
|
|
|
|
2015-02-11 00:09:45 +01:00
|
|
|
int fsmenu_get_active_indices(struct FSMenu *fsmenu, enum FSMenuCategory category, const char *dir)
|
|
|
|
{
|
|
|
|
FSMenuEntry *fsm_iter = ED_fsmenu_get_category(fsmenu, category);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; fsm_iter; fsm_iter = fsm_iter->next, i++) {
|
|
|
|
if (BLI_path_cmp(dir, fsm_iter->path) == 0) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|