Change the file list panel creation APIs.

* (panel_sized_empty_new): use WRect to define a panel area.
  * (panel_sized_with_dir_new): likewise.
  * (panel_sized_new): likewise.
  * (panel_empty_new): sync with modified API.
  * (panel_with_dir_new): likewise.
  * (panel_sized_with_dir_new): likewise.
  * (create_panel): likewise.
  * (restore_into_right_dir_panel): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2024-02-18 13:13:47 +03:00
parent 8bb12a40e6
commit be148a0578
3 changed files with 21 additions and 25 deletions

View File

@ -649,7 +649,7 @@ panel_do_cols (int idx)
/** Save current list_view widget directory into panel */
static Widget *
restore_into_right_dir_panel (int idx, gboolean last_was_panel, int y, int x, int lines, int cols)
restore_into_right_dir_panel (int idx, gboolean last_was_panel, const WRect * r)
{
WPanel *new_widget;
const char *p_name;
@ -661,11 +661,11 @@ restore_into_right_dir_panel (int idx, gboolean last_was_panel, int y, int x, in
vfs_path_t *saved_dir_vpath;
saved_dir_vpath = vfs_path_from_str (panels[idx].last_saved_dir);
new_widget = panel_sized_with_dir_new (p_name, y, x, lines, cols, saved_dir_vpath);
new_widget = panel_sized_with_dir_new (p_name, r, saved_dir_vpath);
vfs_path_free (saved_dir_vpath, TRUE);
}
else
new_widget = panel_sized_new (p_name, y, x, lines, cols);
new_widget = panel_sized_new (p_name, r);
return WIDGET (new_widget);
}
@ -1183,8 +1183,7 @@ create_panel (int num, panel_view_mode_t type)
gboolean last_was_panel;
last_was_panel = old_widget != NULL && get_panel_type (num) != view_listing;
new_widget =
restore_into_right_dir_panel (num, last_was_panel, r.y, r.x, r.lines, r.cols);
new_widget = restore_into_right_dir_panel (num, last_was_panel, &r);
break;
}

View File

@ -4467,14 +4467,14 @@ panel_set_lwd (WPanel * panel, const vfs_path_t * vpath)
* Creatie an empty panel with specified size.
*
* @param panel_name name of panel for setup receiving
* @param r panel areaa
*
* @return new instance of WPanel
*/
WPanel *
panel_sized_empty_new (const char *panel_name, int y, int x, int lines, int cols)
panel_sized_empty_new (const char *panel_name, const WRect * r)
{
WRect r = { y, x, lines, cols };
WPanel *panel;
Widget *w;
char *section;
@ -4482,7 +4482,7 @@ panel_sized_empty_new (const char *panel_name, int y, int x, int lines, int cols
panel = g_new0 (WPanel, 1);
w = WIDGET (panel);
widget_init (w, &r, panel_callback, panel_mouse_callback);
widget_init (w, r, panel_callback, panel_mouse_callback);
w->options |= WOP_SELECTABLE | WOP_TOP_SELECT;
w->keymap = panel_map;
@ -4555,18 +4555,14 @@ panel_sized_empty_new (const char *panel_name, int y, int x, int lines, int cols
* Panel creation for specified size and directory.
*
* @param panel_name name of panel for setup retrieving
* @param y y coordinate of top-left corner
* @param x x coordinate of top-left corner
* @param lines vertical size
* @param cols horizontal size
* @param r panel areaa
* @param vpath working panel directory. If NULL then current directory is used
*
* @return new instance of WPanel
*/
WPanel *
panel_sized_with_dir_new (const char *panel_name, int y, int x, int lines, int cols,
const vfs_path_t * vpath)
panel_sized_with_dir_new (const char *panel_name, const WRect * r, const vfs_path_t * vpath)
{
WPanel *panel;
char *curdir = NULL;
@ -4574,7 +4570,7 @@ panel_sized_with_dir_new (const char *panel_name, int y, int x, int lines, int c
const vfs_path_element_t *path_element;
#endif
panel = panel_sized_empty_new (panel_name, y, x, lines, cols);
panel = panel_sized_empty_new (panel_name, r);
if (vpath != NULL)
{

View File

@ -152,8 +152,8 @@ extern mc_fhl_t *mc_filehighlight;
/*** declarations of public functions ************************************************************/
WPanel *panel_sized_empty_new (const char *panel_name, int y, int x, int lines, int cols);
WPanel *panel_sized_with_dir_new (const char *panel_name, int y, int x, int lines, int cols,
WPanel *panel_sized_empty_new (const char *panel_name, const WRect * r);
WPanel *panel_sized_with_dir_new (const char *panel_name, const WRect * r,
const vfs_path_t * vpath);
void panel_clean_dir (WPanel * panel);
@ -217,7 +217,9 @@ static inline WPanel *
panel_empty_new (const char *panel_name)
{
/* Unknown sizes of the panel at startup */
return panel_sized_empty_new (panel_name, 0, 0, 1, 1);
WRect r = { 0, 0, 1, 1 };
return panel_sized_empty_new (panel_name, &r);
}
/* --------------------------------------------------------------------------------------------- */
@ -234,7 +236,9 @@ static inline WPanel *
panel_with_dir_new (const char *panel_name, const vfs_path_t * vpath)
{
/* Unknown sizes of the panel at startup */
return panel_sized_with_dir_new (panel_name, 0, 0, 1, 1, vpath);
WRect r = { 0, 0, 1, 1 };
return panel_sized_with_dir_new (panel_name, &r, vpath);
}
@ -258,18 +262,15 @@ panel_new (const char *panel_name)
* Panel creation with specified size.
*
* @param panel_name name of panel for setup retrieving
* @param y y coordinate of top-left corner
* @param x x coordinate of top-left corner
* @param lines vertical size
* @param cols horizontal size
* @param r panel area
*
* @return new instance of WPanel
*/
static inline WPanel *
panel_sized_new (const char *panel_name, int y, int x, int lines, int cols)
panel_sized_new (const char *panel_name, const WRect * r)
{
return panel_sized_with_dir_new (panel_name, y, x, lines, cols, NULL);
return panel_sized_with_dir_new (panel_name, r, NULL);
}
/* --------------------------------------------------------------------------------------------- */