item.h 1.4 KB

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