ui: notification when a file is downloaded
This commit is contained in:
+11
-6
@@ -3,6 +3,7 @@
|
||||
#include "modals/download_pr.h"
|
||||
#include "modals/login_credentials.h"
|
||||
#include "modals/login_option.h"
|
||||
#include "modals/notification.h"
|
||||
#include "modals/server_message.h"
|
||||
#include "widget/dialogue.h"
|
||||
#include <ncurses.h>
|
||||
@@ -139,6 +140,10 @@ void app_refresh(app_t *app) {
|
||||
}
|
||||
|
||||
void app_draw_modal(app_t *app) {
|
||||
if (app->modal.needs_destroy) {
|
||||
destroy_dialogue(&(app->modal), app);
|
||||
app_refresh(app);
|
||||
}
|
||||
if (!app->modal.is_initiated) {
|
||||
switch (app->query_args->state) {
|
||||
case S_ASK_SEVER_IP:
|
||||
@@ -172,18 +177,18 @@ void app_draw_modal(app_t *app) {
|
||||
case S_WAIT_SERVER:
|
||||
case S_N_D:
|
||||
case S_NEXT_ACTION:
|
||||
return;
|
||||
if (app->query_args->notification != NULL) {
|
||||
init_notification_modal(app);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
app->active_callback = app->modal.w.callback;
|
||||
app->active_win = app->modal.win;
|
||||
app->active_win_type = aw_modal;
|
||||
app->active_widget = &(app->modal);
|
||||
}
|
||||
if (app->modal.needs_destroy) {
|
||||
destroy_dialogue(&(app->modal), app);
|
||||
} else {
|
||||
draw_dialogue(&(app->modal));
|
||||
}
|
||||
draw_dialogue(&(app->modal));
|
||||
}
|
||||
|
||||
void destroy_app(app_t *app) {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#include <ncurses.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../app.h"
|
||||
#include "../widget/dialogue.h"
|
||||
#include "../widget/group.h"
|
||||
|
||||
typedef struct {
|
||||
button_t *element;
|
||||
enum w_type type;
|
||||
} group_bt_t;
|
||||
|
||||
void init_notification_modal_cb(callback_args_t *args) {
|
||||
int32_t response;
|
||||
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.resp_data = &response;
|
||||
d_args.widget = app->active_widget;
|
||||
dialogue_default_callback(&d_args);
|
||||
|
||||
app->query_args->state = WAIT_CLIENT;
|
||||
destroy_dialogue(d, app);
|
||||
}
|
||||
|
||||
dialogue_t *init_notification_modal(app_t *app) {
|
||||
if (app == NULL)
|
||||
return NULL;
|
||||
|
||||
group_el_init_t actions[] = {
|
||||
{.type = w_button, .label = "OK", .is_default = 1}, {.type = w_end}};
|
||||
|
||||
init_dialogue(&(app->modal), "Notification", app->query_args->notification,
|
||||
&(app->coordinates));
|
||||
free(app->query_args->notification);
|
||||
app->query_args->notification = NULL;
|
||||
dialogue_t *d = &(app->modal);
|
||||
app->query_args->active_dialogue = d;
|
||||
|
||||
d->w.callback = init_notification_modal_cb;
|
||||
d->g_content = NULL;
|
||||
d->g_action = init_group(&(d->win), &(d->w), actions, horizontal);
|
||||
|
||||
dialogue_init_active_id(d);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef NOTIFICATION_H
|
||||
#define NOTIFICATION_H
|
||||
|
||||
#include "../app.h"
|
||||
#include "../widget/dialogue.h"
|
||||
|
||||
dialogue_t *init_notification_modal(app_t *app);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user