unleashed-firmware/applications/main/archive/helpers/archive_menu.h

50 lines
1.4 KiB
C
Raw Normal View History

#pragma once
2022-10-06 00:55:26 +03:00
#include <furi.h>
#include <m-array.h>
typedef struct {
2022-10-05 21:27:13 +03:00
FuriString* text;
uint32_t event;
} ArchiveContextMenuItem_t;
static void ArchiveContextMenuItem_t_init(ArchiveContextMenuItem_t* obj) {
2022-10-05 21:27:13 +03:00
obj->text = furi_string_alloc();
obj->event = 0; // ArchiveBrowserEventFileMenuNone
}
static void ArchiveContextMenuItem_t_init_set(
ArchiveContextMenuItem_t* obj,
const ArchiveContextMenuItem_t* src) {
2022-10-05 21:27:13 +03:00
obj->text = furi_string_alloc_set(src->text);
obj->event = src->event;
}
static void ArchiveContextMenuItem_t_set(
ArchiveContextMenuItem_t* obj,
const ArchiveContextMenuItem_t* src) {
2022-10-06 00:55:26 +03:00
furi_string_set(obj->text, src->text);
obj->event = src->event;
}
static void ArchiveContextMenuItem_t_clear(ArchiveContextMenuItem_t* obj) {
2022-10-05 21:27:13 +03:00
furi_string_free(obj->text);
}
ARRAY_DEF(
menu_array,
ArchiveContextMenuItem_t,
(INIT(API_2(ArchiveContextMenuItem_t_init)),
SET(API_6(ArchiveContextMenuItem_t_set)),
INIT_SET(API_6(ArchiveContextMenuItem_t_init_set)),
CLEAR(API_2(ArchiveContextMenuItem_t_clear))))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
// Using in applications/archive/views/archive_browser_view.c
2022-10-05 21:27:13 +03:00
static void
2023-07-16 20:28:15 +03:00
archive_menu_add_item(ArchiveContextMenuItem_t* obj, const char* text, uint32_t event) {
2022-10-06 00:55:26 +03:00
obj->text = furi_string_alloc_set(text);
obj->event = event;
}
#pragma GCC diagnostic pop