mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-16 04:42:54 +03:00
src/filemanager/chattr.c: minor refactoring.
(chattrboxes_new): create WChattrBoxes widget entirely. (chattr_dlg_create): move creation of checkboxes to chattrboxes_new(). Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
2cd33ad0d5
commit
1e1cbb31d0
@ -880,17 +880,37 @@ chattrboxes_new (int y, int x, int height, int width)
|
||||
{
|
||||
WChattrBoxes *cb;
|
||||
Widget *w;
|
||||
WGroup *cbg;
|
||||
int i;
|
||||
|
||||
if (height <= 0)
|
||||
height = 1;
|
||||
|
||||
cb = g_new0 (WChattrBoxes, 1);
|
||||
w = WIDGET (cb);
|
||||
group_init (GROUP (cb), y, x, height, width, chattrboxes_callback, chattrboxes_mouse_callback);
|
||||
cbg = GROUP (cb);
|
||||
group_init (cbg, y, x, height, width, chattrboxes_callback, chattrboxes_mouse_callback);
|
||||
w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR;
|
||||
w->mouse_handler = chattrboxes_handle_mouse_event;
|
||||
w->keymap = chattr_map;
|
||||
|
||||
/* create checkboxes */
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
int m;
|
||||
WCheck *check;
|
||||
|
||||
m = check_attr_mod[i];
|
||||
|
||||
check = check_new (i, 0, check_attr[m].state, NULL);
|
||||
group_add_widget (cbg, check);
|
||||
}
|
||||
|
||||
chattrboxes_rename (cb);
|
||||
|
||||
/* select first checkbox */
|
||||
cbg->current = cbg->widgets;
|
||||
|
||||
return cb;
|
||||
}
|
||||
|
||||
@ -952,7 +972,7 @@ chattr_dlg_create (WPanel * panel, const char *fname, unsigned long attr)
|
||||
size_t i;
|
||||
int y;
|
||||
Widget *dw;
|
||||
WGroup *dg, *cbg;
|
||||
WGroup *dg;
|
||||
WChattrBoxes *cb;
|
||||
const int cb_scrollbar_width = 1;
|
||||
|
||||
@ -996,25 +1016,11 @@ chattr_dlg_create (WPanel * panel, const char *fname, unsigned long attr)
|
||||
widget_set_size (dw, dw->y, dw->x, lines, cols + wx * 2);
|
||||
}
|
||||
|
||||
checkboxes_lines = MIN (check_attr_mod_num, checkboxes_lines);
|
||||
cb = chattrboxes_new (y++, wx, checkboxes_lines, cols);
|
||||
cbg = GROUP (cb);
|
||||
group_add_widget_autopos (dg, cb, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
|
||||
|
||||
/* create checkboxes */
|
||||
for (i = 0; i < (size_t) check_attr_mod_num && i < (size_t) checkboxes_lines; i++)
|
||||
{
|
||||
int m;
|
||||
WCheck *check;
|
||||
|
||||
m = check_attr_mod[i];
|
||||
|
||||
check = check_new (i, 0, check_attr[m].state, NULL);
|
||||
group_add_widget (cbg, check);
|
||||
}
|
||||
|
||||
chattrboxes_rename (cb);
|
||||
|
||||
y += i - 1;
|
||||
y += checkboxes_lines - 1;
|
||||
cols = 0;
|
||||
|
||||
for (i = single_set ? (BUTTONS - 2) : 0; i < BUTTONS; i++)
|
||||
@ -1057,8 +1063,6 @@ chattr_dlg_create (WPanel * panel, const char *fname, unsigned long attr)
|
||||
}
|
||||
}
|
||||
|
||||
/* select first checkbox */
|
||||
cbg->current = cbg->widgets;
|
||||
widget_select (WIDGET (cb));
|
||||
|
||||
return ch_dlg;
|
||||
|
Loading…
x
Reference in New Issue
Block a user