mirror of
https://github.com/mpv-player/mpv
synced 2024-12-18 12:55:16 +00:00
command: add a property that returns a list of all properties
Also remove the undocumented Lua mp.property_list() function.
This commit is contained in:
parent
16e5ec88e1
commit
be337aa415
@ -1258,6 +1258,8 @@ Property list
|
|||||||
require reloading the file for changes to take effect. If there is an
|
require reloading the file for changes to take effect. If there is an
|
||||||
equivalent property, prefer setting the property instead.
|
equivalent property, prefer setting the property instead.
|
||||||
|
|
||||||
|
``property-list``
|
||||||
|
Return the list of top-level properties.
|
||||||
|
|
||||||
Property Expansion
|
Property Expansion
|
||||||
------------------
|
------------------
|
||||||
|
@ -2623,6 +2623,30 @@ static int mp_property_options(void *ctx, struct m_property *prop,
|
|||||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct m_property mp_properties[];
|
||||||
|
|
||||||
|
static int mp_property_list(void *ctx, struct m_property *prop,
|
||||||
|
int action, void *arg)
|
||||||
|
{
|
||||||
|
switch (action) {
|
||||||
|
case M_PROPERTY_GET_TYPE:
|
||||||
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
||||||
|
return M_PROPERTY_OK;
|
||||||
|
case M_PROPERTY_GET: {
|
||||||
|
char **list = NULL;
|
||||||
|
int num = 0;
|
||||||
|
for (int n = 0; mp_properties[n].name; n++) {
|
||||||
|
MP_TARRAY_APPEND(NULL, list, num,
|
||||||
|
talloc_strdup(NULL, mp_properties[n].name));
|
||||||
|
}
|
||||||
|
MP_TARRAY_APPEND(NULL, list, num, NULL);
|
||||||
|
*(char ***)arg = list;
|
||||||
|
return M_PROPERTY_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
// Redirect a property name to another
|
// Redirect a property name to another
|
||||||
#define M_PROPERTY_ALIAS(name, real_property) \
|
#define M_PROPERTY_ALIAS(name, real_property) \
|
||||||
{(name), mp_property_alias, .priv = (real_property)}
|
{(name), mp_property_alias, .priv = (real_property)}
|
||||||
@ -2780,6 +2804,7 @@ static const struct m_property mp_properties[] = {
|
|||||||
M_PROPERTY_ALIAS("sub", "sid"),
|
M_PROPERTY_ALIAS("sub", "sid"),
|
||||||
|
|
||||||
{"options", mp_property_options},
|
{"options", mp_property_options},
|
||||||
|
{"property-list", mp_property_list},
|
||||||
|
|
||||||
{0},
|
{0},
|
||||||
};
|
};
|
||||||
@ -2809,11 +2834,6 @@ static const char *const *const mp_event_property_change[] = {
|
|||||||
};
|
};
|
||||||
#undef E
|
#undef E
|
||||||
|
|
||||||
const struct m_property *mp_get_property_list(void)
|
|
||||||
{
|
|
||||||
return mp_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool is_property_set(int action, void *val)
|
static bool is_property_set(int action, void *val)
|
||||||
{
|
{
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
@ -33,9 +33,6 @@ void property_print_help(struct mp_log *log);
|
|||||||
int mp_property_do(const char* name, int action, void* val,
|
int mp_property_do(const char* name, int action, void* val,
|
||||||
struct MPContext *mpctx);
|
struct MPContext *mpctx);
|
||||||
|
|
||||||
const struct m_property *mp_get_property_list(void);
|
|
||||||
int mp_find_property_index(const char *property);
|
|
||||||
|
|
||||||
void mp_notify(struct MPContext *mpctx, int event, void *arg);
|
void mp_notify(struct MPContext *mpctx, int event, void *arg);
|
||||||
void mp_notify_property(struct MPContext *mpctx, const char *property);
|
void mp_notify_property(struct MPContext *mpctx, const char *property);
|
||||||
|
|
||||||
|
13
player/lua.c
13
player/lua.c
@ -699,18 +699,6 @@ static int script_set_property_native(lua_State *L)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int script_property_list(lua_State *L)
|
|
||||||
{
|
|
||||||
const struct m_property *props = mp_get_property_list();
|
|
||||||
lua_newtable(L);
|
|
||||||
for (int i = 0; props[i].name; i++) {
|
|
||||||
lua_pushinteger(L, i + 1);
|
|
||||||
lua_pushstring(L, props[i].name);
|
|
||||||
lua_settable(L, -3);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int script_get_property(lua_State *L)
|
static int script_get_property(lua_State *L)
|
||||||
{
|
{
|
||||||
struct script_ctx *ctx = get_ctx(L);
|
struct script_ctx *ctx = get_ctx(L);
|
||||||
@ -1099,7 +1087,6 @@ static const struct fn_entry main_fns[] = {
|
|||||||
FN_ENTRY(set_property_native),
|
FN_ENTRY(set_property_native),
|
||||||
FN_ENTRY(raw_observe_property),
|
FN_ENTRY(raw_observe_property),
|
||||||
FN_ENTRY(raw_unobserve_property),
|
FN_ENTRY(raw_unobserve_property),
|
||||||
FN_ENTRY(property_list),
|
|
||||||
FN_ENTRY(set_osd_ass),
|
FN_ENTRY(set_osd_ass),
|
||||||
FN_ENTRY(get_osd_resolution),
|
FN_ENTRY(get_osd_resolution),
|
||||||
FN_ENTRY(get_screen_size),
|
FN_ENTRY(get_screen_size),
|
||||||
|
Loading…
Reference in New Issue
Block a user