ui: finished (kinda) file upload

This commit is contained in:
2026-01-22 16:26:36 +02:00
parent 346ded71bc
commit 50952f324d
10 changed files with 88 additions and 30 deletions
+4 -2
View File
@@ -155,7 +155,10 @@ void app_draw_modal(app_t *app) {
init_server_message_modal(app);
break;
case S_FILE_DOWNLOAD:
init_dwn_pr_modal(app);
init_dwn_pr_modal(app, false);
break;
case S_UPLOAD_FILE:
init_dwn_pr_modal(app, true);
break;
case S_UPLOAD_FILE_SELECT:
init_upload_dialogue_modal(app);
@@ -176,7 +179,6 @@ void app_draw_modal(app_t *app) {
case S_WAIT_SERVER:
case S_N_D:
case S_NEXT_ACTION:
case S_UPLOAD_FILE:
if (app->query_args->notification != NULL) {
init_notification_modal(app);
} else {
+10 -8
View File
@@ -5,22 +5,24 @@
#include <stdint.h>
#include <stdio.h>
void dwn_pr_modal_cb(callback_args_t *args) {
}
void dwn_pr_modal_cb(callback_args_t *args) {}
dialogue_t *init_dwn_pr_modal(app_t *app) {
dialogue_t *init_dwn_pr_modal(app_t *app, bool is_upload) {
if (app == NULL)
return NULL;
group_el_init_t content[] = {{.type = w_progress, .label = "", .length = 30}, /* length is ignored */
{.type = w_end}};
group_el_init_t content[] = {
{.type = w_progress, .label = "", .length = 30}, /* length is ignored */
{.type = w_end}};
char text[256];
sprintf(text, "Downloading file: %s", app->file_args->f_selected.name);
sprintf(text, "%s file: %s", is_upload ? "Uploading" : "Downloading",
is_upload ? app->query_args->file->name : app->file_args->f_selected.name);
group_el_init_t actions[] = {
{.type = w_button, .label = "Cancel", .is_default = 0}, {.type = w_end}};
{.type = w_button, .label = "Cancel", .is_default = 1}, {.type = w_end}};
app->modal.w.parent_win = &app->win;
init_dialogue(&(app->modal), "Download", text, &(app->coordinates));
init_dialogue(&(app->modal), is_upload ? "Upload" : "Download", text,
&(app->coordinates));
dialogue_t *d = &(app->modal);
d->w.callback = dwn_pr_modal_cb;
+1 -1
View File
@@ -4,6 +4,6 @@
#include "../widget/dialogue.h"
#include "../app.h"
dialogue_t *init_dwn_pr_modal(app_t *app);
dialogue_t *init_dwn_pr_modal(app_t *app, bool is_upload);
#endif
+1
View File
@@ -28,6 +28,7 @@ void server_message_modal_cb(callback_args_t *args) {
destroy_dialogue(d, app);
/* 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;
+34 -3
View File
@@ -187,10 +187,12 @@ void dialogue_init_active_id(dialogue_t *dialogue) {
dialogue->active.type = g_content;
widget_t *w = (widget_t *)dialogue->g_content->elements[i].element;
dialogue->active.id = w->id;
break;
return;
}
}
} else if (dialogue->g_action != NULL) {
}
if (dialogue->g_action != NULL) {
for (int i = 0; i < dialogue->g_action->count; i++) {
widget_type = dialogue->g_action->elements[i].type;
if (widget_type == w_button || widget_type == w_input ||
@@ -198,12 +200,41 @@ void dialogue_init_active_id(dialogue_t *dialogue) {
dialogue->active.type = g_action;
widget_t *w = (widget_t *)dialogue->g_action->elements[i].element;
dialogue->active.id = w->id;
break;
return;
}
}
}
}
// void dialogue_init_active_id(dialogue_t *dialogue) {
// enum w_type widget_type;
// if (dialogue->g_content != NULL) {
// for (int i = 0; i < dialogue->g_content->count; i++) {
// widget_type = dialogue->g_content->elements[i].type;
// if (widget_type == w_button || widget_type == w_input ||
// widget_type == w_fs_file_list) { /* Add here new types */
// dialogue->active.type = g_content;
// widget_t *w = (widget_t *)dialogue->g_content->elements[i].element;
// dialogue->active.id = w->id;
// break;
// }
// }
// } else if (dialogue->g_action != NULL) {
// for (int i = 0; i < dialogue->g_action->count; i++) {
// widget_type = dialogue->g_action->elements[i].type;
// if (widget_type == w_button || widget_type == w_input ||
// widget_type == w_fs_file_list) {
// dialogue->active.type = g_action;
// widget_t *w = (widget_t *)dialogue->g_action->elements[i].element;
// dialogue->active.id = w->id;
// break;
// }
// }
// }
// }
#define DETECT_GROUP_SIZE(group, line_max_len, y, x) \
if (group) { \
group->w.m_y = y; \