settings: add new _get_all() API
This commit is contained in:
@@ -1582,6 +1582,28 @@ settings_get (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
settings_get_all (lua_State *L)
|
||||
{
|
||||
const char *pattern = luaL_checkstring (L, 1);
|
||||
const char *m = NULL;
|
||||
|
||||
if (lua_type (L, 2) == LUA_TSTRING)
|
||||
m = luaL_checkstring (L, 2);
|
||||
|
||||
g_autoptr (WpSettings) s = wp_settings_get_instance (get_wp_core (L), m);
|
||||
|
||||
if (s) {
|
||||
WpSpaJson *j = wp_settings_get_all (s, pattern);
|
||||
if (j)
|
||||
wplua_pushboxed (L, WP_TYPE_SPA_JSON, j);
|
||||
else
|
||||
lua_pushnil (L);
|
||||
} else
|
||||
lua_pushnil (L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
settings_apply_rule (lua_State *L)
|
||||
{
|
||||
@@ -1650,6 +1672,7 @@ static const luaL_Reg settings_methods[] = {
|
||||
{ "get_int", settings_get_int },
|
||||
{ "get_float", settings_get_float },
|
||||
{ "get", settings_get },
|
||||
{ "get_all", settings_get_all },
|
||||
{ "apply_rule", settings_apply_rule },
|
||||
{ "subscribe", settings_subscribe },
|
||||
{ "unsubscribe", settings_unsubscribe },
|
||||
|
Reference in New Issue
Block a user