A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23#include <string.h>
24#include "config.h"
25#include "lang.h"
26#include "menu.h"
27#include "action.h"
28#include "settings.h"
29#include "rbpaths.h"
30#include "root_menu.h"
31#include "tree.h"
32
33enum {
34 GAMES,
35 APPS,
36 DEMOS,
37};
38
39static const struct {
40 const char *path;
41 int id;
42} items[] = {
43 { PLUGIN_GAMES_DIR, LANG_PLUGIN_GAMES },
44 { PLUGIN_APPS_DIR, LANG_PLUGIN_APPS },
45 { PLUGIN_DEMOS_DIR, LANG_PLUGIN_DEMOS },
46};
47
48/* if handler is active we are waiting to reenter menu */
49static void pm_handler(unsigned short id, void *data)
50{
51 remove_event(id, data);
52}
53
54static int plugins_menu(void* param)
55{
56 intptr_t item = (intptr_t)param;
57 int ret;
58
59 struct browse_context browse = {
60 .dirfilter = SHOW_PLUGINS,
61 .title = str(items[item].id),
62 .icon = Icon_Plugin,
63 .root = items[item].path,
64 };
65
66 ret = rockbox_browse(&browse);
67
68 if (ret == GO_TO_PREVIOUS)
69 return 0;
70 if (ret == GO_TO_PLUGIN)
71 add_event(SYS_EVENT_USB_INSERTED, pm_handler);
72
73 return ret;
74}
75
76static int menu_callback(int action,
77 const struct menu_item_ex *this_item,
78 struct gui_synclist *this_list)
79{
80 (void)this_item;
81 static int selected = 0;
82
83 if (action == ACTION_ENTER_MENUITEM)
84 {
85 this_list->selected_item = selected;
86 if (!add_event(SYS_EVENT_USB_INSERTED, pm_handler))
87 {
88 action = ACTION_STD_OK; /* event exists -- reenter menu */
89 }
90 remove_event(SYS_EVENT_USB_INSERTED, pm_handler);
91 }
92 else if (action == ACTION_STD_OK)
93 {
94 selected = gui_synclist_get_sel_pos(this_list);
95 }
96 return action;
97}
98
99#define ITEM_FLAG (MENU_FUNC_CHECK_RETVAL)
100
101MENUITEM_FUNCTION_W_PARAM(games_item, ITEM_FLAG, ID2P(LANG_PLUGIN_GAMES),
102 plugins_menu, (void*)GAMES, NULL, Icon_Folder);
103MENUITEM_FUNCTION_W_PARAM(apps_item, ITEM_FLAG, ID2P(LANG_PLUGIN_APPS),
104 plugins_menu, (void*)APPS, NULL, Icon_Folder);
105MENUITEM_FUNCTION_W_PARAM(demos_item, ITEM_FLAG, ID2P(LANG_PLUGIN_DEMOS),
106 plugins_menu, (void*)DEMOS, NULL, Icon_Folder);
107
108
109MAKE_MENU(plugin_menu, ID2P(LANG_PLUGINS), &menu_callback,
110 Icon_Plugin,
111 &games_item, &apps_item, &demos_item);