mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +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>
|
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.h: Don't include edit/edit-widget.h.
|
||||||
* user.c: Include edit/edit-widget.h and edit/edit.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:
|
case DLG_POST_KEY:
|
||||||
/* The enter key will be processed by the tree widget */
|
/* 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;
|
h->ret_value = B_ENTER;
|
||||||
dlg_stop (h);
|
dlg_stop (h);
|
||||||
}
|
}
|
||||||
@ -677,7 +677,7 @@ tree_box (char *current_dir)
|
|||||||
|
|
||||||
run_dlg (dlg);
|
run_dlg (dlg);
|
||||||
if (dlg->ret_value == B_ENTER)
|
if (dlg->ret_value == B_ENTER)
|
||||||
val = g_strdup (mytree->selected_ptr->name);
|
val = g_strdup (tree_selected_name (mytree));
|
||||||
else
|
else
|
||||||
val = 0;
|
val = 0;
|
||||||
|
|
||||||
|
@ -1559,12 +1559,12 @@ panel_get_file (WPanel *panel, struct stat *stat_buf)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* No problem with Gnome, as get_current_type never returns view_tree there */
|
|
||||||
if (get_current_type () == view_tree) {
|
if (get_current_type () == view_tree) {
|
||||||
WTree *tree = (WTree *) get_panel_widget (get_current_index ());
|
WTree *tree = (WTree *) get_panel_widget (get_current_index ());
|
||||||
|
char *tree_name = tree_selected_name (tree);
|
||||||
|
|
||||||
mc_stat (tree->selected_ptr->name, stat_buf);
|
mc_stat (tree_name, stat_buf);
|
||||||
return tree->selected_ptr->name;
|
return tree_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (panel->marked) {
|
if (panel->marked) {
|
||||||
|
@ -1332,7 +1332,7 @@ copy_prog_name (void)
|
|||||||
|
|
||||||
if (get_current_type () == view_tree) {
|
if (get_current_type () == view_tree) {
|
||||||
WTree *tree = (WTree *) get_panel_widget (get_current_index ());
|
WTree *tree = (WTree *) get_panel_widget (get_current_index ());
|
||||||
tmp = tree->selected_ptr->name;
|
tmp = tree_selected_name (tree);
|
||||||
} else
|
} else
|
||||||
tmp = selection (cpanel)->fname;
|
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 */
|
/* Specifies the display mode: 1d or 2d */
|
||||||
static int tree_navigation_flag;
|
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 */
|
/* Forwards */
|
||||||
static void save_tree (WTree *tree);
|
static void save_tree (WTree *tree);
|
||||||
static void tree_rescan_cmd (WTree *tree);
|
static void tree_rescan_cmd (WTree *tree);
|
||||||
@ -862,12 +875,11 @@ move_nextp (WTree *tree)
|
|||||||
static void
|
static void
|
||||||
chdir_sel (WTree *tree)
|
chdir_sel (WTree *tree)
|
||||||
{
|
{
|
||||||
if (!tree->is_panel){
|
if (!tree->is_panel) {
|
||||||
tree->done = 1;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
change_panel ();
|
change_panel ();
|
||||||
if (do_cd (tree->selected_ptr->name, cd_exact)){
|
if (do_cd (tree->selected_ptr->name, cd_exact)) {
|
||||||
paint_panel (cpanel);
|
paint_panel (cpanel);
|
||||||
select_item (cpanel);
|
select_item (cpanel);
|
||||||
} else {
|
} else {
|
||||||
@ -1069,7 +1081,6 @@ tree_new (int is_panel, int y, int x, int lines, int cols)
|
|||||||
tree->search_buffer[0] = 0;
|
tree->search_buffer[0] = 0;
|
||||||
tree->topdiff = tree->widget.lines / 2;
|
tree->topdiff = tree->widget.lines / 2;
|
||||||
tree->searching = 0;
|
tree->searching = 0;
|
||||||
tree->done = 0;
|
|
||||||
tree->active = 0;
|
tree->active = 0;
|
||||||
|
|
||||||
/* We do not want to keep the cursor */
|
/* 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);
|
load_tree (tree);
|
||||||
return 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 "treestore.h"
|
||||||
|
|
||||||
#include "dlg.h"
|
#include "dlg.h"
|
||||||
typedef struct {
|
|
||||||
Widget widget;
|
struct WTree;
|
||||||
TreeStore *store;
|
typedef struct WTree WTree;
|
||||||
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;
|
|
||||||
|
|
||||||
#define tlines(t) (t->is_panel ? t->widget.lines-2 - (show_mini_info ? 2 : 0) : t->widget.lines)
|
#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);
|
int tree_init (char *current_dir, int lines);
|
||||||
void tree_chdir (WTree *tree, char *dir);
|
void tree_chdir (WTree *tree, char *dir);
|
||||||
|
char *tree_selected_name (WTree *tree);
|
||||||
|
|
||||||
void sync_tree (char *pathname);
|
void sync_tree (char *pathname);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user