mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Merge branch '275_panelization_fixes'
* 275_panelization_fixes: Minor optimization in file list creation. Show the relative filename path in the panel Changed type of the WPanel::is_panelized member from int to gboolean. Fixes segfault after switch panel mode Ticket #275: panelization fixes.
This commit is contained in:
commit
f1eacfbf32
@ -83,6 +83,7 @@
|
||||
#include "file.h" /* file operation routines */
|
||||
#include "find.h" /* find_file() */
|
||||
#include "hotlist.h" /* hotlist_show() */
|
||||
#include "panel.h" /* WPanel */
|
||||
#include "tree.h" /* tree_chdir() */
|
||||
#include "midnight.h" /* change_panel() */
|
||||
#include "usermenu.h" /* MC_GLOBAL_MENU */
|
||||
@ -581,6 +582,17 @@ switch_to_listing (int panel_index)
|
||||
{
|
||||
if (get_display_type (panel_index) != view_listing)
|
||||
set_display_type (panel_index, view_listing);
|
||||
else
|
||||
{
|
||||
WPanel *p;
|
||||
|
||||
p = (WPanel *) get_panel_widget (panel_index);
|
||||
if (p->is_panelized)
|
||||
{
|
||||
p->is_panelized = FALSE;
|
||||
panel_reload (p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -458,7 +458,7 @@ set_zero_dir (dir_list * list)
|
||||
|
||||
memset (&(list->list)[0], 0, sizeof (file_entry));
|
||||
list->list[0].fnamelen = 2;
|
||||
list->list[0].fname = g_strdup ("..");
|
||||
list->list[0].fname = g_strndup ("..", list->list[0].fnamelen);
|
||||
list->list[0].f.link_to_dir = 0;
|
||||
list->list[0].f.stale_link = 0;
|
||||
list->list[0].f.dir_size_computed = 0;
|
||||
@ -558,7 +558,7 @@ do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_rever
|
||||
return next_free;
|
||||
}
|
||||
list->list[next_free].fnamelen = NLENGTH (dp);
|
||||
list->list[next_free].fname = g_strdup (dp->d_name);
|
||||
list->list[next_free].fname = g_strndup (dp->d_name, list->list[next_free].fnamelen);
|
||||
list->list[next_free].f.marked = 0;
|
||||
list->list[next_free].f.link_to_dir = link_to_dir;
|
||||
list->list[next_free].f.stale_link = stale_link;
|
||||
@ -693,7 +693,7 @@ do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count,
|
||||
}
|
||||
|
||||
list->list[next_free].fnamelen = NLENGTH (dp);
|
||||
list->list[next_free].fname = g_strdup (dp->d_name);
|
||||
list->list[next_free].fname = g_strndup (dp->d_name, list->list[next_free].fnamelen);
|
||||
list->list[next_free].f.link_to_dir = link_to_dir;
|
||||
list->list[next_free].f.stale_link = stale_link;
|
||||
list->list[next_free].f.dir_size_computed = 0;
|
||||
|
@ -1664,7 +1664,7 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
|
||||
if (next_free == 0) /* first turn i.e clean old list */
|
||||
panel_clean_dir (current_panel);
|
||||
list->list[next_free].fnamelen = strlen (p);
|
||||
list->list[next_free].fname = g_strdup (p);
|
||||
list->list[next_free].fname = g_strndup (p, list->list[next_free].fnamelen);
|
||||
list->list[next_free].f.marked = 0;
|
||||
list->list[next_free].f.link_to_dir = link_to_dir;
|
||||
list->list[next_free].f.stale_link = stale_link;
|
||||
@ -1681,7 +1681,7 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
|
||||
if (next_free)
|
||||
{
|
||||
current_panel->count = next_free;
|
||||
current_panel->is_panelized = 1;
|
||||
current_panel->is_panelized = TRUE;
|
||||
|
||||
/* absolute path */
|
||||
if (start_dir_len < 0)
|
||||
|
@ -3403,7 +3403,7 @@ update_one_panel_widget (WPanel * panel, panel_update_flags_t flags, const char
|
||||
|
||||
if ((flags & UP_RELOAD) != 0)
|
||||
{
|
||||
panel->is_panelized = 0;
|
||||
panel->is_panelized = FALSE;
|
||||
mc_setctl (panel->cwd, VFS_SETCTL_FLUSH, 0);
|
||||
memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
|
||||
}
|
||||
@ -3637,7 +3637,7 @@ panel_clean_dir (WPanel * panel)
|
||||
panel->dirs_marked = 0;
|
||||
panel->total = 0;
|
||||
panel->searching = FALSE;
|
||||
panel->is_panelized = 0;
|
||||
panel->is_panelized = FALSE;
|
||||
panel->dirty = 1;
|
||||
|
||||
clean_dir (&panel->dir, count);
|
||||
@ -3703,7 +3703,7 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
|
||||
panel->dirty = 1;
|
||||
panel->searching = FALSE;
|
||||
panel->dirs_marked = 0;
|
||||
panel->is_panelized = 0;
|
||||
panel->is_panelized = FALSE;
|
||||
panel->format = 0;
|
||||
panel->status_format = 0;
|
||||
panel->format_modified = 1;
|
||||
|
@ -108,7 +108,7 @@ typedef struct WPanel
|
||||
int top_file; /* The file showed on the top of the panel */
|
||||
int selected; /* Index to the selected file */
|
||||
int split; /* Split panel to allow two columns */
|
||||
int is_panelized; /* Flag: special filelisting, can't reload */
|
||||
gboolean is_panelized; /* Flag: special filelisting, can't reload */
|
||||
panel_display_t frame_size; /* half or full frame */
|
||||
char *filter; /* File name filter */
|
||||
panel_sort_info_t sort_info; /* Sort descriptor */
|
||||
|
@ -52,6 +52,7 @@
|
||||
|
||||
#include "dir.h"
|
||||
#include "midnight.h" /* current_panel */
|
||||
#include "panel.h" /* WPanel */
|
||||
|
||||
#include "panelize.h"
|
||||
|
||||
@ -366,7 +367,7 @@ do_external_panelize (char *command)
|
||||
if (status == -1)
|
||||
break;
|
||||
list->list[next_free].fnamelen = strlen (name);
|
||||
list->list[next_free].fname = g_strdup (name);
|
||||
list->list[next_free].fname = g_strndup (name, list->list[next_free].fnamelen);
|
||||
file_mark (current_panel, next_free, 0);
|
||||
list->list[next_free].f.link_to_dir = link_to_dir;
|
||||
list->list[next_free].f.stale_link = stale_link;
|
||||
@ -379,7 +380,7 @@ do_external_panelize (char *command)
|
||||
rotate_dash ();
|
||||
}
|
||||
|
||||
current_panel->is_panelized = 1;
|
||||
current_panel->is_panelized = TRUE;
|
||||
if (next_free)
|
||||
{
|
||||
current_panel->count = next_free;
|
||||
@ -408,6 +409,7 @@ do_panelize_cd (struct WPanel *panel)
|
||||
{
|
||||
int i;
|
||||
dir_list *list = &panel->dir;
|
||||
gboolean panelized_same;
|
||||
|
||||
clean_dir (list, panel->count);
|
||||
if (panelized_panel.root[0] == '\0')
|
||||
@ -420,16 +422,32 @@ do_panelize_cd (struct WPanel *panel)
|
||||
}
|
||||
else if (panelized_panel.count >= list->size)
|
||||
{
|
||||
list->list = g_try_realloc (list->list, sizeof (file_entry) * (panelized_panel.count));
|
||||
list->list = g_try_realloc (list->list, sizeof (file_entry) * panelized_panel.count);
|
||||
list->size = panelized_panel.count;
|
||||
}
|
||||
panel->count = panelized_panel.count;
|
||||
panel->is_panelized = 1;
|
||||
panel->is_panelized = TRUE;
|
||||
|
||||
panelized_same = (strcmp (panelized_panel.root, panel->cwd) == 0);
|
||||
|
||||
for (i = 0; i < panelized_panel.count; i++)
|
||||
{
|
||||
list->list[i].fnamelen = panelized_panel.list.list[i].fnamelen;
|
||||
list->list[i].fname = g_strdup (panelized_panel.list.list[i].fname);
|
||||
if (panelized_same
|
||||
|| (panelized_panel.list.list[i].fname[0] == '.'
|
||||
&& panelized_panel.list.list[i].fname[1] == '.'
|
||||
&& panelized_panel.list.list[i].fname[2] == '\0'))
|
||||
{
|
||||
list->list[i].fnamelen = panelized_panel.list.list[i].fnamelen;
|
||||
list->list[i].fname = g_strndup (panelized_panel.list.list[i].fname,
|
||||
panelized_panel.list.list[i].fnamelen);
|
||||
}
|
||||
else
|
||||
{
|
||||
list->list[i].fname = mc_build_filename (panelized_panel.root,
|
||||
panelized_panel.list.list[i].fname,
|
||||
(char *) NULL);
|
||||
list->list[i].fnamelen = strlen (list->list[i].fname);
|
||||
}
|
||||
list->list[i].f.link_to_dir = panelized_panel.list.list[i].f.link_to_dir;
|
||||
list->list[i].f.stale_link = panelized_panel.list.list[i].f.stale_link;
|
||||
list->list[i].f.dir_size_computed = panelized_panel.list.list[i].f.dir_size_computed;
|
||||
@ -462,13 +480,13 @@ panelize_save_panel (struct WPanel *panel)
|
||||
if (panel->count >= panelized_panel.list.size)
|
||||
{
|
||||
panelized_panel.list.list = g_try_realloc (panelized_panel.list.list,
|
||||
sizeof (file_entry) * panel->count);
|
||||
sizeof (file_entry) * panel->count);
|
||||
panelized_panel.list.size = panel->count;
|
||||
}
|
||||
for (i = 0; i < panel->count; i++)
|
||||
{
|
||||
panelized_panel.list.list[i].fnamelen = list->list[i].fnamelen;
|
||||
panelized_panel.list.list[i].fname = g_strdup (list->list[i].fname);
|
||||
panelized_panel.list.list[i].fname = g_strndup (list->list[i].fname, list->list[i].fnamelen);
|
||||
panelized_panel.list.list[i].f.link_to_dir = list->list[i].f.link_to_dir;
|
||||
panelized_panel.list.list[i].f.stale_link = list->list[i].f.stale_link;
|
||||
panelized_panel.list.list[i].f.dir_size_computed = list->list[i].f.dir_size_computed;
|
||||
@ -484,9 +502,10 @@ panelize_save_panel (struct WPanel *panel)
|
||||
void
|
||||
cd_panelize_cmd (void)
|
||||
{
|
||||
WPanel *panel = MENU_PANEL_IDX == 0 ? left_panel : right_panel;
|
||||
if (get_display_type (MENU_PANEL_IDX) != view_listing)
|
||||
set_display_type (MENU_PANEL_IDX, view_listing);
|
||||
|
||||
do_panelize_cd (panel);
|
||||
do_panelize_cd ((struct WPanel *) get_panel_widget (MENU_PANEL_IDX));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
struct WPanel;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user