|
| 1 | +/* |
| 2 | + This file is part of darktable, |
| 3 | + Copyright (C) 2024 darktable developers. |
| 4 | +
|
| 5 | + darktable is free software: you can redistribute it and/or modify |
| 6 | + it under the terms of the GNU General Public License as published by |
| 7 | + the Free Software Foundation, either version 3 of the License, or |
| 8 | + (at your option) any later version. |
| 9 | +
|
| 10 | + darktable is distributed in the hope that it will be useful, |
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + GNU General Public License for more details. |
| 14 | +
|
| 15 | + You should have received a copy of the GNU General Public License |
| 16 | + along with darktable. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | +#include "lua/preferences.h" |
| 19 | +#include "lua/call.h" |
| 20 | +#include "lua/events.h" |
| 21 | +#include <glib.h> |
| 22 | +#include <stdlib.h> |
| 23 | +#include <string.h> |
| 24 | + |
| 25 | +static int message(lua_State *L) |
| 26 | +{ |
| 27 | + const char *sender = luaL_checkstring(L, 1); |
| 28 | + const char *receiver = luaL_checkstring(L, 2); |
| 29 | + const char *message = luaL_checkstring(L, 3); |
| 30 | + |
| 31 | + dt_lua_async_call_alien(dt_lua_event_trigger_wrapper, |
| 32 | + 0, NULL, NULL, |
| 33 | + LUA_ASYNC_TYPENAME, "const char*", "inter-script-communication", |
| 34 | + LUA_ASYNC_TYPENAME, "const char*", sender, |
| 35 | + LUA_ASYNC_TYPENAME, "const char*", receiver, |
| 36 | + LUA_ASYNC_TYPENAME, "const char*", message, |
| 37 | + LUA_ASYNC_DONE); |
| 38 | + |
| 39 | + return 0; |
| 40 | +} |
| 41 | + |
| 42 | + |
| 43 | +int dt_lua_init_util(lua_State *L) |
| 44 | +{ |
| 45 | + dt_lua_push_darktable_lib(L); |
| 46 | + dt_lua_goto_subtable(L, "util"); |
| 47 | + |
| 48 | + lua_pushcfunction(L, message); |
| 49 | + lua_setfield(L, -2, "message"); |
| 50 | + |
| 51 | + lua_pop(L, 1); |
| 52 | + |
| 53 | + |
| 54 | + lua_pushcfunction(L, dt_lua_event_multiinstance_register); |
| 55 | + lua_pushcfunction(L, dt_lua_event_multiinstance_destroy); |
| 56 | + lua_pushcfunction(L, dt_lua_event_multiinstance_trigger); |
| 57 | + dt_lua_event_add(L, "inter-script-communication"); |
| 58 | + |
| 59 | + return 0; |
| 60 | +} |
| 61 | +// clang-format off |
| 62 | +// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py |
| 63 | +// vim: shiftwidth=2 expandtab tabstop=2 cindent |
| 64 | +// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified; |
| 65 | +// clang-format on |
| 66 | + |
0 commit comments