item.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include <m-array.h>
  3. #define MAX_EXT_LEN 6
  4. /** Defines an individual item action or item group. Each object contains
  5. * the relevant file and type information needed to both render correctly
  6. * on-screen as well as to perform that action.
  7. */
  8. typedef enum { Item_Action, Item_Group } ItemType;
  9. typedef struct Item {
  10. ItemType type;
  11. FuriString* name;
  12. FuriString* path;
  13. char ext[MAX_EXT_LEN + 1];
  14. } Item;
  15. ARRAY_DEF(ItemArray, Item, M_POD_OPLIST);
  16. typedef struct ItemsView {
  17. FuriString* name;
  18. FuriString* path;
  19. ItemArray_t items;
  20. } ItemsView;
  21. /** Allocates and returns an ItemsView* which contains the list of
  22. * items to display for the given path. Contains everything needed
  23. * to render a scene_items.
  24. *
  25. * @param context App*
  26. * @param path FuriString*
  27. * @return ItemsView*
  28. */
  29. ItemsView* item_get_items_view_from_path(void* context, FuriString* path);
  30. /** Free ItemsView
  31. * @param items_view
  32. */
  33. void item_items_view_free(ItemsView* items_view);
  34. /** Prettify the name by removing a leading XX_, only if both X are digits,
  35. * as well as replace all '_' with ' '.
  36. * @param name FuriString*
  37. */
  38. void item_prettify_name(FuriString* name);