mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* tree.c: Make struct WTree opaque. Remove "done" flag - it's
broken by design. (tree_selected_name): New function, return name of the currently selected entry. Use it where WTree is opaque. * boxes.c (tree_callback): Don't check for the "done" flag - it causes closing the dialog on any key after mouse selection.
This commit is contained in:
parent
e0e20526b2
commit
c3f5696cca
@ -1,5 +1,12 @@
|
||||
2002-11-28 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* tree.c: Make struct WTree opaque. Remove "done" flag - it's
|
||||
broken by design.
|
||||
(tree_selected_name): New function, return name of the currently
|
||||
selected entry. Use it where WTree is opaque.
|
||||
* boxes.c (tree_callback): Don't check for the "done" flag - it
|
||||
causes closing the dialog on any key after mouse selection.
|
||||
|
||||
* user.h: Don't include edit/edit-widget.h.
|
||||
* user.c: Include edit/edit-widget.h and edit/edit.h.
|
||||
|
||||
|
@ -643,7 +643,7 @@ tree_callback (struct Dlg_head *h, int id, int msg)
|
||||
|
||||
case DLG_POST_KEY:
|
||||
/* The enter key will be processed by the tree widget */
|
||||
if (id == '\n' || ((WTree *)(h->current->widget))->done){
|
||||
if (id == '\n') {
|
||||
h->ret_value = B_ENTER;
|
||||
dlg_stop (h);
|
||||
}
|
||||
@ -677,7 +677,7 @@ tree_box (char *current_dir)
|
||||
|
||||
run_dlg (dlg);
|
||||
if (dlg->ret_value == B_ENTER)
|
||||
val = g_strdup (mytree->selected_ptr->name);
|
||||
val = g_strdup (tree_selected_name (mytree));
|
||||
else
|
||||
val = 0;
|
||||
|
||||
|
@ -1559,12 +1559,12 @@ panel_get_file (WPanel *panel, struct stat *stat_buf)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* No problem with Gnome, as get_current_type never returns view_tree there */
|
||||
if (get_current_type () == view_tree) {
|
||||
WTree *tree = (WTree *) get_panel_widget (get_current_index ());
|
||||
char *tree_name = tree_selected_name (tree);
|
||||
|
||||
mc_stat (tree->selected_ptr->name, stat_buf);
|
||||
return tree->selected_ptr->name;
|
||||
mc_stat (tree_name, stat_buf);
|
||||
return tree_name;
|
||||
}
|
||||
|
||||
if (panel->marked) {
|
||||
|
@ -1332,7 +1332,7 @@ copy_prog_name (void)
|
||||
|
||||
if (get_current_type () == view_tree) {
|
||||
WTree *tree = (WTree *) get_panel_widget (get_current_index ());
|
||||
tmp = tree->selected_ptr->name;
|
||||
tmp = tree_selected_name (tree);
|
||||
} else
|
||||
tmp = selection (cpanel)->fname;
|
||||
|
||||
|
27
src/tree.c
27
src/tree.c
@ -56,6 +56,19 @@ extern int command_prompt;
|
||||
/* Specifies the display mode: 1d or 2d */
|
||||
static int tree_navigation_flag;
|
||||
|
||||
struct WTree {
|
||||
Widget widget;
|
||||
TreeStore *store;
|
||||
tree_entry *selected_ptr; /* The selected directory */
|
||||
char search_buffer[256]; /* Current search string */
|
||||
tree_entry **tree_shown; /* Entries currently on screen */
|
||||
int is_panel; /* panel or plain widget flag */
|
||||
int active; /* if it's currently selected */
|
||||
int searching; /* Are we on searching mode? */
|
||||
int topdiff; /* The difference between the topmost
|
||||
shown and the selected */
|
||||
};
|
||||
|
||||
/* Forwards */
|
||||
static void save_tree (WTree *tree);
|
||||
static void tree_rescan_cmd (WTree *tree);
|
||||
@ -862,12 +875,11 @@ move_nextp (WTree *tree)
|
||||
static void
|
||||
chdir_sel (WTree *tree)
|
||||
{
|
||||
if (!tree->is_panel){
|
||||
tree->done = 1;
|
||||
if (!tree->is_panel) {
|
||||
return;
|
||||
}
|
||||
change_panel ();
|
||||
if (do_cd (tree->selected_ptr->name, cd_exact)){
|
||||
if (do_cd (tree->selected_ptr->name, cd_exact)) {
|
||||
paint_panel (cpanel);
|
||||
select_item (cpanel);
|
||||
} else {
|
||||
@ -1069,7 +1081,6 @@ tree_new (int is_panel, int y, int x, int lines, int cols)
|
||||
tree->search_buffer[0] = 0;
|
||||
tree->topdiff = tree->widget.lines / 2;
|
||||
tree->searching = 0;
|
||||
tree->done = 0;
|
||||
tree->active = 0;
|
||||
|
||||
/* We do not want to keep the cursor */
|
||||
@ -1077,3 +1088,11 @@ tree_new (int is_panel, int y, int x, int lines, int cols)
|
||||
load_tree (tree);
|
||||
return tree;
|
||||
}
|
||||
|
||||
/* Return name of the currently selected entry */
|
||||
char *
|
||||
tree_selected_name (WTree *tree)
|
||||
{
|
||||
return tree->selected_ptr->name;
|
||||
}
|
||||
|
||||
|
16
src/tree.h
16
src/tree.h
@ -4,23 +4,15 @@
|
||||
#include "treestore.h"
|
||||
|
||||
#include "dlg.h"
|
||||
typedef struct {
|
||||
Widget widget;
|
||||
TreeStore *store;
|
||||
tree_entry *selected_ptr; /* The selected directory */
|
||||
char search_buffer [256]; /* Current search string */
|
||||
int done; /* Flag: exit tree */
|
||||
tree_entry **tree_shown; /* Entries currently on screen */
|
||||
int is_panel; /* panel or plain widget flag */
|
||||
int active; /* if it's currently selected */
|
||||
int searching; /* Are we on searching mode? */
|
||||
int topdiff; /* The difference between the topmost shown and the selected */
|
||||
} WTree;
|
||||
|
||||
struct WTree;
|
||||
typedef struct WTree WTree;
|
||||
|
||||
#define tlines(t) (t->is_panel ? t->widget.lines-2 - (show_mini_info ? 2 : 0) : t->widget.lines)
|
||||
|
||||
int tree_init (char *current_dir, int lines);
|
||||
void tree_chdir (WTree *tree, char *dir);
|
||||
char *tree_selected_name (WTree *tree);
|
||||
|
||||
void sync_tree (char *pathname);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user