Ticket #1918: viewer in QuickView mode corrupts screen.

Initial step: code refactoring:
  * small code formatting;
  * type accuracy;
  * introduce new type 'panel_view_mode_t' for panel type.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-12-31 21:46:02 +03:00
parent bea2fff1fd
commit 1055b85072
10 changed files with 127 additions and 146 deletions

View File

@ -218,13 +218,14 @@ display_init (int radio_sel, char *init_text, int _check_status,
return dd; return dd;
} }
/* return list type */
int int
display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int num) display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int num)
{ {
int result = -1; int result = -1;
Dlg_head *dd; Dlg_head *dd;
char *section = NULL; char *section = NULL;
int i; size_t i;
if (panel == NULL) { if (panel == NULL) {
const char *p = get_nth_panel_name (num); const char *p = get_nth_panel_name (num);

View File

@ -869,8 +869,8 @@ compare_dirs_cmd (void)
if (choice < 0 || choice > 2) if (choice < 0 || choice > 2)
return; return;
else
thorough_flag = choice; thorough_flag = choice;
if (get_current_type () == view_listing if (get_current_type () == view_listing
&& get_other_type () == view_listing) { && get_other_type () == view_listing) {
@ -1311,21 +1311,20 @@ save_setup_cmd (void)
} }
static void static void
configure_panel_listing (WPanel *p, int view_type, int use_msformat, char *user, char *status) configure_panel_listing (WPanel *p, int list_type, int use_msformat, char *user, char *status)
{ {
p->user_mini_status = use_msformat; p->user_mini_status = use_msformat;
p->list_type = view_type; p->list_type = list_type;
if (view_type == list_user || use_msformat){ if (list_type == list_user || use_msformat) {
g_free (p->user_format); g_free (p->user_format);
p->user_format = user; p->user_format = user;
g_free (p->user_status_format [view_type]); g_free (p->user_status_format [list_type]);
p->user_status_format [view_type] = status; p->user_status_format [list_type] = status;
set_panel_formats (p); set_panel_formats (p);
} } else {
else {
g_free (user); g_free (user);
g_free (status); g_free (status);
} }
@ -1366,27 +1365,21 @@ switch_to_listing (int panel_index)
void void
listing_cmd (void) listing_cmd (void)
{ {
int view_type, use_msformat; int list_type;
int use_msformat;
char *user, *status; char *user, *status;
WPanel *p; WPanel *p = NULL;
int display_type;
display_type = get_display_type (MENU_PANEL_IDX); if (get_display_type (MENU_PANEL_IDX) == view_listing)
if (display_type == view_listing)
p = MENU_PANEL_IDX == 0 ? left_panel : right_panel; p = MENU_PANEL_IDX == 0 ? left_panel : right_panel;
else
p = 0;
view_type = display_box (p, &user, &status, &use_msformat, MENU_PANEL_IDX); list_type = display_box (p, &user, &status, &use_msformat, MENU_PANEL_IDX);
if (view_type == -1) if (list_type != -1) {
return; switch_to_listing (MENU_PANEL_IDX);
p = MENU_PANEL_IDX == 0 ? left_panel : right_panel;
switch_to_listing (MENU_PANEL_IDX); configure_panel_listing (p, list_type, use_msformat, user, status);
}
p = MENU_PANEL_IDX == 0 ? left_panel : right_panel;
configure_panel_listing (p, view_type, use_msformat, user, status);
} }
void void
@ -1410,18 +1403,21 @@ quick_view_cmd (void)
} }
/* Handle the tree internal listing modes switching */ /* Handle the tree internal listing modes switching */
static int static gboolean
set_basic_panel_listing_to (int panel_index, int listing_mode) set_basic_panel_listing_to (int panel_index, int listing_mode)
{ {
WPanel *p = (WPanel *) get_panel_widget (panel_index); WPanel *p = (WPanel *) get_panel_widget (panel_index);
gboolean ok;
switch_to_listing (panel_index); switch_to_listing (panel_index);
p->list_type = listing_mode; p->list_type = listing_mode;
if (set_panel_formats (p))
return 0;
do_refresh (); ok = set_panel_formats (p) == 0;
return 1;
if (ok)
do_refresh ();
return ok;
} }
void void

View File

@ -1818,8 +1818,7 @@ end_bg_process (FileOpContext *ctx, enum OperationMode mode) {
* default destination. Current filename is used as default. * default destination. Current filename is used as default.
*/ */
int int
panel_operate (void *source_panel, FileOperation operation, panel_operate (void *source_panel, FileOperation operation, int force_single)
int force_single)
{ {
WPanel *panel = (WPanel *) source_panel; WPanel *panel = (WPanel *) source_panel;
const gboolean single_entry = force_single || (panel->marked <= 1) const gboolean single_entry = force_single || (panel->marked <= 1)

View File

@ -119,7 +119,7 @@ int output_start_y = 0;
#define MAX_VIEWS 2 #define MAX_VIEWS 2
static struct { static struct {
int type; panel_view_mode_t type;
Widget *widget; Widget *widget;
char *last_saved_dir; /* last view_list working directory */ char *last_saved_dir; /* last view_list working directory */
} panels [MAX_VIEWS] = { } panels [MAX_VIEWS] = {
@ -609,9 +609,8 @@ panel_do_cols (int lc_index)
{ {
if (get_display_type (lc_index) == view_listing) if (get_display_type (lc_index) == view_listing)
set_panel_formats ((WPanel *) panels [lc_index].widget); set_panel_formats ((WPanel *) panels [lc_index].widget);
else { else
panel_update_cols (panels [lc_index].widget, frame_half); panel_update_cols (panels [lc_index].widget, frame_half);
}
} }
void void
@ -865,7 +864,7 @@ const char *get_nth_panel_name (int num)
/* This routine also keeps at least one WPanel object in the screen */ /* This routine also keeps at least one WPanel object in the screen */
/* since a lot of routines depend on the current_panel variable */ /* since a lot of routines depend on the current_panel variable */
void void
set_display_type (int num, int type) set_display_type (int num, panel_view_mode_t type)
{ {
int x = 0, y = 0, cols = 0, lines = 0; int x = 0, y = 0, cols = 0, lines = 0;
int the_other = 0; /* Index to the other panel */ int the_other = 0; /* Index to the other panel */
@ -878,7 +877,7 @@ set_display_type (int num, int type)
abort (); abort ();
} }
/* Check that we will have a WPanel * at least */ /* Check that we will have a WPanel * at least */
if (type != view_listing){ if (type != view_listing) {
the_other = num == 0 ? 1 : 0; the_other = num == 0 ? 1 : 0;
if (panels [the_other].type != view_listing) if (panels [the_other].type != view_listing)
@ -886,7 +885,7 @@ set_display_type (int num, int type)
} }
/* Get rid of it */ /* Get rid of it */
if (panels [num].widget){ if (panels [num].widget) {
Widget *w = panels [num].widget; Widget *w = panels [num].widget;
WPanel *panel = (WPanel *) panels [num].widget; WPanel *panel = (WPanel *) panels [num].widget;
@ -896,8 +895,8 @@ set_display_type (int num, int type)
lines = w->lines; lines = w->lines;
old_widget = panels [num].widget; old_widget = panels [num].widget;
if (panels [num].type == view_listing){ if (panels [num].type == view_listing) {
if (panel->frame_size == frame_full && type != view_listing){ if (panel->frame_size == frame_full && type != view_listing) {
cols = COLS - first_panel_size; cols = COLS - first_panel_size;
if (num == 1) if (num == 1)
x = first_panel_size; x = first_panel_size;
@ -908,14 +907,14 @@ set_display_type (int num, int type)
/* Restoring saved path from panels.ini for nonlist panel */ /* Restoring saved path from panels.ini for nonlist panel */
/* when it's first creation (for example view_info) */ /* when it's first creation (for example view_info) */
if (old_widget == NULL && type != view_listing) { if (old_widget == NULL && type != view_listing) {
char panel_dir[MC_MAXPATHLEN]; char panel_dir [MC_MAXPATHLEN];
mc_get_current_wd (panel_dir, sizeof (panel_dir)); mc_get_current_wd (panel_dir, sizeof (panel_dir));
panels[num].last_saved_dir = g_strdup (panel_dir); panels[num].last_saved_dir = g_strdup (panel_dir);
} }
switch (type){ switch (type) {
case view_listing: case view_listing:
new_widget = restore_into_right_dir_panel(num, old_widget); new_widget = restore_into_right_dir_panel (num, old_widget);
break; break;
case view_info: case view_info:
@ -930,8 +929,7 @@ set_display_type (int num, int type)
new_widget = (Widget *) mcview_new (0, 0, 0, 0, 1); new_widget = (Widget *) mcview_new (0, 0, 0, 0, 1);
the_other_panel = (WPanel *) panels [the_other].widget; the_other_panel = (WPanel *) panels [the_other].widget;
if (the_other_panel) if (the_other_panel)
file_name = file_name = the_other_panel->dir.list[the_other_panel->selected].fname;
the_other_panel->dir.list[the_other_panel->selected].fname;
else else
file_name = ""; file_name = "";
@ -942,7 +940,7 @@ set_display_type (int num, int type)
if (type != view_listing) if (type != view_listing)
/* Must save dir, for restoring after change type to */ /* Must save dir, for restoring after change type to */
/* view_listing */ /* view_listing */
save_panel_dir(num); save_panel_dir (num);
panels [num].type = type; panels [num].type = type;
panels [num].widget = new_widget; panels [num].widget = new_widget;
@ -952,10 +950,10 @@ set_display_type (int num, int type)
/* We use replace to keep the circular list of the dialog in the */ /* We use replace to keep the circular list of the dialog in the */
/* same state. Maybe we could just kill it and then replace it */ /* same state. Maybe we could just kill it and then replace it */
if (midnight_dlg && old_widget){ if ((midnight_dlg != NULL) && (old_widget != NULL))
dlg_replace_widget (old_widget, panels [num].widget); dlg_replace_widget (old_widget, panels [num].widget);
}
if (type == view_listing){ if (type == view_listing) {
if (num == 0) if (num == 0)
left_panel = (WPanel *) new_widget; left_panel = (WPanel *) new_widget;
else else
@ -974,8 +972,8 @@ set_display_type (int num, int type)
* current_panel causes segfault, e.g. C-Enter, C-x c, ... * current_panel causes segfault, e.g. C-Enter, C-x c, ...
*/ */
if (type != view_listing) if ((type != view_listing)
if (current_panel == (WPanel *) old_widget) && (current_panel == (WPanel *) old_widget))
current_panel = num == 0 ? right_panel : left_panel; current_panel = num == 0 ? right_panel : left_panel;
} }
@ -989,7 +987,7 @@ void swap_panels ()
WPanel panel; WPanel panel;
WPanel *panel1, *panel2; WPanel *panel1, *panel2;
int tmp_type; int tmp_type;
#define panelswap(x) panel. x = panel1-> x; panel1-> x = panel2-> x; panel2-> x = panel. x; #define panelswap(x) panel. x = panel1-> x; panel1-> x = panel2-> x; panel2-> x = panel. x;
#define panelswapstr(e) strcpy (panel. e, panel1-> e); \ #define panelswapstr(e) strcpy (panel. e, panel1-> e); \
@ -1011,7 +1009,7 @@ void swap_panels ()
panelswap (selected); panelswap (selected);
panelswap (is_panelized); panelswap (is_panelized);
panelswap (dir_stat); panelswap (dir_stat);
panel1->searching = 0; panel1->searching = 0;
panel2->searching = 0; panel2->searching = 0;
if (current_panel == panel1) if (current_panel == panel1)
@ -1026,9 +1024,9 @@ void swap_panels ()
} else { } else {
WPanel *tmp_panel; WPanel *tmp_panel;
tmp_panel=right_panel; tmp_panel = right_panel;
right_panel=left_panel; right_panel = left_panel;
left_panel=tmp_panel; left_panel = tmp_panel;
if (panels [0].type == view_listing) { if (panels [0].type == view_listing) {
if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) { if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) {
@ -1042,7 +1040,7 @@ void swap_panels ()
panel2->panel_name = g_strdup (get_nth_panel_name (0)); panel2->panel_name = g_strdup (get_nth_panel_name (0));
} }
} }
tmp.x = panels [0].widget->x; tmp.x = panels [0].widget->x;
tmp.y = panels [0].widget->y; tmp.y = panels [0].widget->y;
tmp.cols = panels [0].widget->cols; tmp.cols = panels [0].widget->cols;
@ -1057,7 +1055,7 @@ void swap_panels ()
panels [1].widget->y = tmp.y; panels [1].widget->y = tmp.y;
panels [1].widget->cols = tmp.cols; panels [1].widget->cols = tmp.cols;
panels [1].widget->lines = tmp.lines; panels [1].widget->lines = tmp.lines;
tmp_widget = panels [0].widget; tmp_widget = panels [0].widget;
panels [0].widget = panels [1].widget; panels [0].widget = panels [1].widget;
panels [1].widget = tmp_widget; panels [1].widget = tmp_widget;
@ -1067,7 +1065,8 @@ void swap_panels ()
} }
} }
int get_display_type (int lc_index) panel_view_mode_t
get_display_type (int lc_index)
{ {
return panels [lc_index].type; return panels [lc_index].type;
} }
@ -1098,7 +1097,8 @@ get_other_panel (void)
} }
/* Returns the view type for the current panel/view */ /* Returns the view type for the current panel/view */
int get_current_type (void) panel_view_mode_t
get_current_type (void)
{ {
if (panels [0].widget == (Widget *) current_panel) if (panels [0].widget == (Widget *) current_panel)
return panels [0].type; return panels [0].type;
@ -1107,7 +1107,8 @@ int get_current_type (void)
} }
/* Returns the view type of the unselected panel */ /* Returns the view type of the unselected panel */
int get_other_type (void) panel_view_mode_t
get_other_type (void)
{ {
if (panels [0].widget == (Widget *) current_panel) if (panels [0].widget == (Widget *) current_panel)
return panels [1].type; return panels [1].type;
@ -1119,7 +1120,7 @@ int get_other_type (void)
void void
save_panel_dir (int lc_index) save_panel_dir (int lc_index)
{ {
int type = get_display_type (lc_index); panel_view_mode_t type = get_display_type (lc_index);
Widget *widget = get_panel_widget (lc_index); Widget *widget = get_panel_widget (lc_index);
if ((type == view_listing) && (widget != NULL)) { if ((type == view_listing) && (widget != NULL)) {
@ -1136,7 +1137,7 @@ save_panel_dir (int lc_index)
Widget * Widget *
restore_into_right_dir_panel (int lc_index, Widget *from_widget) restore_into_right_dir_panel (int lc_index, Widget *from_widget)
{ {
Widget *new_widget = 0; Widget *new_widget = NULL;
const char *saved_dir = panels [lc_index].last_saved_dir; const char *saved_dir = panels [lc_index].last_saved_dir;
gboolean last_was_panel = (from_widget && gboolean last_was_panel = (from_widget &&
get_display_type(lc_index) != view_listing); get_display_type(lc_index) != view_listing);

View File

@ -14,11 +14,11 @@ void setup_panels (void);
void destroy_panels (void); void destroy_panels (void);
void sigwinch_handler (int dummy); void sigwinch_handler (int dummy);
void change_screen_size (void); void change_screen_size (void);
void set_display_type (int num, int type); void set_display_type (int num, panel_view_mode_t type);
void swap_panels (void); void swap_panels (void);
int get_display_type (int index); panel_view_mode_t get_display_type (int index);
int get_current_type (void); panel_view_mode_t get_current_type (void);
int get_other_type (void); panel_view_mode_t get_other_type (void);
int get_current_index (void); int get_current_index (void);
int get_other_index (void); int get_other_index (void);
const char *get_nth_panel_name (int num); const char *get_nth_panel_name (int num);

View File

@ -925,8 +925,7 @@ create_panels (void)
{ {
int current_index; int current_index;
int other_index; int other_index;
int current_mode; panel_view_mode_t current_mode, other_mode;
int other_mode;
char original_dir[1024]; char original_dir[1024];
original_dir[0] = 0; original_dir[0] = 0;
@ -1049,9 +1048,8 @@ copy_current_readlink (void)
static void static void
copy_other_readlink (void) copy_other_readlink (void)
{ {
if (get_other_type () != view_listing) if (get_other_type () == view_listing)
return; copy_readlink (other_panel);
copy_readlink (other_panel);
} }
/* Insert the selected file name into the input line */ /* Insert the selected file name into the input line */
@ -1100,9 +1098,8 @@ copy_current_tagged (void)
static void static void
copy_other_tagged (void) copy_other_tagged (void)
{ {
if (get_other_type () != view_listing) if (get_other_type () == view_listing)
return; copy_tagged (other_panel);
copy_tagged (other_panel);
} }
void void

View File

@ -23,13 +23,13 @@ enum list_types {
list_user /* User defined */ list_user /* User defined */
}; };
enum view_modes { typedef enum {
view_listing, /* Directory listing */ view_listing = 0, /* Directory listing */
view_info, /* Information panel */ view_info = 1, /* Information panel */
view_tree, /* Tree view */ view_tree = 2, /* Tree view */
view_quick, /* Quick view */ view_quick = 3, /* Quick view */
view_nothing /* Undefined */ view_nothing = 4, /* Undefined */
}; } panel_view_mode_t;
enum panel_display_enum { enum panel_display_enum {
frame_full, /* full screen frame */ frame_full, /* full screen frame */

View File

@ -140,11 +140,9 @@ set_colors (WPanel *panel)
static void static void
delete_format (format_e *format) delete_format (format_e *format)
{ {
format_e *next; while (format != NULL) {
format_e *next = format->next;
while (format){ g_free (format->title);
next = format->next;
g_free(format->title);
g_free (format); g_free (format);
format = next; format = next;
} }
@ -1182,7 +1180,7 @@ panel_clean_dir (WPanel *panel)
static void static void
panel_destroy (WPanel *p) panel_destroy (WPanel *p)
{ {
int i; size_t i;
char *name = panel_save_name (p); char *name = panel_save_name (p);
@ -1293,11 +1291,9 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
/* Load format strings */ /* Load format strings */
err = set_panel_formats (panel); err = set_panel_formats (panel);
if (err) { if (err != 0)
set_panel_formats (panel); set_panel_formats (panel);
}
/* Because do_load_dir lists files in current directory */ /* Because do_load_dir lists files in current directory */
if (wpath) if (wpath)
mc_chdir(wpath); mc_chdir(wpath);
@ -1701,34 +1697,27 @@ int
set_panel_formats (WPanel *p) set_panel_formats (WPanel *p)
{ {
format_e *form; format_e *form;
char *err; char *err = NULL;
int retcode = 0; int retcode = 0;
form = use_display_format (p, panel_format (p), &err, 0); form = use_display_format (p, panel_format (p), &err, 0);
if (err){ if (err != NULL) {
g_free (err); g_free (err);
retcode = 1; retcode = 1;
} } else {
else { delete_format (p->format);
if (p->format) p->format = form;
delete_format (p->format);
p->format = form;
} }
if (show_mini_info){ if (show_mini_info) {
form = use_display_format (p, mini_status_format (p), &err, 1); form = use_display_format (p, mini_status_format (p), &err, 1);
if (err){ if (err != NULL) {
g_free (err); g_free (err);
retcode += 2; retcode += 2;
} } else {
else { delete_format (p->status_format);
if (p->status_format)
delete_format (p->status_format);
p->status_format = form; p->status_format = form;
} }
} }
@ -1737,14 +1726,14 @@ set_panel_formats (WPanel *p)
panel_update_cols (&(p->widget), p->frame_size); panel_update_cols (&(p->widget), p->frame_size);
if (retcode) if (retcode)
message (D_ERROR, _("Warning" ), _( "User supplied format looks invalid, reverting to default." ) ); message (D_ERROR, _("Warning" ), _( "User supplied format looks invalid, reverting to default." ) );
if (retcode & 0x01){ if (retcode & 0x01){
g_free (p->user_format); g_free (p->user_format);
p->user_format = g_strdup (DEFAULT_USER_FORMAT); p->user_format = g_strdup (DEFAULT_USER_FORMAT);
} }
if (retcode & 0x02){ if (retcode & 0x02){
g_free (p->user_status_format [p->list_type]); g_free (p->user_status_format [p->list_type]);
p->user_status_format [p->list_type] = g_strdup (DEFAULT_USER_FORMAT); p->user_status_format [p->list_type] = g_strdup (DEFAULT_USER_FORMAT);
} }
return retcode; return retcode;
@ -3257,13 +3246,11 @@ update_one_panel_widget (WPanel *panel, int force_update,
static void static void
update_one_panel (int which, int force_update, const char *current_file) update_one_panel (int which, int force_update, const char *current_file)
{ {
WPanel *panel; if (get_display_type (which) == view_listing) {
WPanel *panel;
if (get_display_type (which) != view_listing) panel = (WPanel *) get_panel_widget (which);
return; update_one_panel_widget (panel, force_update, current_file);
}
panel = (WPanel *) get_panel_widget (which);
update_one_panel_widget (panel, force_update, current_file);
} }
/* This routine reloads the directory in both panels. It tries to /* This routine reloads the directory in both panels. It tries to

View File

@ -82,8 +82,8 @@ char *setup_color_string;
char *term_color_string; char *term_color_string;
char *color_terminal_string; char *color_terminal_string;
int startup_left_mode; panel_view_mode_t startup_left_mode;
int startup_right_mode; panel_view_mode_t startup_right_mode;
/* Ugly hack to allow panel_save_setup to work as a place holder for */ /* Ugly hack to allow panel_save_setup to work as a place holder for */
/* default panel values */ /* default panel values */
@ -105,13 +105,13 @@ static const struct {
static const struct { static const struct {
const char *opt_name; const char *opt_name;
int opt_type; panel_view_mode_t opt_type;
} panel_types [] = { } panel_types [] = {
{ "listing", view_listing }, { "listing", view_listing },
{ "quickview", view_quick }, { "quickview", view_quick },
{ "info", view_info }, { "info", view_info },
{ "tree", view_tree }, { "tree", view_tree },
{ 0, 0 } { NULL, view_listing }
}; };
static const struct { static const struct {
@ -248,7 +248,7 @@ void
panel_save_setup (struct WPanel *panel, const char *section) panel_save_setup (struct WPanel *panel, const char *section)
{ {
char *buffer; char *buffer;
int i; size_t i;
mc_config_set_int(mc_panels_config, section, "reverse", panel->reverse); mc_config_set_int(mc_panels_config, section, "reverse", panel->reverse);
mc_config_set_int(mc_panels_config, section, "case_sensitive", panel->case_sensitive); mc_config_set_int(mc_panels_config, section, "case_sensitive", panel->case_sensitive);
@ -315,14 +315,14 @@ save_configure (void)
} }
static void static void
panel_save_type (const char *section, int type) panel_save_type (const char *section, panel_view_mode_t type)
{ {
int i; int i;
for (i = 0; panel_types [i].opt_name; i++) for (i = 0; panel_types [i].opt_name != NULL; i++)
if (panel_types [i].opt_type == type){ if (panel_types [i].opt_type == type) {
mc_config_set_string(mc_panels_config, section, mc_config_set_string (mc_panels_config, section,
"display", panel_types [i].opt_name); "display", panel_types [i].opt_name);
break; break;
} }
} }
@ -330,9 +330,10 @@ panel_save_type (const char *section, int type)
void void
save_panel_types (void) save_panel_types (void)
{ {
int type; panel_view_mode_t type;
if (! mc_config_get_int(mc_main_config,CONFIG_APP_SECTION,"auto_save_setup_panels",auto_save_setup)) if (!mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
"auto_save_setup_panels", auto_save_setup))
return; return;
type = get_display_type (0); type = get_display_type (0);
@ -352,7 +353,7 @@ save_panel_types (void)
get_current_index () == 0 ? "1" : "0"); get_current_index () == 0 ? "1" : "0");
if (mc_panels_config->ini_path == NULL) if (mc_panels_config->ini_path == NULL)
mc_panels_config->ini_path = g_strdup(panels_profile_name); mc_panels_config->ini_path = g_strdup (panels_profile_name);
mc_config_del_group (mc_panels_config, "Temporal:New Left Panel"); mc_config_del_group (mc_panels_config, "Temporal:New Left Panel");
mc_config_del_group (mc_panels_config, "Temporal:New Right Panel"); mc_config_del_group (mc_panels_config, "Temporal:New Right Panel");
@ -403,7 +404,7 @@ save_setup (void)
void void
panel_load_setup (WPanel *panel, const char *section) panel_load_setup (WPanel *panel, const char *section)
{ {
int i; size_t i;
char *buffer; char *buffer;
panel->reverse = mc_config_get_int(mc_panels_config, section, "reverse", 0); panel->reverse = mc_config_get_int(mc_panels_config, section, "reverse", 0);
@ -455,23 +456,22 @@ load_layout ()
mc_config_get_int(mc_main_config,"Layout", layout [i].opt_name, *layout [i].opt_addr); mc_config_get_int(mc_main_config,"Layout", layout [i].opt_name, *layout [i].opt_addr);
} }
static int static panel_view_mode_t
setup__load_panel_state (const char *section) setup__load_panel_state (const char *section)
{ {
char *buffer; char *buffer;
int i; size_t i;
panel_view_mode_t mode = view_listing;
int mode = view_listing;
/* Load the display mode */ /* Load the display mode */
buffer = mc_config_get_string(mc_panels_config, section, "display", "listing"); buffer = mc_config_get_string (mc_panels_config, section, "display", "listing");
for (i = 0; panel_types [i].opt_name; i++) for (i = 0; panel_types [i].opt_name != NULL; i++)
if ( g_strcasecmp (panel_types [i].opt_name, buffer) == 0){ if (g_strcasecmp (panel_types [i].opt_name, buffer) == 0) {
mode = panel_types [i].opt_type; mode = panel_types [i].opt_type;
break; break;
} }
g_free(buffer); g_free (buffer);
return mode; return mode;
} }
@ -769,7 +769,7 @@ load_setup (void)
startup_right_mode = setup__load_panel_state ("New Right Panel"); startup_right_mode = setup__load_panel_state ("New Right Panel");
/* At least one of the panels is a listing panel */ /* At least one of the panels is a listing panel */
if (startup_left_mode != view_listing && startup_right_mode!=view_listing) if (startup_left_mode != view_listing && startup_right_mode != view_listing)
startup_left_mode = view_listing; startup_left_mode = view_listing;
if (!other_dir){ if (!other_dir){

View File

@ -29,8 +29,8 @@ extern char *setup_color_string;
extern char *term_color_string; extern char *term_color_string;
extern char *color_terminal_string; extern char *color_terminal_string;
extern int startup_left_mode; extern panel_view_mode_t startup_left_mode;
extern int startup_right_mode; extern panel_view_mode_t startup_right_mode;
extern int verbose; extern int verbose;
extern int mouse_close_dialog; extern int mouse_close_dialog;