mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Ticket 3948: can't create network link from panel...
other than file list (tree, quick view, info). Initial step: extend file panel creation API: * create an empty panel; * create panel with specified size. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
4b46e61947
commit
96520f48c3
@ -715,28 +715,12 @@ panel_listing_box (WPanel * panel, int num, char **userp, char **minip, gboolean
|
||||
int *brief_cols)
|
||||
{
|
||||
int result = -1;
|
||||
char *section = NULL;
|
||||
const char *p = NULL;
|
||||
|
||||
if (panel == NULL)
|
||||
{
|
||||
const char *p;
|
||||
size_t i;
|
||||
|
||||
p = get_nth_panel_name (num);
|
||||
panel = g_new (WPanel, 1);
|
||||
panel->list_format = list_full;
|
||||
panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
|
||||
panel->user_mini_status = FALSE;
|
||||
for (i = 0; i < LIST_FORMATS; i++)
|
||||
panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
|
||||
section = g_strconcat ("Temporal:", p, (char *) NULL);
|
||||
if (!mc_config_has_group (mc_global.main_config, section))
|
||||
{
|
||||
g_free (section);
|
||||
section = g_strdup (p);
|
||||
}
|
||||
panel_load_setup (panel, section);
|
||||
g_free (section);
|
||||
panel = panel_empty_new (p);
|
||||
}
|
||||
|
||||
{
|
||||
@ -817,7 +801,7 @@ panel_listing_box (WPanel * panel, int num, char **userp, char **minip, gboolean
|
||||
}
|
||||
}
|
||||
|
||||
if (section != NULL)
|
||||
if (p != NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -597,23 +597,23 @@ panel_do_cols (int idx)
|
||||
/** Save current list_view widget directory into panel */
|
||||
|
||||
static Widget *
|
||||
restore_into_right_dir_panel (int idx, Widget * from_widget)
|
||||
restore_into_right_dir_panel (int idx, gboolean last_was_panel, int y, int x, int lines, int cols)
|
||||
{
|
||||
WPanel *new_widget;
|
||||
const char *saved_dir = panels[idx].last_saved_dir;
|
||||
gboolean last_was_panel = (from_widget && get_display_type (idx) != view_listing);
|
||||
const char *p_name = get_nth_panel_name (idx);
|
||||
const char *p_name;
|
||||
|
||||
p_name = get_nth_panel_name (idx);
|
||||
|
||||
if (last_was_panel)
|
||||
{
|
||||
vfs_path_t *saved_dir_vpath;
|
||||
|
||||
saved_dir_vpath = vfs_path_from_str (saved_dir);
|
||||
new_widget = panel_new_with_dir (p_name, 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);
|
||||
vfs_path_free (saved_dir_vpath);
|
||||
}
|
||||
else
|
||||
new_widget = panel_new (p_name);
|
||||
new_widget = panel_sized_new (p_name, y, x, lines, cols);
|
||||
|
||||
return WIDGET (new_widget);
|
||||
}
|
||||
@ -1032,9 +1032,13 @@ set_display_type (int num, panel_view_mode_t type)
|
||||
{
|
||||
case view_nothing:
|
||||
case view_listing:
|
||||
new_widget = restore_into_right_dir_panel (num, old_widget);
|
||||
widget_set_size (new_widget, y, x, lines, cols);
|
||||
{
|
||||
gboolean last_was_panel;
|
||||
|
||||
last_was_panel = old_widget != NULL && get_display_type (num) != view_listing;
|
||||
new_widget = restore_into_right_dir_panel (num, last_was_panel, y, x, lines, cols);
|
||||
break;
|
||||
}
|
||||
|
||||
case view_info:
|
||||
new_widget = WIDGET (info_new (y, x, lines, cols));
|
||||
|
@ -4274,81 +4274,53 @@ panel_set_lwd (WPanel * panel, const vfs_path_t * vpath)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Panel creation for specified directory.
|
||||
* Creatie an empty panel with specified size.
|
||||
*
|
||||
* @param panel_name specifies the name of the panel for setup retieving
|
||||
* @param wpath the path of working panel directory. If path is NULL then panel will be created
|
||||
* for current directory
|
||||
* @param panel_name name of panel for setup retieving
|
||||
*
|
||||
* @return new instance of WPanel
|
||||
*/
|
||||
|
||||
WPanel *
|
||||
panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath)
|
||||
panel_sized_empty_new (const char *panel_name, int y, int x, int lines, int cols)
|
||||
{
|
||||
WPanel *panel;
|
||||
Widget *w;
|
||||
char *section;
|
||||
int i, err;
|
||||
char *curdir = NULL;
|
||||
|
||||
panel = g_new0 (WPanel, 1);
|
||||
w = WIDGET (panel);
|
||||
/* No know sizes of the panel at startup */
|
||||
widget_init (w, 0, 0, 0, 0, panel_callback, panel_mouse_callback);
|
||||
widget_init (w, y, x, lines, cols, panel_callback, panel_mouse_callback);
|
||||
w->options |= WOP_SELECTABLE | WOP_TOP_SELECT;
|
||||
|
||||
if (vpath != NULL)
|
||||
{
|
||||
curdir = _vfs_get_cwd ();
|
||||
panel_set_cwd (panel, vpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
vfs_setup_cwd ();
|
||||
panel->cwd_vpath = vfs_path_clone (vfs_get_raw_current_dir ());
|
||||
}
|
||||
|
||||
panel_set_lwd (panel, vfs_get_raw_current_dir ());
|
||||
|
||||
panel->hist_name = g_strconcat ("Dir Hist ", panel_name, (char *) NULL);
|
||||
/* directories history will be get later */
|
||||
|
||||
panel->dir.size = DIR_LIST_MIN_SIZE;
|
||||
panel->dir.list = g_new (file_entry_t, panel->dir.size);
|
||||
panel->dir.len = 0;
|
||||
panel->active = 0;
|
||||
panel->filter = NULL;
|
||||
|
||||
panel->list_cols = 1;
|
||||
panel->brief_cols = 2;
|
||||
panel->top_file = 0;
|
||||
panel->selected = 0;
|
||||
panel->marked = 0;
|
||||
panel->total = 0;
|
||||
panel->dirty = 1;
|
||||
panel->searching = FALSE;
|
||||
panel->dirs_marked = 0;
|
||||
panel->is_panelized = FALSE;
|
||||
panel->format = NULL;
|
||||
panel->status_format = NULL;
|
||||
panel->format_modified = 1;
|
||||
panel->content_shift = -1;
|
||||
panel->max_shift = -1;
|
||||
|
||||
panel->panel_name = g_strdup (panel_name);
|
||||
panel->list_format = list_full;
|
||||
panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
|
||||
|
||||
for (i = 0; i < LIST_FORMATS; i++)
|
||||
panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
panel->codepage = SELECT_CHARSET_NO_TRANSLATE;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < LIST_FORMATS; i++)
|
||||
panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
|
||||
|
||||
panel->search_buffer[0] = '\0';
|
||||
panel->prev_search_buffer[0] = '\0';
|
||||
panel->frame_size = frame_half;
|
||||
|
||||
panel->panel_name = g_strdup (panel_name);
|
||||
panel->hist_name = g_strconcat ("Dir Hist ", panel->panel_name, (char *) NULL);
|
||||
/* directories history will be get later */
|
||||
|
||||
section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);
|
||||
if (!mc_config_has_group (mc_global.main_config, section))
|
||||
{
|
||||
@ -4363,14 +4335,52 @@ panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath)
|
||||
if (err != 0)
|
||||
set_panel_formats (panel);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
{
|
||||
const vfs_path_element_t *path_element;
|
||||
return panel;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Panel creation for specified size and directory.
|
||||
*
|
||||
* @param panel_name name of panel for setup retieving
|
||||
* @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 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)
|
||||
{
|
||||
WPanel *panel;
|
||||
char *curdir = NULL;
|
||||
#ifdef HAVE_CHARSET
|
||||
const vfs_path_element_t *path_element;
|
||||
#endif
|
||||
|
||||
panel = panel_sized_empty_new (panel_name, y, x, lines, cols);
|
||||
|
||||
if (vpath != NULL)
|
||||
{
|
||||
curdir = _vfs_get_cwd ();
|
||||
panel_set_cwd (panel, vpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
vfs_setup_cwd ();
|
||||
panel->cwd_vpath = vfs_path_clone (vfs_get_raw_current_dir ());
|
||||
}
|
||||
|
||||
panel_set_lwd (panel, vfs_get_raw_current_dir ());
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
path_element = vfs_path_get_by_index (panel->cwd_vpath, -1);
|
||||
if (path_element->encoding != NULL)
|
||||
panel->codepage = get_codepage_index (path_element->encoding);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mc_chdir (panel->cwd_vpath) != 0)
|
||||
@ -4391,10 +4401,12 @@ panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath)
|
||||
if (curdir != NULL)
|
||||
{
|
||||
vfs_path_t *tmp_vpath;
|
||||
int err;
|
||||
|
||||
tmp_vpath = vfs_path_from_str (curdir);
|
||||
err = mc_chdir (tmp_vpath);
|
||||
vfs_path_free (tmp_vpath);
|
||||
(void) err;
|
||||
}
|
||||
g_free (curdir);
|
||||
|
||||
|
@ -153,7 +153,10 @@ extern mc_fhl_t *mc_filehighlight;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
WPanel *panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath);
|
||||
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,
|
||||
const vfs_path_t * vpath);
|
||||
|
||||
void panel_clean_dir (WPanel * panel);
|
||||
|
||||
void panel_reload (WPanel * panel);
|
||||
@ -195,11 +198,45 @@ gboolean do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** inline functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Empty panel creation.
|
||||
*
|
||||
* @param panel_name name of panel for setup retieving
|
||||
*
|
||||
* @return new instance of WPanel
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Panel creation for specified directory.
|
||||
*
|
||||
* @param panel_name name of panel for setup retieving
|
||||
* @param vpath working panel directory. If NULL then current directory is used
|
||||
*
|
||||
* @return new instance of WPanel
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Panel creation.
|
||||
*
|
||||
* @param panel_name the name of the panel for setup retieving
|
||||
* @param panel_name name of panel for setup retieving
|
||||
*
|
||||
* @return new instance of WPanel
|
||||
*/
|
||||
@ -207,7 +244,26 @@ gboolean do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
|
||||
static inline WPanel *
|
||||
panel_new (const char *panel_name)
|
||||
{
|
||||
return panel_new_with_dir (panel_name, NULL);
|
||||
return panel_with_dir_new (panel_name, NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Panel creation with specified size.
|
||||
*
|
||||
* @param panel_name name of panel for setup retieving
|
||||
* @param y y coordinate of top-left corner
|
||||
* @param x x coordinate of top-left corner
|
||||
* @param lines vertical size
|
||||
* @param cols horizontal size
|
||||
*
|
||||
* @return new instance of WPanel
|
||||
*/
|
||||
|
||||
static inline WPanel *
|
||||
panel_sized_new (const char *panel_name, int y, int x, int lines, int cols)
|
||||
{
|
||||
return panel_sized_with_dir_new (panel_name, y, x, lines, cols, NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user