mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-24 20:22:11 +03:00
* chmod.c: Use common_dialog_repaint().
* chown.c: Likewise. * layout.c: Likewise. * option.c: Likewise.
This commit is contained in:
parent
e000c69683
commit
6f0c076c65
@ -1,5 +1,10 @@
|
||||
2002-09-02 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* chmod.c: Use common_dialog_repaint().
|
||||
* chown.c: Likewise.
|
||||
* layout.c: Likewise.
|
||||
* option.c: Likewise.
|
||||
|
||||
* wtools.c (common_dialog_callback): Fold into ...
|
||||
* dlg.c (default_dlg_callback): ... this. Don't redraw dialogs
|
||||
that don't have colors. Adjust all dependencies.
|
||||
|
106
src/chmod.c
106
src/chmod.c
@ -45,7 +45,6 @@
|
||||
#include "../vfs/vfs.h"
|
||||
|
||||
static int single_set;
|
||||
static struct Dlg_head *ch_dlg;
|
||||
|
||||
#define PX 5
|
||||
#define PY 2
|
||||
@ -74,9 +73,6 @@ static umode_t and_mask, or_mask, c_stat;
|
||||
static char *c_fname, *c_fown, *c_fgrp;
|
||||
|
||||
static WLabel *statl;
|
||||
static int normal_color;
|
||||
static int title_color;
|
||||
static int selection_color;
|
||||
|
||||
static struct {
|
||||
mode_t mode;
|
||||
@ -112,54 +108,51 @@ static struct {
|
||||
{ B_ALL, NORMAL_BUTTON, 0, 0, N_("Set &all") },
|
||||
};
|
||||
|
||||
static void chmod_toggle_select (void)
|
||||
static void chmod_toggle_select (Dlg_head *h)
|
||||
{
|
||||
int Id = ch_dlg->current->dlg_id - BUTTONS + single_set * 2;
|
||||
int Id = h->current->dlg_id - BUTTONS + single_set * 2;
|
||||
|
||||
attrset (normal_color);
|
||||
attrset (COLOR_NORMAL);
|
||||
check_perm[Id].selected ^= 1;
|
||||
|
||||
dlg_move (ch_dlg, PY + PERMISSIONS - Id, PX + 1);
|
||||
dlg_move (h, PY + PERMISSIONS - Id, PX + 1);
|
||||
addch ((check_perm[Id].selected) ? '*' : ' ');
|
||||
dlg_move (ch_dlg, PY + PERMISSIONS - Id, PX + 3);
|
||||
dlg_move (h, PY + PERMISSIONS - Id, PX + 3);
|
||||
}
|
||||
|
||||
static void chmod_refresh (void)
|
||||
static void chmod_refresh (Dlg_head *h)
|
||||
{
|
||||
common_dialog_repaint (h);
|
||||
|
||||
attrset (COLOR_NORMAL);
|
||||
dlg_erase (ch_dlg);
|
||||
|
||||
draw_box (ch_dlg, 1, 2, 20 - single_set, 66);
|
||||
draw_box (ch_dlg, PY, PX, PERMISSIONS + 2, 33);
|
||||
draw_box (ch_dlg, FY, FX, 10, 25);
|
||||
draw_box (h, PY, PX, PERMISSIONS + 2, 33);
|
||||
draw_box (h, FY, FX, 10, 25);
|
||||
|
||||
dlg_move (ch_dlg, FY + 1, FX + 2);
|
||||
dlg_move (h, FY + 1, FX + 2);
|
||||
addstr (_("Name"));
|
||||
dlg_move (ch_dlg, FY + 3, FX + 2);
|
||||
dlg_move (h, FY + 3, FX + 2);
|
||||
addstr (_("Permissions (Octal)"));
|
||||
dlg_move (ch_dlg, FY + 5, FX + 2);
|
||||
dlg_move (h, FY + 5, FX + 2);
|
||||
addstr (_("Owner name"));
|
||||
dlg_move (ch_dlg, FY + 7, FX + 2);
|
||||
dlg_move (h, FY + 7, FX + 2);
|
||||
addstr (_("Group name"));
|
||||
|
||||
attrset (title_color);
|
||||
dlg_move (ch_dlg, 1, 28);
|
||||
addstr (_(" Chmod command "));
|
||||
dlg_move (ch_dlg, PY, PX + 1);
|
||||
addstr (_(" Permission "));
|
||||
dlg_move (ch_dlg, FY, FX + 1);
|
||||
addstr (_(" File "));
|
||||
|
||||
attrset (selection_color);
|
||||
|
||||
dlg_move (ch_dlg, TY, TX);
|
||||
dlg_move (h, TY, TX);
|
||||
addstr (_("Use SPACE to change"));
|
||||
dlg_move (ch_dlg, TY + 1, TX);
|
||||
dlg_move (h, TY + 1, TX);
|
||||
addstr (_("an option, ARROW KEYS"));
|
||||
dlg_move (ch_dlg, TY + 2, TX);
|
||||
dlg_move (h, TY + 2, TX);
|
||||
addstr (_("to move between options"));
|
||||
dlg_move (ch_dlg, TY + 3, TX);
|
||||
dlg_move (h, TY + 3, TX);
|
||||
addstr (_("and T or INS to mark"));
|
||||
|
||||
attrset (COLOR_HOT_NORMAL);
|
||||
|
||||
dlg_move (h, PY, PX + 1);
|
||||
addstr (_(" Permission "));
|
||||
dlg_move (h, FY, FX + 1);
|
||||
addstr (_(" File "));
|
||||
}
|
||||
|
||||
static int chmod_callback (Dlg_head *h, int Par, int Msg)
|
||||
@ -172,68 +165,64 @@ static int chmod_callback (Dlg_head *h, int Par, int Msg)
|
||||
c_stat ^= check_perm[Par - BUTTONS + single_set * 2].mode;
|
||||
g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
|
||||
label_set_text (statl, buffer);
|
||||
chmod_toggle_select ();
|
||||
chmod_toggle_select (h);
|
||||
mode_change = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case DLG_KEY:
|
||||
if ((Par == 'T' || Par == 't' || Par == KEY_IC) &&
|
||||
ch_dlg->current->dlg_id >= BUTTONS - single_set * 2) {
|
||||
chmod_toggle_select ();
|
||||
h->current->dlg_id >= BUTTONS - single_set * 2) {
|
||||
chmod_toggle_select (h);
|
||||
if (Par == KEY_IC)
|
||||
dlg_one_down (ch_dlg);
|
||||
dlg_one_down (h);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case DLG_DRAW:
|
||||
chmod_refresh ();
|
||||
chmod_refresh (h);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void init_chmod (void)
|
||||
Dlg_head *
|
||||
init_chmod (void)
|
||||
{
|
||||
int i;
|
||||
Dlg_head *ch_dlg;
|
||||
|
||||
do_refresh ();
|
||||
end_chmod = c_file = need_update = 0;
|
||||
single_set = (cpanel->marked < 2) ? 2 : 0;
|
||||
|
||||
if (use_colors){
|
||||
normal_color = COLOR_NORMAL;
|
||||
title_color = COLOR_HOT_NORMAL;
|
||||
selection_color = COLOR_NORMAL;
|
||||
} else {
|
||||
normal_color = NORMAL_COLOR;
|
||||
title_color = SELECTED_COLOR;
|
||||
selection_color = SELECTED_COLOR;
|
||||
}
|
||||
|
||||
ch_dlg = create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
|
||||
ch_dlg =
|
||||
create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
|
||||
chmod_callback, "[Chmod]", "chmod", DLG_CENTER);
|
||||
|
||||
x_set_dialog_title (ch_dlg, _("Chmod command"));
|
||||
|
||||
#define XTRACT(i) BY+chmod_but[i].y-single_set, BX+chmod_but[i].x, \
|
||||
chmod_but[i].ret_cmd, chmod_but[i].flags, _(chmod_but[i].text), 0, 0, NULL
|
||||
|
||||
for (i = 0; i < BUTTONS; i++) {
|
||||
if (i == 2 && single_set)
|
||||
break;
|
||||
else
|
||||
add_widget (ch_dlg, button_new (XTRACT (i)));
|
||||
add_widget (ch_dlg,
|
||||
button_new (BY + chmod_but[i].y - single_set,
|
||||
BX + chmod_but[i].x,
|
||||
chmod_but[i].ret_cmd,
|
||||
chmod_but[i].flags,
|
||||
_(chmod_but[i].text), 0, 0, NULL));
|
||||
}
|
||||
|
||||
|
||||
#define XTRACT2(i) 0, _(check_perm [i].text), NULL
|
||||
for (i = 0; i < PERMISSIONS; i++) {
|
||||
check_perm[i].check = check_new (PY + (PERMISSIONS - i), PX + 2,
|
||||
XTRACT2 (i));
|
||||
check_perm[i].check =
|
||||
check_new (PY + (PERMISSIONS - i), PX + 2, 0,
|
||||
_(check_perm[i].text), NULL);
|
||||
add_widget (ch_dlg, check_perm[i].check);
|
||||
}
|
||||
|
||||
return ch_dlg;
|
||||
}
|
||||
|
||||
int stat_file (char *filename, struct stat *st)
|
||||
@ -293,9 +282,10 @@ void chmod_cmd (void)
|
||||
char *fname;
|
||||
int i;
|
||||
struct stat sf_stat;
|
||||
Dlg_head *ch_dlg;
|
||||
|
||||
do { /* do while any files remaining */
|
||||
init_chmod ();
|
||||
ch_dlg = init_chmod ();
|
||||
if (cpanel->marked)
|
||||
fname = next_file (); /* next marked file */
|
||||
else
|
||||
|
73
src/chown.c
73
src/chown.c
@ -63,7 +63,6 @@
|
||||
#define B_SETUSR B_USER + 1
|
||||
#define B_SETGRP B_USER + 2
|
||||
|
||||
static struct Dlg_head *ch_dlg;
|
||||
static int need_update, end_chown;
|
||||
static int current_file;
|
||||
static int single_set;
|
||||
@ -93,36 +92,33 @@ static struct {
|
||||
};
|
||||
|
||||
static void
|
||||
chown_refresh (void)
|
||||
chown_refresh (Dlg_head *h)
|
||||
{
|
||||
attrset (COLOR_NORMAL);
|
||||
dlg_erase (ch_dlg);
|
||||
|
||||
draw_box (ch_dlg, 1, 2, 16, 70);
|
||||
draw_box (ch_dlg, UY, UX, 12, 21);
|
||||
draw_box (ch_dlg, GY, GX, 12, 21);
|
||||
draw_box (ch_dlg, TY, TX, 12, 19);
|
||||
common_dialog_repaint (h);
|
||||
|
||||
attrset (COLOR_NORMAL);
|
||||
dlg_move (ch_dlg, TY + 1, TX + 1);
|
||||
|
||||
draw_box (h, UY, UX, 12, 21);
|
||||
draw_box (h, GY, GX, 12, 21);
|
||||
draw_box (h, TY, TX, 12, 19);
|
||||
|
||||
dlg_move (h, TY + 1, TX + 1);
|
||||
addstr (_(" Name "));
|
||||
dlg_move (ch_dlg, TY + 3, TX + 1);
|
||||
dlg_move (h, TY + 3, TX + 1);
|
||||
addstr (_(" Owner name "));
|
||||
dlg_move (ch_dlg, TY + 5, TX + 1);
|
||||
dlg_move (h, TY + 5, TX + 1);
|
||||
addstr (_(" Group name "));
|
||||
dlg_move (ch_dlg, TY + 7, TX + 1);
|
||||
dlg_move (h, TY + 7, TX + 1);
|
||||
addstr (_(" Size "));
|
||||
dlg_move (ch_dlg, TY + 9, TX + 1);
|
||||
dlg_move (h, TY + 9, TX + 1);
|
||||
addstr (_(" Permission "));
|
||||
|
||||
attrset (COLOR_HOT_NORMAL);
|
||||
dlg_move (ch_dlg, 1, 28);
|
||||
addstr (_(" Chown command "));
|
||||
dlg_move (ch_dlg, UY, UX + 1);
|
||||
dlg_move (h, UY, UX + 1);
|
||||
addstr (_(" User name "));
|
||||
dlg_move (ch_dlg, GY, GX + 1);
|
||||
dlg_move (h, GY, GX + 1);
|
||||
addstr (_(" Group name "));
|
||||
dlg_move (ch_dlg, TY, TX + 1);
|
||||
dlg_move (h, TY, TX + 1);
|
||||
addstr (_(" File "));
|
||||
}
|
||||
|
||||
@ -140,7 +136,7 @@ chown_callback (Dlg_head * h, int Par, int Msg)
|
||||
{
|
||||
switch (Msg) {
|
||||
case DLG_DRAW:
|
||||
chown_refresh ();
|
||||
chown_refresh (h);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@ -152,29 +148,33 @@ l_call (void *data)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
static Dlg_head *
|
||||
init_chown (void)
|
||||
{
|
||||
int i;
|
||||
struct passwd *l_pass;
|
||||
struct group *l_grp;
|
||||
Dlg_head *ch_dlg;
|
||||
|
||||
do_refresh ();
|
||||
end_chown = need_update = current_file = 0;
|
||||
single_set = (cpanel->marked < 2) ? 3 : 0;
|
||||
|
||||
ch_dlg = create_dlg (0, 0, 18, 74, dialog_colors, chown_callback,
|
||||
"[Chown]", "chown", DLG_CENTER);
|
||||
|
||||
#define XTRACT(i) BY+chown_but[i].y, BX+chown_but[i].x, chown_but[i].ret_cmd, chown_but[i].flags, _(chown_but[i].text), 0, 0, NULL
|
||||
ch_dlg =
|
||||
create_dlg (0, 0, 18, 74, dialog_colors, chown_callback, "[Chown]",
|
||||
"chown", DLG_CENTER);
|
||||
x_set_dialog_title (ch_dlg, _(" Chown command "));
|
||||
|
||||
for (i = 0; i < BUTTONS - single_set; i++)
|
||||
add_widget (ch_dlg, button_new (XTRACT (i)));
|
||||
add_widget (ch_dlg,
|
||||
button_new (BY + chown_but[i].y, BX + chown_but[i].x,
|
||||
chown_but[i].ret_cmd, chown_but[i].flags,
|
||||
_(chown_but[i].text), 0, 0, NULL));
|
||||
|
||||
/* Add the widgets for the file information */
|
||||
#define LX(i) chown_label [i].y, chown_label [i].x, "", NULL
|
||||
for (i = 0; i < LABELS; i++) {
|
||||
chown_label [i].l = label_new (LX (i));
|
||||
chown_label[i].l =
|
||||
label_new (chown_label[i].y, chown_label[i].x, "", NULL);
|
||||
add_widget (ch_dlg, chown_label[i].l);
|
||||
}
|
||||
|
||||
@ -182,23 +182,29 @@ init_chown (void)
|
||||
l_user = listbox_new (UY + 1, UX + 1, 19, 10, 0, l_call, NULL);
|
||||
l_group = listbox_new (GY + 1, GX + 1, 19, 10, 0, l_call, NULL);
|
||||
|
||||
listbox_add_item (l_user, 0, 0, _("<Unknown user>"), NULL); /* add fields for unknown names (numbers) */
|
||||
/* add fields for unknown names (numbers) */
|
||||
listbox_add_item (l_user, 0, 0, _("<Unknown user>"), NULL);
|
||||
listbox_add_item (l_group, 0, 0, _("<Unknown group>"), NULL);
|
||||
|
||||
setpwent (); /* get and put user names in the listbox */
|
||||
/* get and put user names in the listbox */
|
||||
setpwent ();
|
||||
while ((l_pass = getpwent ())) {
|
||||
listbox_add_item (l_user, 0, 0, l_pass->pw_name, NULL);
|
||||
}
|
||||
endpwent ();
|
||||
|
||||
setgrent (); /* get and put group names in the listbox */
|
||||
/* get and put group names in the listbox */
|
||||
setgrent ();
|
||||
while ((l_grp = getgrent ())) {
|
||||
listbox_add_item (l_group, 0, 0, l_grp->gr_name, NULL);
|
||||
}
|
||||
endgrent ();
|
||||
|
||||
/* add listboxes to the dialogs */
|
||||
add_widget (ch_dlg, l_group);
|
||||
add_widget (ch_dlg, l_user); /* add listboxes to the dialogs */
|
||||
add_widget (ch_dlg, l_user);
|
||||
|
||||
return ch_dlg;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -242,12 +248,13 @@ chown_cmd (void)
|
||||
char *fname;
|
||||
struct stat sf_stat;
|
||||
WLEntry *fe;
|
||||
Dlg_head *ch_dlg;
|
||||
uid_t new_user;
|
||||
gid_t new_group;
|
||||
char buffer [BUF_TINY];
|
||||
|
||||
do { /* do while any files remaining */
|
||||
init_chown ();
|
||||
ch_dlg = init_chown ();
|
||||
new_user = new_group = -1;
|
||||
|
||||
if (cpanel->marked)
|
||||
|
12
src/layout.c
12
src/layout.c
@ -177,7 +177,7 @@ static struct {
|
||||
};
|
||||
|
||||
static int first_width, second_width;
|
||||
static char *layout_title, *title1, *title2, *title3, *output_lines_label;
|
||||
static char *title1, *title2, *title3, *output_lines_label;
|
||||
|
||||
static WButton *bleft_widget, *bright_widget;
|
||||
|
||||
@ -274,19 +274,18 @@ static int layout_callback (struct Dlg_head *h, int Id, int Msg)
|
||||
case DLG_DRAW:
|
||||
/*When repainting the whole dialog (e.g. with C-l) we have to
|
||||
update everything*/
|
||||
common_dialog_repaint (h);
|
||||
|
||||
old_first_panel_size = -1;
|
||||
old_horizontal_split = -1;
|
||||
old_output_lines = -1;
|
||||
|
||||
attrset (COLOR_NORMAL);
|
||||
dlg_erase (h);
|
||||
draw_box (h, 1, 2, h->lines - 2, h->cols - 4);
|
||||
draw_box (h, 2, 4, 6, first_width);
|
||||
draw_box (h, 8, 4, 4, first_width);
|
||||
draw_box (h, 2, 5 + first_width, 10, second_width);
|
||||
|
||||
attrset (COLOR_HOT_NORMAL);
|
||||
dlg_move (h, 1, (h->cols - strlen(layout_title))/2);
|
||||
addstr (layout_title);
|
||||
dlg_move (h, 2, 5);
|
||||
addstr (title1);
|
||||
dlg_move (h, 8, 5);
|
||||
@ -373,7 +372,6 @@ static void init_layout (void)
|
||||
|
||||
first_width = 19; /* length of line with '<' '>' buttons */
|
||||
|
||||
layout_title = _(" Layout ");
|
||||
title1 = _(" Panel split ");
|
||||
title2 = _(" Highlight... ");
|
||||
title3 = _(" Other options ");
|
||||
@ -421,7 +419,7 @@ static void init_layout (void)
|
||||
|
||||
/*
|
||||
* alex@bcs.zp.ua:
|
||||
* To be completely correct, one need to check if layout_title
|
||||
* To be completely correct, one need to check if the title
|
||||
* does not exceed dialog length and total length of 3 buttons
|
||||
* allows their placement in one row. But assuming this dialog
|
||||
* is wide enough, I don't include such a tests.
|
||||
|
@ -60,7 +60,7 @@ static int r_but;
|
||||
extern int use_internal_edit;
|
||||
|
||||
static int OX = 33, first_width = 27, second_width = 27;
|
||||
static char *configure_title, *title1, *title2, *title3;
|
||||
static char *title1, *title2, *title3;
|
||||
|
||||
static struct {
|
||||
char *text;
|
||||
@ -102,16 +102,14 @@ static int configure_callback (struct Dlg_head *h, int Id, int Msg)
|
||||
{
|
||||
switch (Msg) {
|
||||
case DLG_DRAW:
|
||||
common_dialog_repaint (h);
|
||||
|
||||
attrset (COLOR_NORMAL);
|
||||
dlg_erase (h);
|
||||
draw_box (h, 1, 2, h->lines - 2, h->cols - 4);
|
||||
draw_box (h, PY, PX, 8, first_width);
|
||||
draw_box (h, RY, RX, 5, first_width);
|
||||
draw_box (h, OY, OX, 15, second_width);
|
||||
|
||||
attrset (COLOR_HOT_NORMAL);
|
||||
dlg_move (h, 1, (h->cols - strlen(configure_title))/2);
|
||||
addstr (configure_title);
|
||||
dlg_move (h, OY, OX+1);
|
||||
addstr (title3);
|
||||
dlg_move (h, RY, RX+1);
|
||||
@ -142,7 +140,6 @@ static void init_configure (void)
|
||||
|
||||
/* Similar code is in layout.c (init_layout()) */
|
||||
|
||||
configure_title = _(" Configure options ");
|
||||
title1 = _(" Panel options ");
|
||||
title2 = _(" Pause after run... ");
|
||||
title3 = _(" Other options ");
|
||||
|
Loading…
Reference in New Issue
Block a user