* chmod.c: Use common_dialog_repaint().

* chown.c: Likewise.
* layout.c: Likewise.
* option.c: Likewise.
This commit is contained in:
Pavel Roskin 2002-09-02 18:03:15 +00:00
parent e000c69683
commit 6f0c076c65
5 changed files with 112 additions and 115 deletions

View File

@ -1,5 +1,10 @@
2002-09-02 Pavel Roskin <proski@gnu.org> 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 ... * wtools.c (common_dialog_callback): Fold into ...
* dlg.c (default_dlg_callback): ... this. Don't redraw dialogs * dlg.c (default_dlg_callback): ... this. Don't redraw dialogs
that don't have colors. Adjust all dependencies. that don't have colors. Adjust all dependencies.

View File

@ -45,7 +45,6 @@
#include "../vfs/vfs.h" #include "../vfs/vfs.h"
static int single_set; static int single_set;
static struct Dlg_head *ch_dlg;
#define PX 5 #define PX 5
#define PY 2 #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 char *c_fname, *c_fown, *c_fgrp;
static WLabel *statl; static WLabel *statl;
static int normal_color;
static int title_color;
static int selection_color;
static struct { static struct {
mode_t mode; mode_t mode;
@ -112,54 +108,51 @@ static struct {
{ B_ALL, NORMAL_BUTTON, 0, 0, N_("Set &all") }, { 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; 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) ? '*' : ' '); 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)
{ {
attrset (COLOR_NORMAL); common_dialog_repaint (h);
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);
dlg_move (ch_dlg, FY + 1, FX + 2); attrset (COLOR_NORMAL);
draw_box (h, PY, PX, PERMISSIONS + 2, 33);
draw_box (h, FY, FX, 10, 25);
dlg_move (h, FY + 1, FX + 2);
addstr (_("Name")); addstr (_("Name"));
dlg_move (ch_dlg, FY + 3, FX + 2); dlg_move (h, FY + 3, FX + 2);
addstr (_("Permissions (Octal)")); addstr (_("Permissions (Octal)"));
dlg_move (ch_dlg, FY + 5, FX + 2); dlg_move (h, FY + 5, FX + 2);
addstr (_("Owner name")); addstr (_("Owner name"));
dlg_move (ch_dlg, FY + 7, FX + 2); dlg_move (h, FY + 7, FX + 2);
addstr (_("Group name")); addstr (_("Group name"));
attrset (title_color); dlg_move (h, TY, TX);
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);
addstr (_("Use SPACE to change")); addstr (_("Use SPACE to change"));
dlg_move (ch_dlg, TY + 1, TX); dlg_move (h, TY + 1, TX);
addstr (_("an option, ARROW KEYS")); addstr (_("an option, ARROW KEYS"));
dlg_move (ch_dlg, TY + 2, TX); dlg_move (h, TY + 2, TX);
addstr (_("to move between options")); 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")); 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) 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; c_stat ^= check_perm[Par - BUTTONS + single_set * 2].mode;
g_snprintf (buffer, sizeof (buffer), "%o", c_stat); g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
label_set_text (statl, buffer); label_set_text (statl, buffer);
chmod_toggle_select (); chmod_toggle_select (h);
mode_change = 1; mode_change = 1;
} }
break; break;
case DLG_KEY: case DLG_KEY:
if ((Par == 'T' || Par == 't' || Par == KEY_IC) && if ((Par == 'T' || Par == 't' || Par == KEY_IC) &&
ch_dlg->current->dlg_id >= BUTTONS - single_set * 2) { h->current->dlg_id >= BUTTONS - single_set * 2) {
chmod_toggle_select (); chmod_toggle_select (h);
if (Par == KEY_IC) if (Par == KEY_IC)
dlg_one_down (ch_dlg); dlg_one_down (h);
return 1; return 1;
} }
break; break;
case DLG_DRAW: case DLG_DRAW:
chmod_refresh (); chmod_refresh (h);
break; break;
} }
return 0; return 0;
} }
static void init_chmod (void) Dlg_head *
init_chmod (void)
{ {
int i; int i;
Dlg_head *ch_dlg;
do_refresh (); do_refresh ();
end_chmod = c_file = need_update = 0; end_chmod = c_file = need_update = 0;
single_set = (cpanel->marked < 2) ? 2 : 0; single_set = (cpanel->marked < 2) ? 2 : 0;
if (use_colors){ ch_dlg =
normal_color = COLOR_NORMAL; create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
title_color = COLOR_HOT_NORMAL; chmod_callback, "[Chmod]", "chmod", DLG_CENTER);
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,
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, \ x_set_dialog_title (ch_dlg, _("Chmod command"));
chmod_but[i].ret_cmd, chmod_but[i].flags, _(chmod_but[i].text), 0, 0, NULL
for (i = 0; i < BUTTONS; i++) { for (i = 0; i < BUTTONS; i++) {
if (i == 2 && single_set) if (i == 2 && single_set)
break; break;
else 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++) { for (i = 0; i < PERMISSIONS; i++) {
check_perm[i].check = check_new (PY + (PERMISSIONS - i), PX + 2, check_perm[i].check =
XTRACT2 (i)); check_new (PY + (PERMISSIONS - i), PX + 2, 0,
_(check_perm[i].text), NULL);
add_widget (ch_dlg, check_perm[i].check); add_widget (ch_dlg, check_perm[i].check);
} }
return ch_dlg;
} }
int stat_file (char *filename, struct stat *st) int stat_file (char *filename, struct stat *st)
@ -293,9 +282,10 @@ void chmod_cmd (void)
char *fname; char *fname;
int i; int i;
struct stat sf_stat; struct stat sf_stat;
Dlg_head *ch_dlg;
do { /* do while any files remaining */ do { /* do while any files remaining */
init_chmod (); ch_dlg = init_chmod ();
if (cpanel->marked) if (cpanel->marked)
fname = next_file (); /* next marked file */ fname = next_file (); /* next marked file */
else else

View File

@ -63,7 +63,6 @@
#define B_SETUSR B_USER + 1 #define B_SETUSR B_USER + 1
#define B_SETGRP B_USER + 2 #define B_SETGRP B_USER + 2
static struct Dlg_head *ch_dlg;
static int need_update, end_chown; static int need_update, end_chown;
static int current_file; static int current_file;
static int single_set; static int single_set;
@ -93,36 +92,33 @@ static struct {
}; };
static void static void
chown_refresh (void) chown_refresh (Dlg_head *h)
{ {
attrset (COLOR_NORMAL); common_dialog_repaint (h);
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);
attrset (COLOR_NORMAL); 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 ")); addstr (_(" Name "));
dlg_move (ch_dlg, TY + 3, TX + 1); dlg_move (h, TY + 3, TX + 1);
addstr (_(" Owner name ")); addstr (_(" Owner name "));
dlg_move (ch_dlg, TY + 5, TX + 1); dlg_move (h, TY + 5, TX + 1);
addstr (_(" Group name ")); addstr (_(" Group name "));
dlg_move (ch_dlg, TY + 7, TX + 1); dlg_move (h, TY + 7, TX + 1);
addstr (_(" Size ")); addstr (_(" Size "));
dlg_move (ch_dlg, TY + 9, TX + 1); dlg_move (h, TY + 9, TX + 1);
addstr (_(" Permission ")); addstr (_(" Permission "));
attrset (COLOR_HOT_NORMAL); attrset (COLOR_HOT_NORMAL);
dlg_move (ch_dlg, 1, 28); dlg_move (h, UY, UX + 1);
addstr (_(" Chown command "));
dlg_move (ch_dlg, UY, UX + 1);
addstr (_(" User name ")); addstr (_(" User name "));
dlg_move (ch_dlg, GY, GX + 1); dlg_move (h, GY, GX + 1);
addstr (_(" Group name ")); addstr (_(" Group name "));
dlg_move (ch_dlg, TY, TX + 1); dlg_move (h, TY, TX + 1);
addstr (_(" File ")); addstr (_(" File "));
} }
@ -140,8 +136,8 @@ chown_callback (Dlg_head * h, int Par, int Msg)
{ {
switch (Msg) { switch (Msg) {
case DLG_DRAW: case DLG_DRAW:
chown_refresh (); chown_refresh (h);
break; break;
} }
return 0; return 0;
} }
@ -152,53 +148,63 @@ l_call (void *data)
return 1; return 1;
} }
static void static Dlg_head *
init_chown (void) init_chown (void)
{ {
int i; int i;
struct passwd *l_pass; struct passwd *l_pass;
struct group *l_grp; struct group *l_grp;
Dlg_head *ch_dlg;
do_refresh (); do_refresh ();
end_chown = need_update = current_file = 0; end_chown = need_update = current_file = 0;
single_set = (cpanel->marked < 2) ? 3 : 0; single_set = (cpanel->marked < 2) ? 3 : 0;
ch_dlg = create_dlg (0, 0, 18, 74, dialog_colors, chown_callback, ch_dlg =
"[Chown]", "chown", DLG_CENTER); create_dlg (0, 0, 18, 74, dialog_colors, chown_callback, "[Chown]",
"chown", DLG_CENTER);
x_set_dialog_title (ch_dlg, _(" Chown command "));
#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 for (i = 0; i < BUTTONS - single_set; i++)
add_widget (ch_dlg,
for (i = 0; i < BUTTONS-single_set; i++) button_new (BY + chown_but[i].y, BX + chown_but[i].x,
add_widget (ch_dlg, button_new (XTRACT (i))); chown_but[i].ret_cmd, chown_but[i].flags,
_(chown_but[i].text), 0, 0, NULL));
/* Add the widgets for the file information */ /* 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++) {
for (i = 0; i < LABELS; i++){ chown_label[i].l =
chown_label [i].l = label_new (LX (i)); label_new (chown_label[i].y, chown_label[i].x, "", NULL);
add_widget (ch_dlg, chown_label [i].l); add_widget (ch_dlg, chown_label[i].l);
} }
/* get new listboxes */ /* get new listboxes */
l_user = listbox_new (UY + 1, UX + 1, 19, 10, 0, l_call, NULL); 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); 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); 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 ())) { while ((l_pass = getpwent ())) {
listbox_add_item (l_user, 0, 0, l_pass->pw_name, NULL); listbox_add_item (l_user, 0, 0, l_pass->pw_name, NULL);
} }
endpwent (); endpwent ();
setgrent (); /* get and put group names in the listbox */ /* get and put group names in the listbox */
setgrent ();
while ((l_grp = getgrent ())) { while ((l_grp = getgrent ())) {
listbox_add_item (l_group, 0, 0, l_grp->gr_name, NULL); listbox_add_item (l_group, 0, 0, l_grp->gr_name, NULL);
} }
endgrent (); endgrent ();
/* add listboxes to the dialogs */
add_widget (ch_dlg, l_group); 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 static void
@ -242,12 +248,13 @@ chown_cmd (void)
char *fname; char *fname;
struct stat sf_stat; struct stat sf_stat;
WLEntry *fe; WLEntry *fe;
Dlg_head *ch_dlg;
uid_t new_user; uid_t new_user;
gid_t new_group; gid_t new_group;
char buffer [BUF_TINY]; char buffer [BUF_TINY];
do { /* do while any files remaining */ do { /* do while any files remaining */
init_chown (); ch_dlg = init_chown ();
new_user = new_group = -1; new_user = new_group = -1;
if (cpanel->marked) if (cpanel->marked)

View File

@ -177,7 +177,7 @@ static struct {
}; };
static int first_width, second_width; 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; 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: case DLG_DRAW:
/*When repainting the whole dialog (e.g. with C-l) we have to /*When repainting the whole dialog (e.g. with C-l) we have to
update everything*/ update everything*/
common_dialog_repaint (h);
old_first_panel_size = -1; old_first_panel_size = -1;
old_horizontal_split = -1; old_horizontal_split = -1;
old_output_lines = -1; old_output_lines = -1;
attrset (COLOR_NORMAL); 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, 2, 4, 6, first_width);
draw_box (h, 8, 4, 4, first_width); draw_box (h, 8, 4, 4, first_width);
draw_box (h, 2, 5 + first_width, 10, second_width); draw_box (h, 2, 5 + first_width, 10, second_width);
attrset (COLOR_HOT_NORMAL); attrset (COLOR_HOT_NORMAL);
dlg_move (h, 1, (h->cols - strlen(layout_title))/2);
addstr (layout_title);
dlg_move (h, 2, 5); dlg_move (h, 2, 5);
addstr (title1); addstr (title1);
dlg_move (h, 8, 5); dlg_move (h, 8, 5);
@ -373,7 +372,6 @@ static void init_layout (void)
first_width = 19; /* length of line with '<' '>' buttons */ first_width = 19; /* length of line with '<' '>' buttons */
layout_title = _(" Layout ");
title1 = _(" Panel split "); title1 = _(" Panel split ");
title2 = _(" Highlight... "); title2 = _(" Highlight... ");
title3 = _(" Other options "); title3 = _(" Other options ");
@ -421,7 +419,7 @@ static void init_layout (void)
/* /*
* alex@bcs.zp.ua: * 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 * does not exceed dialog length and total length of 3 buttons
* allows their placement in one row. But assuming this dialog * allows their placement in one row. But assuming this dialog
* is wide enough, I don't include such a tests. * is wide enough, I don't include such a tests.

View File

@ -60,7 +60,7 @@ static int r_but;
extern int use_internal_edit; extern int use_internal_edit;
static int OX = 33, first_width = 27, second_width = 27; static int OX = 33, first_width = 27, second_width = 27;
static char *configure_title, *title1, *title2, *title3; static char *title1, *title2, *title3;
static struct { static struct {
char *text; char *text;
@ -102,16 +102,14 @@ static int configure_callback (struct Dlg_head *h, int Id, int Msg)
{ {
switch (Msg) { switch (Msg) {
case DLG_DRAW: case DLG_DRAW:
common_dialog_repaint (h);
attrset (COLOR_NORMAL); 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, PY, PX, 8, first_width);
draw_box (h, RY, RX, 5, first_width); draw_box (h, RY, RX, 5, first_width);
draw_box (h, OY, OX, 15, second_width); draw_box (h, OY, OX, 15, second_width);
attrset (COLOR_HOT_NORMAL); attrset (COLOR_HOT_NORMAL);
dlg_move (h, 1, (h->cols - strlen(configure_title))/2);
addstr (configure_title);
dlg_move (h, OY, OX+1); dlg_move (h, OY, OX+1);
addstr (title3); addstr (title3);
dlg_move (h, RY, RX+1); dlg_move (h, RY, RX+1);
@ -142,7 +140,6 @@ static void init_configure (void)
/* Similar code is in layout.c (init_layout()) */ /* Similar code is in layout.c (init_layout()) */
configure_title = _(" Configure options ");
title1 = _(" Panel options "); title1 = _(" Panel options ");
title2 = _(" Pause after run... "); title2 = _(" Pause after run... ");
title3 = _(" Other options "); title3 = _(" Other options ");