mcviewer: refactoring of MSG_RESIZE handling.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-10-10 10:41:11 +03:00
parent 5ca0dbab01
commit 2ddd6b41a0
2 changed files with 13 additions and 20 deletions

View File

@ -622,18 +622,8 @@ mcview_handle_key (WView * view, int key)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static inline void static inline void
mcview_adjust_size (WDialog * h) mcview_resize (WView * view)
{ {
WView *view;
WButtonBar *b;
/* Look up the viewer and the buttonbar, we assume only two widgets here */
view = (WView *) find_widget_type (h, mcview_callback);
b = find_buttonbar (h);
widget_set_size (WIDGET (view), 0, 0, LINES - 1, COLS);
widget_set_size (WIDGET (b), LINES - 1, 0, 1, COLS);
view->dpy_wrap_dirty = TRUE; view->dpy_wrap_dirty = TRUE;
mcview_compute_areas (view); mcview_compute_areas (view);
mcview_update_bytes_per_line (view); mcview_update_bytes_per_line (view);
@ -725,6 +715,10 @@ mcview_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *
mcview_update (view); mcview_update (view);
return MSG_HANDLED; return MSG_HANDLED;
case MSG_RESIZE:
mcview_resize (view);
return MSG_HANDLED;
case MSG_DESTROY: case MSG_DESTROY:
if (mcview_is_in_panel (view)) if (mcview_is_in_panel (view))
{ {
@ -773,10 +767,6 @@ mcview_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
switch (msg) switch (msg)
{ {
case MSG_RESIZE:
mcview_adjust_size (h);
return MSG_HANDLED;
case MSG_ACTION: case MSG_ACTION:
/* Handle shortcuts. */ /* Handle shortcuts. */

View File

@ -234,16 +234,19 @@ mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin
gboolean succeeded; gboolean succeeded;
WView *lc_mcview; WView *lc_mcview;
WDialog *view_dlg; WDialog *view_dlg;
Widget *vw, *b;
/* Create dialog and widgets, put them on the dialog */ /* Create dialog and widgets, put them on the dialog */
view_dlg = dlg_create (FALSE, 0, 0, 1, 1, WPOS_FULLSCREEN, FALSE, NULL, mcview_dialog_callback, view_dlg = dlg_create (FALSE, 0, 0, 1, 1, WPOS_FULLSCREEN, FALSE, NULL, mcview_dialog_callback,
NULL, "[Internal File Viewer]", NULL); NULL, "[Internal File Viewer]", NULL);
widget_want_tab (WIDGET (view_dlg), TRUE); vw = WIDGET (view_dlg);
widget_want_tab (vw, TRUE);
lc_mcview = mcview_new (0, 0, LINES - 1, COLS, FALSE); lc_mcview = mcview_new (vw->y, vw->x, vw->lines - 1, vw->cols, FALSE);
add_widget (view_dlg, lc_mcview); add_widget_autopos (view_dlg, lc_mcview, WPOS_KEEP_ALL, NULL);
add_widget (view_dlg, buttonbar_new (TRUE)); b = WIDGET (buttonbar_new (TRUE));
add_widget_autopos (view_dlg, b, b->pos_flags, NULL);
view_dlg->get_title = mcview_get_title; view_dlg->get_title = mcview_get_title;
@ -256,7 +259,7 @@ mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin
else else
dlg_stop (view_dlg); dlg_stop (view_dlg);
if (widget_get_state (WIDGET (view_dlg), WST_CLOSED)) if (widget_get_state (vw, WST_CLOSED))
dlg_destroy (view_dlg); dlg_destroy (view_dlg);
return succeeded; return succeeded;