mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-08 08:58:05 +02:00
[script] add support for message in script
This commit is contained in:
parent
fc2cbc497a
commit
ff959dbd2f
3 changed files with 39 additions and 0 deletions
|
|
@ -415,6 +415,15 @@ display_question (ply_boot_splash_plugin_t *plugin,
|
|||
entry_text);
|
||||
}
|
||||
|
||||
static void
|
||||
display_message (ply_boot_splash_plugin_t *plugin,
|
||||
const char *message)
|
||||
{
|
||||
script_lib_plymouth_on_message (plugin->script_state,
|
||||
plugin->script_plymouth_lib,
|
||||
message);
|
||||
}
|
||||
|
||||
ply_boot_splash_plugin_interface_t *
|
||||
ply_boot_splash_plugin_get_interface (void)
|
||||
{
|
||||
|
|
@ -433,6 +442,7 @@ ply_boot_splash_plugin_get_interface (void)
|
|||
.display_normal = display_normal,
|
||||
.display_password = display_password,
|
||||
.display_question = display_question,
|
||||
.display_message = display_message,
|
||||
};
|
||||
|
||||
return &plugin_interface;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state_t *state)
|
|||
data->script_display_normal_func = script_obj_new_null ();
|
||||
data->script_display_password_func = script_obj_new_null ();
|
||||
data->script_display_question_func = script_obj_new_null ();
|
||||
data->script_message_func = script_obj_new_null ();
|
||||
|
||||
script_add_native_function (state->global,
|
||||
"PlymouthSetRefreshFunction",
|
||||
|
|
@ -115,6 +116,12 @@ script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state_t *state)
|
|||
&data->script_display_question_func,
|
||||
"function",
|
||||
NULL);
|
||||
script_add_native_function (state->global,
|
||||
"PlymouthSetMessageFunction",
|
||||
plymouth_set_function,
|
||||
&data->script_message_func,
|
||||
"function",
|
||||
NULL);
|
||||
data->script_main_op = script_parse_string (script_lib_plymouth_string);
|
||||
script_return_t ret = script_execute (state, data->script_main_op);
|
||||
script_obj_unref (ret.object); /* Throw anything sent back away */
|
||||
|
|
@ -133,6 +140,7 @@ void script_lib_plymouth_destroy (script_lib_plymouth_data_t *data)
|
|||
script_obj_unref (data->script_display_normal_func);
|
||||
script_obj_unref (data->script_display_password_func);
|
||||
script_obj_unref (data->script_display_question_func);
|
||||
script_obj_unref (data->script_message_func);
|
||||
free (data);
|
||||
}
|
||||
|
||||
|
|
@ -271,3 +279,20 @@ void script_lib_plymouth_on_display_question (script_state_t *state,
|
|||
script_obj_unref (ret.object);
|
||||
}
|
||||
}
|
||||
|
||||
void script_lib_plymouth_on_message (script_state_t *state,
|
||||
script_lib_plymouth_data_t *data,
|
||||
const char *message)
|
||||
{
|
||||
script_function_t *function = script_obj_as_function (data->script_message_func);
|
||||
if (function)
|
||||
{
|
||||
script_obj_t *new_message_obj = script_obj_new_string (message);
|
||||
script_return_t ret = script_execute_function (state,
|
||||
function,
|
||||
new_message_obj,
|
||||
NULL);
|
||||
script_obj_unref (new_message_obj);
|
||||
script_obj_unref (ret.object);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ typedef struct
|
|||
script_obj_t *script_display_normal_func;
|
||||
script_obj_t *script_display_password_func;
|
||||
script_obj_t *script_display_question_func;
|
||||
script_obj_t *script_message_func;
|
||||
} script_lib_plymouth_data_t;
|
||||
|
||||
script_lib_plymouth_data_t *script_lib_plymouth_setup (script_state_t *state);
|
||||
|
|
@ -64,5 +65,8 @@ void script_lib_plymouth_on_display_question (script_state_t *state,
|
|||
script_lib_plymouth_data_t *data,
|
||||
const char *prompt,
|
||||
const char *entry_text);
|
||||
void script_lib_plymouth_on_message (script_state_t *state,
|
||||
script_lib_plymouth_data_t *data,
|
||||
const char *new_message);
|
||||
|
||||
#endif /* SCRIPT_LIB_PLYMOUTH */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue