mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
src/filemanager/chown.c: get rid of global variable current_panel usage.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
54642d315f
commit
0c00ead1b0
@ -45,7 +45,6 @@
|
||||
#include "lib/widget.h"
|
||||
|
||||
#include "src/setup.h" /* panels_options */
|
||||
#include "filemanager.h" /* current_panel */
|
||||
|
||||
#include "cmd.h" /* chown_cmd() */
|
||||
|
||||
@ -187,7 +186,7 @@ chown_bg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static WDialog *
|
||||
chown_dlg_create (void)
|
||||
chown_dlg_create (WPanel * panel)
|
||||
{
|
||||
int single_set;
|
||||
WDialog *ch_dlg;
|
||||
@ -197,7 +196,7 @@ chown_dlg_create (void)
|
||||
struct passwd *l_pass;
|
||||
struct group *l_grp;
|
||||
|
||||
single_set = (current_panel->marked < 2) ? 3 : 0;
|
||||
single_set = (panel->marked < 2) ? 3 : 0;
|
||||
lines = GH + 4 + (single_set != 0 ? 2 : 4);
|
||||
cols = GW * 3 + 2 + 6;
|
||||
|
||||
@ -285,12 +284,12 @@ chown_done (gboolean need_update)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static const char *
|
||||
next_file (void)
|
||||
next_file (const WPanel * panel)
|
||||
{
|
||||
while (!current_panel->dir.list[current_file].f.marked)
|
||||
while (!panel->dir.list[current_file].f.marked)
|
||||
current_file++;
|
||||
|
||||
return current_panel->dir.list[current_file].fname;
|
||||
return panel->dir.list[current_file].fname;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -340,13 +339,13 @@ try_chown (const vfs_path_t * p, uid_t u, gid_t g)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gboolean
|
||||
do_chown (const vfs_path_t * p, uid_t u, gid_t g)
|
||||
do_chown (WPanel * panel, const vfs_path_t * p, uid_t u, gid_t g)
|
||||
{
|
||||
gboolean ret;
|
||||
|
||||
ret = try_chown (p, u, g);
|
||||
|
||||
do_file_mark (current_panel, current_file, 0);
|
||||
do_file_mark (panel, current_file, 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -354,11 +353,11 @@ do_chown (const vfs_path_t * p, uid_t u, gid_t g)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
apply_chowns (vfs_path_t * vpath, uid_t u, gid_t g)
|
||||
apply_chowns (WPanel * panel, vfs_path_t * vpath, uid_t u, gid_t g)
|
||||
{
|
||||
gboolean ok;
|
||||
|
||||
if (!do_chown (vpath, u, g))
|
||||
if (!do_chown (panel, vpath, u, g))
|
||||
return;
|
||||
|
||||
do
|
||||
@ -366,25 +365,25 @@ apply_chowns (vfs_path_t * vpath, uid_t u, gid_t g)
|
||||
const char *fname;
|
||||
struct stat sf;
|
||||
|
||||
fname = next_file ();
|
||||
fname = next_file (panel);
|
||||
vpath = vfs_path_from_str (fname);
|
||||
ok = (mc_stat (vpath, &sf) == 0);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
/* if current file was deleted outside mc -- try next file */
|
||||
/* decrease current_panel->marked */
|
||||
do_file_mark (current_panel, current_file, 0);
|
||||
/* decrease panel->marked */
|
||||
do_file_mark (panel, current_file, 0);
|
||||
|
||||
/* try next file */
|
||||
ok = TRUE;
|
||||
}
|
||||
else
|
||||
ok = do_chown (vpath, u, g);
|
||||
ok = do_chown (panel, vpath, u, g);
|
||||
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
while (ok && current_panel->marked != 0);
|
||||
while (ok && panel->marked != 0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -392,7 +391,7 @@ apply_chowns (vfs_path_t * vpath, uid_t u, gid_t g)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
chown_cmd (void)
|
||||
chown_cmd (WPanel * panel)
|
||||
{
|
||||
gboolean need_update;
|
||||
gboolean end_chown;
|
||||
@ -418,10 +417,10 @@ chown_cmd (void)
|
||||
need_update = FALSE;
|
||||
end_chown = FALSE;
|
||||
|
||||
if (current_panel->marked != 0)
|
||||
fname = next_file (); /* next marked file */
|
||||
if (panel->marked != 0)
|
||||
fname = next_file (panel); /* next marked file */
|
||||
else
|
||||
fname = selection (current_panel)->fname; /* single file */
|
||||
fname = selection (panel)->fname; /* single file */
|
||||
|
||||
vpath = vfs_path_from_str (fname);
|
||||
|
||||
@ -431,7 +430,7 @@ chown_cmd (void)
|
||||
break;
|
||||
}
|
||||
|
||||
ch_dlg = chown_dlg_create ();
|
||||
ch_dlg = chown_dlg_create (panel);
|
||||
|
||||
/* select in listboxes */
|
||||
listbox_select_entry (l_user, listbox_search_text (l_user, get_owner (sf_stat.st_uid)));
|
||||
@ -469,7 +468,7 @@ chown_cmd (void)
|
||||
new_user = user->pw_uid;
|
||||
if (result == B_ENTER)
|
||||
{
|
||||
if (current_panel->marked <= 1)
|
||||
if (panel->marked <= 1)
|
||||
{
|
||||
/* single or last file */
|
||||
if (mc_chown (vpath, new_user, new_group) == -1)
|
||||
@ -486,7 +485,7 @@ chown_cmd (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
apply_chowns (vpath, new_user, new_group);
|
||||
apply_chowns (panel, vpath, new_user, new_group);
|
||||
end_chown = TRUE;
|
||||
}
|
||||
|
||||
@ -504,7 +503,7 @@ chown_cmd (void)
|
||||
if (user != NULL)
|
||||
{
|
||||
new_user = user->pw_uid;
|
||||
apply_chowns (vpath, new_user, new_group);
|
||||
apply_chowns (panel, vpath, new_user, new_group);
|
||||
need_update = TRUE;
|
||||
end_chown = TRUE;
|
||||
}
|
||||
@ -521,7 +520,7 @@ chown_cmd (void)
|
||||
if (grp != NULL)
|
||||
{
|
||||
new_group = grp->gr_gid;
|
||||
apply_chowns (vpath, new_user, new_group);
|
||||
apply_chowns (panel, vpath, new_user, new_group);
|
||||
need_update = TRUE;
|
||||
end_chown = TRUE;
|
||||
}
|
||||
@ -532,9 +531,9 @@ chown_cmd (void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (current_panel->marked != 0 && result != B_CANCEL)
|
||||
if (panel->marked != 0 && result != B_CANCEL)
|
||||
{
|
||||
do_file_mark (current_panel, current_file, 0);
|
||||
do_file_mark (panel, current_file, 0);
|
||||
need_update = TRUE;
|
||||
}
|
||||
|
||||
@ -542,7 +541,7 @@ chown_cmd (void)
|
||||
|
||||
dlg_destroy (ch_dlg);
|
||||
}
|
||||
while (current_panel->marked != 0 && !end_chown);
|
||||
while (panel->marked != 0 && !end_chown);
|
||||
|
||||
chown_done (need_update);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ void advanced_chown_cmd (WPanel * panel);
|
||||
/* chmod.c */
|
||||
void chmod_cmd (WPanel * panel);
|
||||
/* chown.c */
|
||||
void chown_cmd (void);
|
||||
void chown_cmd (WPanel * panel);
|
||||
#ifdef ENABLE_EXT2FS_ATTR
|
||||
/* chattr.c */
|
||||
void chattr_cmd (void);
|
||||
|
@ -1150,7 +1150,7 @@ midnight_execute_cmd (Widget * sender, long command)
|
||||
chmod_cmd (current_panel);
|
||||
break;
|
||||
case CK_ChangeOwn:
|
||||
chown_cmd ();
|
||||
chown_cmd (current_panel);
|
||||
break;
|
||||
case CK_ChangeOwnAdvanced:
|
||||
advanced_chown_cmd (current_panel);
|
||||
|
Loading…
Reference in New Issue
Block a user