file list fixes
This commit is contained in:
@@ -157,8 +157,8 @@ void app_refresh(app_t *app) {
|
|||||||
if (app->modal.is_initiated != 0) {
|
if (app->modal.is_initiated != 0) {
|
||||||
wnoutrefresh(app->modal.win);
|
wnoutrefresh(app->modal.win);
|
||||||
}
|
}
|
||||||
} else if (app->main_ui.cb_refresh != NULL) {
|
} else if (app->main_ui.cb_ui_refresh != NULL) {
|
||||||
app->main_ui.cb_refresh(app);
|
app->main_ui.cb_ui_refresh(app);
|
||||||
}
|
}
|
||||||
doupdate();
|
doupdate();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ typedef struct {
|
|||||||
|
|
||||||
#define MAIN_UI_RESET(app) \
|
#define MAIN_UI_RESET(app) \
|
||||||
app->main_ui.ui = NULL; \
|
app->main_ui.ui = NULL; \
|
||||||
app->main_ui.cb_refresh = NULL; \
|
app->main_ui.cb_ui_refresh = NULL; \
|
||||||
app->main_ui.cb_b_press = NULL; \
|
app->main_ui.cb_b_press = NULL; \
|
||||||
app->main_ui.b_keys = NULL; \
|
app->main_ui.b_keys = NULL; \
|
||||||
app->main_ui.b_keys_len = 0;
|
app->main_ui.b_keys_len = 0;
|
||||||
|
|||||||
+5
-1
@@ -89,11 +89,15 @@ enum main_window_type {
|
|||||||
mw_f_desc, /* file description */
|
mw_f_desc, /* file description */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (draw_f_t) (void *fui) ;
|
||||||
|
|
||||||
typedef struct main_window {
|
typedef struct main_window {
|
||||||
enum main_window_type type;
|
enum main_window_type type;
|
||||||
void *ui; /* structure which describes window UI */
|
void *ui; /* structure which describes window UI */
|
||||||
int32_t (*cb_b_press) (void *app, void *args); /* callback on button press */
|
int32_t (*cb_b_press) (void *app, void *args); /* callback on button press */
|
||||||
void (*cb_refresh) (void *app); /* refresh callback */
|
void (*cb_ui_refresh) (void *app); /* refresh callback */
|
||||||
|
void (*reset) (void *app); /* reset state of the window */
|
||||||
|
draw_f_t *draw;
|
||||||
struct action_key *b_keys;
|
struct action_key *b_keys;
|
||||||
int32_t b_keys_len;
|
int32_t b_keys_len;
|
||||||
} main_window_t;
|
} main_window_t;
|
||||||
|
|||||||
@@ -139,15 +139,12 @@ void wait_register(query_args_t *q_args) {
|
|||||||
|
|
||||||
int upload_confirm_cb(app_t *app, char *query, int q_len) {
|
int upload_confirm_cb(app_t *app, char *query, int q_len) {
|
||||||
if (!strncmp("finished\n", query, sizeof("finished\n") - 1)) {
|
if (!strncmp("finished\n", query, sizeof("finished\n") - 1)) {
|
||||||
w_ui_file_list_t *fui = (w_ui_file_list_t *)app->query_args->main_ui->ui;
|
|
||||||
w_notification("File upload", dc_normal,
|
w_notification("File upload", dc_normal,
|
||||||
"File %s is uploaded to the server!",
|
"File %s is uploaded to the server!",
|
||||||
app->query_args->file->name);
|
app->query_args->file->name);
|
||||||
clear_file_in_query(app->query_args);
|
clear_file_in_query(app->query_args);
|
||||||
app->query_args->state = S_FILE_LIST;
|
app->query_args->state = S_FILE_LIST;
|
||||||
app->modal.needs_destroy = true;
|
app->modal.needs_destroy = true;
|
||||||
w_fl_reset(fui);
|
|
||||||
server_send_string(app->query_args, "file list %u %u\n", fui->max_lines, 1);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1; /* TODO: Error case */
|
return 1; /* TODO: Error case */
|
||||||
|
|||||||
+12
-1
@@ -164,15 +164,20 @@ static int32_t process_user_input(app_t *app, w_cb_args_t *d_args) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void w_fl_reset_app(void *app);
|
||||||
|
|
||||||
void *w_fl_init(app_t *app) {
|
void *w_fl_init(app_t *app) {
|
||||||
w_ui_file_list_t *fui = malloc(sizeof(w_ui_file_list_t));
|
w_ui_file_list_t *fui = malloc(sizeof(w_ui_file_list_t));
|
||||||
app->main_ui.ui = fui;
|
app->main_ui.ui = fui;
|
||||||
app->main_ui.type = mw_fl_server;
|
app->main_ui.type = mw_fl_server;
|
||||||
app->main_ui.cb_refresh = w_fl_cb_refresh;
|
app->main_ui.cb_ui_refresh = w_fl_cb_refresh;
|
||||||
app->main_ui.b_keys = action_keys;
|
app->main_ui.b_keys = action_keys;
|
||||||
app->main_ui.b_keys_len = 4;
|
app->main_ui.b_keys_len = 4;
|
||||||
app->main_ui.cb_b_press = (w_cb_press_t)process_user_input;
|
app->main_ui.cb_b_press = (w_cb_press_t)process_user_input;
|
||||||
|
app->main_ui.reset = w_fl_reset_app;
|
||||||
|
app->main_ui.draw = (draw_f_t *) w_fl_draw;
|
||||||
app->active_callback = w_fl_cb;
|
app->active_callback = w_fl_cb;
|
||||||
|
fui->w.callback = w_fl_cb;
|
||||||
w_init(&(fui->w), NULL, &(app->win), "");
|
w_init(&(fui->w), NULL, &(app->win), "");
|
||||||
WINDOW *win_parent = app->win;
|
WINDOW *win_parent = app->win;
|
||||||
fui->current_idx = 0;
|
fui->current_idx = 0;
|
||||||
@@ -221,6 +226,12 @@ void w_fl_reset(w_ui_file_list_t *fl_ui) {
|
|||||||
fl_ui->active_search = false;
|
fl_ui->active_search = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void w_fl_reset_app(void *app) {
|
||||||
|
app_t *_app = (app_t *) app;
|
||||||
|
w_ui_file_list_t *fl_ui = (w_ui_file_list_t *) _app->main_ui.ui;
|
||||||
|
w_fl_reset(fl_ui);
|
||||||
|
}
|
||||||
|
|
||||||
void w_fl_draw(w_ui_file_list_t *fui) {
|
void w_fl_draw(w_ui_file_list_t *fui) {
|
||||||
int32_t sz_y, sz_x;
|
int32_t sz_y, sz_x;
|
||||||
int64_t p_y, p_x;
|
int64_t p_y, p_x;
|
||||||
|
|||||||
@@ -354,20 +354,24 @@ static int32_t process_user_input(app_t *app, w_cb_args_t *d_args) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void w_lfl_reset_app(void *app);
|
||||||
|
|
||||||
w_lfl_ui_t *w_lfl_init_win(app_t *app) {
|
w_lfl_ui_t *w_lfl_init_win(app_t *app) {
|
||||||
w_lfl_ui_t *fui = malloc(sizeof(w_lfl_ui_t));
|
w_lfl_ui_t *fui = malloc(sizeof(w_lfl_ui_t));
|
||||||
app->main_ui.ui = fui;
|
app->main_ui.ui = fui;
|
||||||
app->main_ui.type = mw_fl_local;
|
app->main_ui.type = mw_fl_local;
|
||||||
app->main_ui.cb_refresh = w_lfl_cb_refresh;
|
app->main_ui.cb_ui_refresh = w_lfl_cb_refresh;
|
||||||
app->main_ui.b_keys = action_keys;
|
app->main_ui.b_keys = action_keys;
|
||||||
app->main_ui.b_keys_len = 2;
|
app->main_ui.b_keys_len = 2;
|
||||||
app->main_ui.cb_b_press = (w_cb_press_t)process_user_input;
|
app->main_ui.cb_b_press = (w_cb_press_t)process_user_input;
|
||||||
|
app->main_ui.reset = w_lfl_reset_app;
|
||||||
|
app->main_ui.draw = (draw_f_t *) w_lfl_draw;
|
||||||
app->active_callback = w_lfl_cb;
|
app->active_callback = w_lfl_cb;
|
||||||
|
fui->w.callback = w_lfl_cb;
|
||||||
w_init(&(fui->w), NULL, &(app->win), "");
|
w_init(&(fui->w), NULL, &(app->win), "");
|
||||||
fui->current_idx = 0;
|
fui->current_idx = 0;
|
||||||
fui->win_info = NULL;
|
fui->win_info = NULL;
|
||||||
fui->d_path = NULL;
|
fui->d_path = NULL;
|
||||||
fui->w.callback = w_lfl_cb;
|
|
||||||
fui->w.sz.x = getmaxx(app->win);
|
fui->w.sz.x = getmaxx(app->win);
|
||||||
fui->w.sz.y = getmaxy(app->win);
|
fui->w.sz.y = getmaxy(app->win);
|
||||||
fui->cur_page = 1;
|
fui->cur_page = 1;
|
||||||
@@ -393,7 +397,16 @@ w_lfl_ui_t *w_lfl_init_win(app_t *app) {
|
|||||||
return fui;
|
return fui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void w_lfl_reset(w_lfl_ui_t *fl_ui) { fl_ui->current_idx = 0; }
|
void w_lfl_reset(w_lfl_ui_t *fl_ui) {
|
||||||
|
fl_ui->current_idx = 0;
|
||||||
|
lfl_clear(&(fl_ui->start), &(fl_ui->current));
|
||||||
|
}
|
||||||
|
|
||||||
|
void w_lfl_reset_app(void *app) {
|
||||||
|
app_t *_app = app;
|
||||||
|
w_lfl_ui_t *fl_ui = (w_lfl_ui_t *) _app->main_ui.ui;
|
||||||
|
w_lfl_reset(fl_ui);
|
||||||
|
}
|
||||||
|
|
||||||
void w_lfl_draw(w_lfl_ui_t *fui) {
|
void w_lfl_draw(w_lfl_ui_t *fui) {
|
||||||
int32_t sz_y, sz_x;
|
int32_t sz_y, sz_x;
|
||||||
|
|||||||
Reference in New Issue
Block a user