* dlg.c (create_dlg): Take title instead of unused name as the
8-th argument. (x_set_dialog_title): Free old title. Mark this function obsolete. * achown.c: Use new create_dlg(). (do_enter_key): Provide titles for popups.
Этот коммит содержится в:
родитель
67cfc5d84d
Коммит
69a3777112
@ -1,5 +1,12 @@
|
|||||||
2002-09-02 Pavel Roskin <proski@gnu.org>
|
2002-09-02 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* dlg.c (create_dlg): Take title instead of unused name as the
|
||||||
|
8-th argument.
|
||||||
|
(x_set_dialog_title): Free old title. Mark this function
|
||||||
|
obsolete.
|
||||||
|
* achown.c: Use new create_dlg().
|
||||||
|
(do_enter_key): Provide titles for popups.
|
||||||
|
|
||||||
* dlg.c: Remove unused code, make functions static if possible.
|
* dlg.c: Remove unused code, make functions static if possible.
|
||||||
|
|
||||||
* chmod.c: Use common_dialog_repaint().
|
* chmod.c: Use common_dialog_repaint().
|
||||||
|
83
src/achown.c
83
src/achown.c
@ -242,85 +242,92 @@ static int chl_callback (Dlg_head * h, int Par, int Msg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_enter_key (Dlg_head *h, int f_pos)
|
static void
|
||||||
|
do_enter_key (Dlg_head * h, int f_pos)
|
||||||
{
|
{
|
||||||
Dlg_head *chl_dlg;
|
Dlg_head *chl_dlg;
|
||||||
WListbox *chl_list;
|
WListbox *chl_list;
|
||||||
struct passwd *chl_pass;
|
struct passwd *chl_pass;
|
||||||
struct group *chl_grp;
|
struct group *chl_grp;
|
||||||
WLEntry *fe;
|
WLEntry *fe;
|
||||||
int lxx, lyy, chl_end, b_pos;
|
int lxx, lyy, chl_end, b_pos;
|
||||||
|
int is_owner;
|
||||||
|
char *title;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
lxx = (COLS - 74) / 2 + ((f_pos == 3) ? 35 : 53);
|
is_owner = (f_pos == 3);
|
||||||
|
title = is_owner ? _("owner") : _("group");
|
||||||
|
|
||||||
|
lxx = (COLS - 74) / 2 + (is_owner ? 35 : 53);
|
||||||
lyy = (LINES - 13) / 2;
|
lyy = (LINES - 13) / 2;
|
||||||
chl_end = 0;
|
chl_end = 0;
|
||||||
|
|
||||||
chl_dlg = create_dlg (lyy, lxx, 13, 17, dialog_colors, chl_callback,
|
chl_dlg =
|
||||||
"[Advanced Chown]", "achown_enter", DLG_COMPACT);
|
create_dlg (lyy, lxx, 13, 17, dialog_colors, chl_callback,
|
||||||
|
"[Advanced Chown]", title, DLG_COMPACT);
|
||||||
|
|
||||||
/* get new listboxes */
|
/* get new listboxes */
|
||||||
chl_list = listbox_new (1, 1, 15, 11, 0, l_call, NULL);
|
chl_list = listbox_new (1, 1, 15, 11, 0, l_call, NULL);
|
||||||
|
|
||||||
listbox_add_item (chl_list, 0, 0, "<Unknown>", NULL);
|
listbox_add_item (chl_list, 0, 0, "<Unknown>", NULL);
|
||||||
|
|
||||||
if (f_pos == 3) {
|
if (is_owner) {
|
||||||
/* get and put user names in the listbox */
|
/* get and put user names in the listbox */
|
||||||
setpwent ();
|
setpwent ();
|
||||||
while ((chl_pass = getpwent ()))
|
while ((chl_pass = getpwent ()))
|
||||||
listbox_add_item (chl_list, 0, 0, chl_pass->pw_name, NULL);
|
listbox_add_item (chl_list, 0, 0, chl_pass->pw_name, NULL);
|
||||||
endpwent ();
|
endpwent ();
|
||||||
fe = listbox_search_text (chl_list, get_owner (sf_stat->st_uid));
|
fe = listbox_search_text (chl_list,
|
||||||
}
|
get_owner (sf_stat->st_uid));
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
/* get and put group names in the listbox */
|
/* get and put group names in the listbox */
|
||||||
setgrent ();
|
setgrent ();
|
||||||
while ((chl_grp = getgrent ())) {
|
while ((chl_grp = getgrent ())) {
|
||||||
listbox_add_item (chl_list, 0, 0, chl_grp->gr_name, NULL);
|
listbox_add_item (chl_list, 0, 0, chl_grp->gr_name, NULL);
|
||||||
}
|
}
|
||||||
endgrent ();
|
endgrent ();
|
||||||
fe = listbox_search_text (chl_list, get_group (sf_stat->st_gid));
|
fe = listbox_search_text (chl_list,
|
||||||
|
get_group (sf_stat->st_gid));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fe)
|
if (fe)
|
||||||
listbox_select_entry (chl_list, fe);
|
listbox_select_entry (chl_list, fe);
|
||||||
|
|
||||||
b_pos = chl_list->pos;
|
b_pos = chl_list->pos;
|
||||||
add_widget (chl_dlg, chl_list);
|
add_widget (chl_dlg, chl_list);
|
||||||
|
|
||||||
run_dlg (chl_dlg);
|
run_dlg (chl_dlg);
|
||||||
|
|
||||||
if (b_pos != chl_list->pos){
|
if (b_pos != chl_list->pos) {
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
if (f_pos == 3){
|
if (is_owner) {
|
||||||
chl_pass = getpwnam (chl_list->current->text);
|
chl_pass = getpwnam (chl_list->current->text);
|
||||||
if (chl_pass){
|
if (chl_pass) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
sf_stat->st_uid = chl_pass->pw_uid;
|
sf_stat->st_uid = chl_pass->pw_uid;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chl_grp = getgrnam (chl_list->current->text);
|
chl_grp = getgrnam (chl_list->current->text);
|
||||||
if (chl_grp){
|
if (chl_grp) {
|
||||||
sf_stat->st_gid = chl_grp->gr_gid;
|
sf_stat->st_gid = chl_grp->gr_gid;
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ok){
|
if (ok) {
|
||||||
ch_flags [f_pos + 6] = '+';
|
ch_flags[f_pos + 6] = '+';
|
||||||
get_ownership ();
|
get_ownership ();
|
||||||
}
|
}
|
||||||
dlg_focus (h);
|
dlg_focus (h);
|
||||||
if (ok)
|
if (ok)
|
||||||
print_flags ();
|
print_flags ();
|
||||||
}
|
}
|
||||||
if (chl_dlg->ret_value == KEY_LEFT){
|
if (chl_dlg->ret_value == KEY_LEFT) {
|
||||||
if (f_pos == 4)
|
if (!is_owner)
|
||||||
chl_end = 1;
|
chl_end = 1;
|
||||||
dlg_one_up (ch_dlg);
|
dlg_one_up (ch_dlg);
|
||||||
f_pos--;
|
f_pos--;
|
||||||
} else if (chl_dlg->ret_value == KEY_RIGHT) {
|
} else if (chl_dlg->ret_value == KEY_RIGHT) {
|
||||||
if (f_pos == 3)
|
if (is_owner)
|
||||||
chl_end = 1;
|
chl_end = 1;
|
||||||
dlg_one_down (ch_dlg);
|
dlg_one_down (ch_dlg);
|
||||||
f_pos++;
|
f_pos++;
|
||||||
@ -526,7 +533,8 @@ static int advanced_chown_callback (Dlg_head * h, int Par, int Msg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_chown_advanced (void)
|
static void
|
||||||
|
init_chown_advanced (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -538,9 +546,10 @@ static void init_chown_advanced (void)
|
|||||||
flag_pos = 0;
|
flag_pos = 0;
|
||||||
x_toggle = 070;
|
x_toggle = 070;
|
||||||
|
|
||||||
ch_dlg = create_dlg (0, 0, 13, 74, dialog_colors, advanced_chown_callback,
|
ch_dlg =
|
||||||
"[Advanced Chown]", "achown", DLG_CENTER);
|
create_dlg (0, 0, 13, 74, dialog_colors, advanced_chown_callback,
|
||||||
x_set_dialog_title (ch_dlg, _(" Chown advanced command "));
|
"[Advanced Chown]", _(" Chown advanced command "),
|
||||||
|
DLG_CENTER);
|
||||||
|
|
||||||
#define XTRACT(i) BY+chown_advanced_but[i].y, BX+chown_advanced_but[i].x, \
|
#define XTRACT(i) BY+chown_advanced_but[i].y, BX+chown_advanced_but[i].x, \
|
||||||
chown_advanced_but[i].ret_cmd, chown_advanced_but[i].flags, _(chown_advanced_but[i].text), \
|
chown_advanced_but[i].ret_cmd, chown_advanced_but[i].flags, _(chown_advanced_but[i].text), \
|
||||||
|
16
src/dlg.c
16
src/dlg.c
@ -212,10 +212,10 @@ int default_dlg_callback (Dlg_head *h, int id, int msg)
|
|||||||
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||||
const int *color_set,
|
const int *color_set,
|
||||||
int (*callback) (struct Dlg_head *, int, int),
|
int (*callback) (struct Dlg_head *, int, int),
|
||||||
char *help_ctx, char *name,
|
char *help_ctx, const char *title, int flags)
|
||||||
int flags)
|
|
||||||
{
|
{
|
||||||
Dlg_head *new_d;
|
Dlg_head *new_d;
|
||||||
|
char *t;
|
||||||
|
|
||||||
if (flags & DLG_CENTER){
|
if (flags & DLG_CENTER){
|
||||||
y1 = (LINES-lines)/2;
|
y1 = (LINES-lines)/2;
|
||||||
@ -234,6 +234,12 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
|||||||
new_d->cols = cols;
|
new_d->cols = cols;
|
||||||
new_d->lines = lines;
|
new_d->lines = lines;
|
||||||
new_d->flags = flags;
|
new_d->flags = flags;
|
||||||
|
|
||||||
|
/* Strip existing spaces, add one space before and after the title */
|
||||||
|
t = g_strstrip (g_strdup (title));
|
||||||
|
new_d->title = g_strconcat (" ", t, " ", NULL);
|
||||||
|
g_free (t);
|
||||||
|
|
||||||
return (new_d);
|
return (new_d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -956,10 +962,14 @@ int dlg_select_nth_widget (Dlg_head *h, int n)
|
|||||||
return dlg_select_widget (h, w->widget);
|
return dlg_select_widget (h, w->widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set dialog title. This function should be eliminated. */
|
||||||
void
|
void
|
||||||
x_set_dialog_title (Dlg_head * h, const char *title)
|
x_set_dialog_title (Dlg_head * h, const char *title)
|
||||||
{
|
{
|
||||||
char *t = g_strstrip (g_strdup (title));
|
char *t;
|
||||||
|
|
||||||
|
g_free (h->title);
|
||||||
|
t = g_strstrip (g_strdup (title));
|
||||||
h->title = g_strconcat (" ", t, " ", NULL);
|
h->title = g_strconcat (" ", t, " ", NULL);
|
||||||
g_free (t);
|
g_free (t);
|
||||||
}
|
}
|
||||||
|
10
src/dlg.h
10
src/dlg.h
@ -130,7 +130,11 @@ void draw_double_box (Dlg_head *h, int y, int x, int ys, int xs);
|
|||||||
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||||
const int *color_set,
|
const int *color_set,
|
||||||
int (*callback) (struct Dlg_head *, int, int),
|
int (*callback) (struct Dlg_head *, int, int),
|
||||||
char *help_ctx, char *name, int flags);
|
char *help_ctx, const char *title, int flags);
|
||||||
|
|
||||||
|
/* Set title - this function should go away */
|
||||||
|
void x_set_dialog_title (Dlg_head *h, const char *title);
|
||||||
|
|
||||||
|
|
||||||
/* The flags: */
|
/* The flags: */
|
||||||
#define DLG_BACKWARD 32 /* Tab order is reverse to the index order */
|
#define DLG_BACKWARD 32 /* Tab order is reverse to the index order */
|
||||||
@ -212,10 +216,6 @@ Widget *find_widget_type (Dlg_head *h, callback_fn signature);
|
|||||||
|
|
||||||
typedef void (*movefn)(void *, int);
|
typedef void (*movefn)(void *, int);
|
||||||
|
|
||||||
/* Layout definitions */
|
|
||||||
|
|
||||||
void x_set_dialog_title (Dlg_head *h, const char *title);
|
|
||||||
|
|
||||||
/* Used in load_prompt() */
|
/* Used in load_prompt() */
|
||||||
void update_cursor (Dlg_head *h);
|
void update_cursor (Dlg_head *h);
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user