mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-10 21:42:00 +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 "lib/widget.h"
|
||||||
|
|
||||||
#include "src/setup.h" /* panels_options */
|
#include "src/setup.h" /* panels_options */
|
||||||
#include "filemanager.h" /* current_panel */
|
|
||||||
|
|
||||||
#include "cmd.h" /* chown_cmd() */
|
#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 *
|
static WDialog *
|
||||||
chown_dlg_create (void)
|
chown_dlg_create (WPanel * panel)
|
||||||
{
|
{
|
||||||
int single_set;
|
int single_set;
|
||||||
WDialog *ch_dlg;
|
WDialog *ch_dlg;
|
||||||
@ -197,7 +196,7 @@ chown_dlg_create (void)
|
|||||||
struct passwd *l_pass;
|
struct passwd *l_pass;
|
||||||
struct group *l_grp;
|
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);
|
lines = GH + 4 + (single_set != 0 ? 2 : 4);
|
||||||
cols = GW * 3 + 2 + 6;
|
cols = GW * 3 + 2 + 6;
|
||||||
|
|
||||||
@ -285,12 +284,12 @@ chown_done (gboolean need_update)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static const char *
|
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++;
|
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
|
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;
|
gboolean ret;
|
||||||
|
|
||||||
ret = try_chown (p, u, g);
|
ret = try_chown (p, u, g);
|
||||||
|
|
||||||
do_file_mark (current_panel, current_file, 0);
|
do_file_mark (panel, current_file, 0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -354,11 +353,11 @@ do_chown (const vfs_path_t * p, uid_t u, gid_t g)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
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;
|
gboolean ok;
|
||||||
|
|
||||||
if (!do_chown (vpath, u, g))
|
if (!do_chown (panel, vpath, u, g))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -366,25 +365,25 @@ apply_chowns (vfs_path_t * vpath, uid_t u, gid_t g)
|
|||||||
const char *fname;
|
const char *fname;
|
||||||
struct stat sf;
|
struct stat sf;
|
||||||
|
|
||||||
fname = next_file ();
|
fname = next_file (panel);
|
||||||
vpath = vfs_path_from_str (fname);
|
vpath = vfs_path_from_str (fname);
|
||||||
ok = (mc_stat (vpath, &sf) == 0);
|
ok = (mc_stat (vpath, &sf) == 0);
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
/* if current file was deleted outside mc -- try next file */
|
/* if current file was deleted outside mc -- try next file */
|
||||||
/* decrease current_panel->marked */
|
/* decrease panel->marked */
|
||||||
do_file_mark (current_panel, current_file, 0);
|
do_file_mark (panel, current_file, 0);
|
||||||
|
|
||||||
/* try next file */
|
/* try next file */
|
||||||
ok = TRUE;
|
ok = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ok = do_chown (vpath, u, g);
|
ok = do_chown (panel, vpath, u, g);
|
||||||
|
|
||||||
vfs_path_free (vpath);
|
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
|
void
|
||||||
chown_cmd (void)
|
chown_cmd (WPanel * panel)
|
||||||
{
|
{
|
||||||
gboolean need_update;
|
gboolean need_update;
|
||||||
gboolean end_chown;
|
gboolean end_chown;
|
||||||
@ -418,10 +417,10 @@ chown_cmd (void)
|
|||||||
need_update = FALSE;
|
need_update = FALSE;
|
||||||
end_chown = FALSE;
|
end_chown = FALSE;
|
||||||
|
|
||||||
if (current_panel->marked != 0)
|
if (panel->marked != 0)
|
||||||
fname = next_file (); /* next marked file */
|
fname = next_file (panel); /* next marked file */
|
||||||
else
|
else
|
||||||
fname = selection (current_panel)->fname; /* single file */
|
fname = selection (panel)->fname; /* single file */
|
||||||
|
|
||||||
vpath = vfs_path_from_str (fname);
|
vpath = vfs_path_from_str (fname);
|
||||||
|
|
||||||
@ -431,7 +430,7 @@ chown_cmd (void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ch_dlg = chown_dlg_create ();
|
ch_dlg = chown_dlg_create (panel);
|
||||||
|
|
||||||
/* select in listboxes */
|
/* select in listboxes */
|
||||||
listbox_select_entry (l_user, listbox_search_text (l_user, get_owner (sf_stat.st_uid)));
|
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;
|
new_user = user->pw_uid;
|
||||||
if (result == B_ENTER)
|
if (result == B_ENTER)
|
||||||
{
|
{
|
||||||
if (current_panel->marked <= 1)
|
if (panel->marked <= 1)
|
||||||
{
|
{
|
||||||
/* single or last file */
|
/* single or last file */
|
||||||
if (mc_chown (vpath, new_user, new_group) == -1)
|
if (mc_chown (vpath, new_user, new_group) == -1)
|
||||||
@ -486,7 +485,7 @@ chown_cmd (void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
apply_chowns (vpath, new_user, new_group);
|
apply_chowns (panel, vpath, new_user, new_group);
|
||||||
end_chown = TRUE;
|
end_chown = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,7 +503,7 @@ chown_cmd (void)
|
|||||||
if (user != NULL)
|
if (user != NULL)
|
||||||
{
|
{
|
||||||
new_user = user->pw_uid;
|
new_user = user->pw_uid;
|
||||||
apply_chowns (vpath, new_user, new_group);
|
apply_chowns (panel, vpath, new_user, new_group);
|
||||||
need_update = TRUE;
|
need_update = TRUE;
|
||||||
end_chown = TRUE;
|
end_chown = TRUE;
|
||||||
}
|
}
|
||||||
@ -521,7 +520,7 @@ chown_cmd (void)
|
|||||||
if (grp != NULL)
|
if (grp != NULL)
|
||||||
{
|
{
|
||||||
new_group = grp->gr_gid;
|
new_group = grp->gr_gid;
|
||||||
apply_chowns (vpath, new_user, new_group);
|
apply_chowns (panel, vpath, new_user, new_group);
|
||||||
need_update = TRUE;
|
need_update = TRUE;
|
||||||
end_chown = TRUE;
|
end_chown = TRUE;
|
||||||
}
|
}
|
||||||
@ -532,9 +531,9 @@ chown_cmd (void)
|
|||||||
break;
|
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;
|
need_update = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,7 +541,7 @@ chown_cmd (void)
|
|||||||
|
|
||||||
dlg_destroy (ch_dlg);
|
dlg_destroy (ch_dlg);
|
||||||
}
|
}
|
||||||
while (current_panel->marked != 0 && !end_chown);
|
while (panel->marked != 0 && !end_chown);
|
||||||
|
|
||||||
chown_done (need_update);
|
chown_done (need_update);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ void advanced_chown_cmd (WPanel * panel);
|
|||||||
/* chmod.c */
|
/* chmod.c */
|
||||||
void chmod_cmd (WPanel * panel);
|
void chmod_cmd (WPanel * panel);
|
||||||
/* chown.c */
|
/* chown.c */
|
||||||
void chown_cmd (void);
|
void chown_cmd (WPanel * panel);
|
||||||
#ifdef ENABLE_EXT2FS_ATTR
|
#ifdef ENABLE_EXT2FS_ATTR
|
||||||
/* chattr.c */
|
/* chattr.c */
|
||||||
void chattr_cmd (void);
|
void chattr_cmd (void);
|
||||||
|
@ -1150,7 +1150,7 @@ midnight_execute_cmd (Widget * sender, long command)
|
|||||||
chmod_cmd (current_panel);
|
chmod_cmd (current_panel);
|
||||||
break;
|
break;
|
||||||
case CK_ChangeOwn:
|
case CK_ChangeOwn:
|
||||||
chown_cmd ();
|
chown_cmd (current_panel);
|
||||||
break;
|
break;
|
||||||
case CK_ChangeOwnAdvanced:
|
case CK_ChangeOwnAdvanced:
|
||||||
advanced_chown_cmd (current_panel);
|
advanced_chown_cmd (current_panel);
|
||||||
|
Loading…
Reference in New Issue
Block a user