51 lines
1.5 KiB
C
51 lines
1.5 KiB
C
#include "group.h"
|
|
#include <ncurses.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <widget.h>
|
|
|
|
typedef struct {
|
|
button_t *element;
|
|
enum w_type type;
|
|
} group_bt_t;
|
|
|
|
void server_message_modal_cb(callback_args_t *args) {
|
|
callback_args_t d_args;
|
|
app_t *app = args->app;
|
|
dialogue_t *d = (dialogue_t *)app->active_widget;
|
|
memcpy(&d_args, args, sizeof(callback_args_t));
|
|
d_args.app = NULL;
|
|
d_args.element = app->active_widget;
|
|
dialogue_default_callback(&d_args);
|
|
if (d_args.resp_data.code == cbrp_val) {
|
|
switch (d_args.resp_data.val.val.num) {
|
|
case 1:
|
|
d->needs_destroy = true;
|
|
/* TODO: macros */
|
|
free(app->query_args->server_message.text);
|
|
app->query_args->server_message.text = NULL;
|
|
app->query_args->server_message.capacity = 0;
|
|
app->query_args->server_message.size = 0;
|
|
app->query_args->state = S_NEXT_ACTION;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void *init_server_message_modal(app_t *app) {
|
|
if (app == NULL)
|
|
return NULL;
|
|
group_el_init_t children[] = {
|
|
{.type = w_button, .label = "OK", .is_default = true, .val.num = 1}, {.type = w_end}};
|
|
|
|
init_dialogue(&(app->modal), "Server response",
|
|
app->query_args->server_message.text, &(app->coordinates));
|
|
app->modal.g_action =
|
|
init_group(&(app->modal.win), &(app->modal.w), children, &(app->modal.id_map), horizontal, g_action);
|
|
app->modal.w.callback = server_message_modal_cb;
|
|
dialogue_init_active_id(&(app->modal));
|
|
|
|
return NULL;
|
|
} |