|
Blender
V2.93
|
#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "MEM_guardedalloc.h"#include "BLI_blenlib.h"#include "BLI_ghash.h"#include "BLI_utildefines.h"#include "BLT_translation.h"#include "BKE_appdir.h"#include "ED_fileselect.h"#include "UI_interface_icons.h"#include "UI_resources.h"#include "WM_api.h"#include "WM_types.h"#include "fsmenu.h"Go to the source code of this file.
Classes | |
| struct | FSMenu |
Macros | |
| #define | FS_UDIR_PATH(dir, icon) |
Typedefs | |
| typedef struct FSMenu | FSMenu |
Functions | |
| FSMenu * | ED_fsmenu_get (void) |
| struct FSMenuEntry * | ED_fsmenu_get_category (struct FSMenu *fsmenu, FSMenuCategory category) |
| void | ED_fsmenu_set_category (struct FSMenu *fsmenu, FSMenuCategory category, FSMenuEntry *fsm_head) |
| int | ED_fsmenu_get_nentries (struct FSMenu *fsmenu, FSMenuCategory category) |
| FSMenuEntry * | ED_fsmenu_get_entry (struct FSMenu *fsmenu, FSMenuCategory category, int idx) |
| char * | ED_fsmenu_entry_get_path (struct FSMenuEntry *fsentry) |
| void | ED_fsmenu_entry_set_path (struct FSMenuEntry *fsentry, const char *path) |
| int | ED_fsmenu_entry_get_icon (struct FSMenuEntry *fsentry) |
| void | ED_fsmenu_entry_set_icon (struct FSMenuEntry *fsentry, const int icon) |
| static void | fsmenu_entry_generate_name (struct FSMenuEntry *fsentry, char *name, size_t name_size) |
| char * | ED_fsmenu_entry_get_name (struct FSMenuEntry *fsentry) |
| void | ED_fsmenu_entry_set_name (struct FSMenuEntry *fsentry, const char *name) |
| void | fsmenu_entry_refresh_valid (struct FSMenuEntry *fsentry) |
| short | fsmenu_can_save (struct FSMenu *fsmenu, FSMenuCategory category, int idx) |
| void | fsmenu_insert_entry (struct FSMenu *fsmenu, FSMenuCategory category, const char *path, const char *name, int icon, FSMenuInsert flag) |
| void | fsmenu_remove_entry (struct FSMenu *fsmenu, FSMenuCategory category, int idx) |
| void | fsmenu_write_file (struct FSMenu *fsmenu, const char *filename) |
| void | fsmenu_read_bookmarks (struct FSMenu *fsmenu, const char *filename) |
| void | fsmenu_read_system (struct FSMenu *fsmenu, int read_bookmarks) |
| static void | fsmenu_free_category (struct FSMenu *fsmenu, FSMenuCategory category) |
| void | fsmenu_refresh_system_category (struct FSMenu *fsmenu) |
| static void | fsmenu_free_ex (FSMenu **fsmenu) |
| void | fsmenu_free (void) |
| static void | fsmenu_copy_category (struct FSMenu *fsmenu_dst, struct FSMenu *fsmenu_src, const FSMenuCategory category) |
| static FSMenu * | fsmenu_copy (FSMenu *fsmenu) |
| int | fsmenu_get_active_indices (struct FSMenu *fsmenu, enum FSMenuCategory category, const char *dir) |
| static void | fsmenu_bookmark_validate_job_startjob (void *fsmenuv, short *stop, short *do_update, float *UNUSED(progress)) |
| static void | fsmenu_bookmark_validate_job_update (void *fsmenuv) |
| static void | fsmenu_bookmark_validate_job_end (void *fsmenuv) |
| static void | fsmenu_bookmark_validate_job_free (void *fsmenuv) |
| static void | fsmenu_bookmark_validate_job_start (wmWindowManager *wm) |
| static void | fsmenu_bookmark_validate_job_stop (wmWindowManager *wm) |
| void | fsmenu_refresh_bookmarks_status (wmWindowManager *wm, FSMenu *fsmenu) |
XDG User Directory Support (Unix) | |
Generic Unix, Use XDG when available, otherwise fallback to the home directory. | |
| static GHash * | fsmenu_xdg_user_dirs_parse (const char *home) |
| static void | fsmenu_xdg_user_dirs_free (GHash *xdg_map) |
| static void | fsmenu_xdg_insert_entry (GHash *xdg_map, struct FSMenu *fsmenu, const char *key, const char *default_path, int icon, const char *home) |
Variables | |
| static FSMenu * | g_fsmenu = NULL |
| #define FS_UDIR_PATH | ( | dir, | |
| icon | |||
| ) |
| int ED_fsmenu_entry_get_icon | ( | struct FSMenuEntry * | fsentry | ) |
Definition at line 280 of file fsmenu.c.
References FSMenuEntry::icon.
| char* ED_fsmenu_entry_get_name | ( | struct FSMenuEntry * | fsentry | ) |
Definition at line 307 of file fsmenu.c.
References fsmenu_entry_generate_name(), and FSMenuEntry::name.
| char* ED_fsmenu_entry_get_path | ( | struct FSMenuEntry * | fsentry | ) |
Definition at line 258 of file fsmenu.c.
References FSMenuEntry::path.
| void ED_fsmenu_entry_set_icon | ( | struct FSMenuEntry * | fsentry, |
| const int | icon | ||
| ) |
Definition at line 285 of file fsmenu.c.
References FSMenuEntry::icon.
Referenced by fsmenu_insert_entry().
| void ED_fsmenu_entry_set_name | ( | struct FSMenuEntry * | fsentry, |
| const char * | name | ||
| ) |
Definition at line 321 of file fsmenu.c.
References BKE_appdir_folder_id_create(), BLENDER_BOOKMARK_FILE, BLENDER_USER_CONFIG, BLI_join_dirfile(), BLI_strncpy(), ED_fsmenu_get(), FILE_MAXFILE, fsmenu_entry_generate_name(), fsmenu_write_file(), FSMenuEntry::name, NULL, and STREQ.
| void ED_fsmenu_entry_set_path | ( | struct FSMenuEntry * | fsentry, |
| const char * | path | ||
| ) |
Definition at line 263 of file fsmenu.c.
References BKE_appdir_folder_id_create(), BLENDER_BOOKMARK_FILE, BLENDER_USER_CONFIG, BLI_join_dirfile(), BLI_strdup(), ED_fsmenu_get(), FILE_MAXFILE, fsmenu_write_file(), MEM_SAFE_FREE, NULL, FSMenuEntry::path, and STREQ.
| FSMenu* ED_fsmenu_get | ( | void | ) |
Definition at line 78 of file fsmenu.c.
References g_fsmenu, and MEM_callocN.
Referenced by bookmark_add_exec(), bookmark_cleanup_exec(), bookmark_delete_exec(), bookmark_move_exec(), ED_file_read_bookmarks(), ED_fsmenu_entry_set_name(), ED_fsmenu_entry_set_path(), file_exec(), file_refresh(), file_refresh_exec(), filelist_geticon_ex(), fsmenu_bookmark_validate_job_update(), fsmenu_refresh_bookmarks_status(), and reset_recent_exec().
| struct FSMenuEntry* ED_fsmenu_get_category | ( | struct FSMenu * | fsmenu, |
| FSMenuCategory | category | ||
| ) |
Definition at line 86 of file fsmenu.c.
References FS_CATEGORY_BOOKMARKS, FS_CATEGORY_OTHER, FS_CATEGORY_RECENT, FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, FSMenu::fsmenu_bookmarks, FSMenu::fsmenu_other, FSMenu::fsmenu_recent, FSMenu::fsmenu_system, FSMenu::fsmenu_system_bookmarks, and NULL.
Referenced by bookmark_cleanup_exec(), bookmark_move_exec(), ED_fsmenu_get_entry(), ED_fsmenu_get_nentries(), filelist_geticon_ex(), fsmenu_bookmark_validate_job_startjob(), fsmenu_bookmark_validate_job_update(), fsmenu_can_save(), fsmenu_copy_category(), fsmenu_free_category(), fsmenu_get_active_indices(), fsmenu_insert_entry(), fsmenu_remove_entry(), and fsmenu_write_file().
| FSMenuEntry* ED_fsmenu_get_entry | ( | struct FSMenu * | fsmenu, |
| FSMenuCategory | category, | ||
| int | idx | ||
| ) |
Definition at line 246 of file fsmenu.c.
References ED_fsmenu_get_category(), and FSMenuEntry::next.
Referenced by reset_recent_exec().
| int ED_fsmenu_get_nentries | ( | struct FSMenu * | fsmenu, |
| FSMenuCategory | category | ||
| ) |
Definition at line 234 of file fsmenu.c.
References count, ED_fsmenu_get_category(), and FSMenuEntry::next.
Referenced by bookmark_delete_exec(), and bookmark_move_exec().
| void ED_fsmenu_set_category | ( | struct FSMenu * | fsmenu, |
| FSMenuCategory | category, | ||
| FSMenuEntry * | fsm_head | ||
| ) |
Definition at line 213 of file fsmenu.c.
References FS_CATEGORY_BOOKMARKS, FS_CATEGORY_OTHER, FS_CATEGORY_RECENT, FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, FSMenu::fsmenu_bookmarks, FSMenu::fsmenu_other, FSMenu::fsmenu_recent, FSMenu::fsmenu_system, and FSMenu::fsmenu_system_bookmarks.
Referenced by bookmark_move_exec(), fsmenu_copy_category(), fsmenu_insert_entry(), fsmenu_refresh_system_category(), and fsmenu_remove_entry().
|
static |
Definition at line 1178 of file fsmenu.c.
References fsmenu_bookmark_validate_job_update().
Referenced by fsmenu_bookmark_validate_job_start().
|
static |
Definition at line 1184 of file fsmenu.c.
References fsmenu_free_ex().
Referenced by fsmenu_bookmark_validate_job_start().
|
static |
Definition at line 1190 of file fsmenu.c.
References fsmenu_bookmark_validate_job_end(), fsmenu_bookmark_validate_job_free(), fsmenu_bookmark_validate_job_startjob(), fsmenu_bookmark_validate_job_update(), fsmenu_copy(), g_fsmenu, NC_SPACE, ND_SPACE_FILE_LIST, NULL, wmWindowManager::winactive, WM_JOB_TYPE_FSMENU_BOOKMARK_VALIDATE, WM_jobs_callbacks(), WM_jobs_customdata_set(), WM_jobs_get(), WM_jobs_start(), and WM_jobs_timer().
Referenced by fsmenu_refresh_bookmarks_status().
|
static |
Definition at line 1129 of file fsmenu.c.
References ARRAY_SIZE, ED_fsmenu_get_category(), FS_CATEGORY_BOOKMARKS, FS_CATEGORY_RECENT, FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, fsmenu_entry_refresh_valid(), and FSMenuEntry::next.
Referenced by fsmenu_bookmark_validate_job_start().
|
static |
Definition at line 1210 of file fsmenu.c.
References WM_JOB_TYPE_FSMENU_BOOKMARK_VALIDATE, and WM_jobs_kill_type().
Referenced by fsmenu_refresh_bookmarks_status().
|
static |
Definition at line 1156 of file fsmenu.c.
References ARRAY_SIZE, ED_fsmenu_get(), ED_fsmenu_get_category(), FS_CATEGORY_BOOKMARKS, FS_CATEGORY_RECENT, FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, FSMenuEntry::next, NULL, FSMenuEntry::path, STREQ, and FSMenuEntry::valid.
Referenced by fsmenu_bookmark_validate_job_end(), and fsmenu_bookmark_validate_job_start().
| short fsmenu_can_save | ( | struct FSMenu * | fsmenu, |
| enum FSMenuCategory | category, | ||
| int | idx | ||
| ) |
Return whether the entry was created by the user and can be saved and deleted
Definition at line 369 of file fsmenu.c.
References ED_fsmenu_get_category(), FSMenuEntry::next, and FSMenuEntry::save.
Definition at line 1098 of file fsmenu.c.
References FS_CATEGORY_BOOKMARKS, FS_CATEGORY_OTHER, FS_CATEGORY_RECENT, FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, fsmenu_copy_category(), and MEM_dupallocN.
Referenced by fsmenu_bookmark_validate_job_start().
|
static |
Definition at line 1073 of file fsmenu.c.
References ED_fsmenu_get_category(), ED_fsmenu_set_category(), MEM_dupallocN, FSMenuEntry::next, NULL, and FSMenuEntry::path.
Referenced by fsmenu_copy().
|
static |
Definition at line 290 of file fsmenu.c.
References BLI_path_name_at_index(), BLI_strncpy(), len, MIN2, FSMenuEntry::name, and FSMenuEntry::path.
Referenced by ED_fsmenu_entry_get_name(), ED_fsmenu_entry_set_name(), and fsmenu_write_file().
| void fsmenu_entry_refresh_valid | ( | struct FSMenuEntry * | fsentry | ) |
Refresh 'valid' status of given menu entry
Definition at line 344 of file fsmenu.c.
References BLI_is_dir(), NULL, FSMenuEntry::path, STRCASEEQLEN, and FSMenuEntry::valid.
Referenced by fsmenu_bookmark_validate_job_startjob(), and fsmenu_insert_entry().
| void fsmenu_free | ( | void | ) |
Free's all the memory associated with the fsmenu
Definition at line 1068 of file fsmenu.c.
References fsmenu_free_ex(), and g_fsmenu.
Referenced by ED_file_exit(), and ED_file_read_bookmarks().
|
static |
Definition at line 1026 of file fsmenu.c.
References ED_fsmenu_get_category(), MEM_freeN, FSMenuEntry::next, and FSMenuEntry::path.
Referenced by fsmenu_free_ex(), and fsmenu_refresh_system_category().
|
static |
Definition at line 1054 of file fsmenu.c.
References FS_CATEGORY_BOOKMARKS, FS_CATEGORY_OTHER, FS_CATEGORY_RECENT, FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, fsmenu_free_category(), MEM_freeN, and NULL.
Referenced by fsmenu_bookmark_validate_job_free(), and fsmenu_free().
| int fsmenu_get_active_indices | ( | struct FSMenu * | fsmenu, |
| enum FSMenuCategory | category, | ||
| const char * | dir | ||
| ) |
Get active index based on given directory.
Definition at line 1111 of file fsmenu.c.
References BLI_path_cmp, ED_fsmenu_get_category(), FSMenuEntry::next, and FSMenuEntry::path.
Referenced by file_refresh().
| void fsmenu_insert_entry | ( | struct FSMenu * | fsmenu, |
| enum FSMenuCategory | category, | ||
| const char * | path, | ||
| const char * | name, | ||
| int | icon, | ||
| const enum FSMenuInsert | flag | ||
| ) |
Inserts a new fsmenu entry with the given path. Duplicate entries are not added.
| flag | Options for inserting the entry. |
Definition at line 381 of file fsmenu.c.
References ARRAY_SIZE, BLI_assert, BLI_path_ncmp, BLI_strdup(), BLI_strdupn(), BLI_strncpy(), ED_fsmenu_entry_set_icon(), ED_fsmenu_get_category(), ED_fsmenu_set_category(), ELEM, FS_CATEGORY_BOOKMARKS, FS_CATEGORY_OTHER, FS_CATEGORY_RECENT, FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, FS_INSERT_FIRST, FS_INSERT_SAVE, FS_INSERT_SORTED, fsmenu_entry_refresh_valid(), FSMenuEntry::icon, MEM_mallocN, FSMenuEntry::name, FSMenuEntry::next, FSMenuEntry::path, FSMenuEntry::save, SEP, SEP_STR, and STREQ.
Referenced by bookmark_add_exec(), file_exec(), fsmenu_read_bookmarks(), fsmenu_read_system(), and fsmenu_xdg_insert_entry().
| void fsmenu_read_bookmarks | ( | struct FSMenu * | fsmenu, |
| const char * | filename | ||
| ) |
reads the 'bookmarks' from the specified file
Definition at line 569 of file fsmenu.c.
References BLI_exists(), BLI_fopen(), BLI_strncpy(), FILE_MAXDIR, FILE_MAXFILE, FS_CATEGORY_BOOKMARKS, FS_CATEGORY_RECENT, FS_INSERT_SAVE, fsmenu_insert_entry(), len, FSMenuEntry::name, NULL, and STRPREFIX.
Referenced by ED_file_read_bookmarks().
| void fsmenu_read_system | ( | struct FSMenu * | fsmenu, |
| int | read_bookmarks | ||
| ) |
adds system specific directories
Definition at line 641 of file fsmenu.c.
References ARRAY_SIZE, BLI_filelist_dir_contents(), BLI_filelist_free(), BLI_getenv(), BLI_join_dirfile(), BLI_snprintf(), BLI_strncpy_wchar_as_utf8(), BLI_strncpy_wchar_from_utf8(), dirname(), err, FILE_MAX, FILE_MAXDIR, FILE_MAXFILE, FS_CATEGORY_OTHER, FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, FS_INSERT_LAST, FS_INSERT_SORTED, FS_UDIR_PATH, fsmenu_insert_entry(), fsmenu_xdg_insert_entry(), fsmenu_xdg_user_dirs_free(), fsmenu_xdg_user_dirs_parse(), FSMenuEntry::icon, label, N_, FSMenuEntry::name, NULL, direntry::relname, result, seed, STRPREFIX, type, and UNUSED_VARS.
Referenced by ED_file_read_bookmarks(), and fsmenu_refresh_system_category().
| void fsmenu_refresh_bookmarks_status | ( | struct wmWindowManager * | wm, |
| struct FSMenu * | fsmenu | ||
| ) |
Refresh 'valid' status of all menu entries
Definition at line 1215 of file fsmenu.c.
References BLI_assert, ED_fsmenu_get(), fsmenu_bookmark_validate_job_start(), fsmenu_bookmark_validate_job_stop(), and UNUSED_VARS_NDEBUG.
Referenced by bookmark_cleanup_exec(), and file_refresh_exec().
| void fsmenu_refresh_system_category | ( | struct FSMenu * | fsmenu | ) |
Refresh system directory menu
Definition at line 1042 of file fsmenu.c.
References ED_fsmenu_set_category(), FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, fsmenu_free_category(), fsmenu_read_system(), and NULL.
Referenced by file_refresh_exec().
| void fsmenu_remove_entry | ( | struct FSMenu * | fsmenu, |
| enum FSMenuCategory | category, | ||
| int | idx | ||
| ) |
Removes the fsmenu entry at the given index.
Definition at line 499 of file fsmenu.c.
References ED_fsmenu_get_category(), ED_fsmenu_set_category(), MEM_freeN, FSMenuEntry::next, NULL, FSMenuEntry::path, and FSMenuEntry::save.
Referenced by bookmark_cleanup_exec(), bookmark_delete_exec(), and reset_recent_exec().
| void fsmenu_write_file | ( | struct FSMenu * | fsmenu, |
| const char * | filename | ||
| ) |
saves the 'bookmarks' to the specified file
Definition at line 532 of file fsmenu.c.
References BLI_fopen(), ED_fsmenu_get_category(), FILE_MAX, FS_CATEGORY_BOOKMARKS, FS_CATEGORY_RECENT, fsmenu_entry_generate_name(), FSMENU_RECENT_MAX, FSMenuEntry::name, FSMenuEntry::next, NULL, FSMenuEntry::path, FSMenuEntry::save, and STREQ.
Referenced by bookmark_add_exec(), bookmark_cleanup_exec(), bookmark_delete_exec(), bookmark_move_exec(), ED_fsmenu_entry_set_name(), ED_fsmenu_entry_set_path(), file_exec(), and reset_recent_exec().
|
static |
Add fsmenu entry for system folders on linux.
| key | Use user-dirs.dirs format "XDG_EXAMPLE_DIR" |
| default_path | Directory name to check in $HOME, also used for the menu entry name. |
Definition at line 194 of file fsmenu.c.
References BLI_ghash_lookup(), BLI_path_join(), FILE_MAXDIR, FS_CATEGORY_SYSTEM_BOOKMARKS, FS_INSERT_LAST, fsmenu_insert_entry(), FSMenuEntry::icon, N_, and NULL.
Referenced by fsmenu_read_system().
|
static |
Definition at line 179 of file fsmenu.c.
References BLI_ghash_free(), MEM_freeN, and NULL.
Referenced by fsmenu_read_system().
|
static |
Look for user-dirs.dirs, where localized or custom user folders are defined, and store their paths in a GHash.
Definition at line 120 of file fsmenu.c.
References BLI_fopen(), BLI_ghash_insert(), BLI_ghash_str_new_ex(), BLI_path_join(), BLI_str_rstrip(), BLI_strdup(), FILE_MAX, FILE_MAXDIR, l, NULL, SEP_STR, and STRPREFIX.
Referenced by fsmenu_read_system().
Definition at line 76 of file fsmenu.c.
Referenced by ED_fsmenu_get(), fsmenu_bookmark_validate_job_start(), and fsmenu_free().