item.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 {
  9. Item_SubGhz,
  10. Item_RFID,
  11. Item_IR,
  12. Item_Playlist,
  13. Item_Group,
  14. Item_Settings
  15. } ItemType;
  16. typedef struct Item {
  17. ItemType type;
  18. FuriString* name;
  19. FuriString* path;
  20. char ext[MAX_EXT_LEN + 1];
  21. } Item;
  22. ARRAY_DEF(ItemArray, Item, M_POD_OPLIST);
  23. typedef struct ItemsView {
  24. FuriString* name;
  25. FuriString* path;
  26. ItemArray_t items;
  27. } ItemsView;
  28. /** Allocates and returns an ItemsView* which contains the list of
  29. * items to display for the given path. Contains everything needed
  30. * to render a scene_items.
  31. *
  32. * @param context App*
  33. * @param path FuriString*
  34. * @return ItemsView*
  35. */
  36. ItemsView* item_get_items_view_from_path(void* context, FuriString* path);
  37. /** Free ItemsView
  38. * @param items_view
  39. */
  40. void item_items_view_free(ItemsView* items_view);
  41. /** Prettify the name by removing a leading XX_, only if both X are digits,
  42. * as well as replace all '_' with ' '.
  43. * @param name FuriString*
  44. */
  45. void item_prettify_name(FuriString* name);