* 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.
This commit is contained in:
Pavel Roskin 2002-09-02 19:24:23 +00:00
parent 67cfc5d84d
commit 69a3777112
4 changed files with 71 additions and 45 deletions

View File

@ -1,5 +1,12 @@
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.
* chmod.c: Use common_dialog_repaint().

View File

@ -242,85 +242,92 @@ static int chl_callback (Dlg_head * h, int Par, int Msg)
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;
WListbox *chl_list;
struct passwd *chl_pass;
struct group *chl_grp;
WLEntry *fe;
int lxx, lyy, chl_end, b_pos;
struct passwd *chl_pass;
struct group *chl_grp;
WLEntry *fe;
int lxx, lyy, chl_end, b_pos;
int is_owner;
char *title;
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;
chl_end = 0;
chl_dlg = create_dlg (lyy, lxx, 13, 17, dialog_colors, chl_callback,
"[Advanced Chown]", "achown_enter", DLG_COMPACT);
chl_dlg =
create_dlg (lyy, lxx, 13, 17, dialog_colors, chl_callback,
"[Advanced Chown]", title, DLG_COMPACT);
/* get new listboxes */
chl_list = listbox_new (1, 1, 15, 11, 0, l_call, 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 */
setpwent ();
while ((chl_pass = getpwent ()))
listbox_add_item (chl_list, 0, 0, chl_pass->pw_name, NULL);
endpwent ();
fe = listbox_search_text (chl_list, get_owner (sf_stat->st_uid));
}
else
{
fe = listbox_search_text (chl_list,
get_owner (sf_stat->st_uid));
} else {
/* get and put group names in the listbox */
setgrent ();
setgrent ();
while ((chl_grp = getgrent ())) {
listbox_add_item (chl_list, 0, 0, chl_grp->gr_name, NULL);
}
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)
listbox_select_entry (chl_list, fe);
b_pos = chl_list->pos;
add_widget (chl_dlg, chl_list);
run_dlg (chl_dlg);
if (b_pos != chl_list->pos){
if (b_pos != chl_list->pos) {
int ok = 0;
if (f_pos == 3){
if (is_owner) {
chl_pass = getpwnam (chl_list->current->text);
if (chl_pass){
if (chl_pass) {
ok = 1;
sf_stat->st_uid = chl_pass->pw_uid;
}
} else {
chl_grp = getgrnam (chl_list->current->text);
if (chl_grp){
if (chl_grp) {
sf_stat->st_gid = chl_grp->gr_gid;
ok = 1;
}
}
if (ok){
ch_flags [f_pos + 6] = '+';
if (ok) {
ch_flags[f_pos + 6] = '+';
get_ownership ();
}
dlg_focus (h);
if (ok)
print_flags ();
}
if (chl_dlg->ret_value == KEY_LEFT){
if (f_pos == 4)
if (chl_dlg->ret_value == KEY_LEFT) {
if (!is_owner)
chl_end = 1;
dlg_one_up (ch_dlg);
f_pos--;
} else if (chl_dlg->ret_value == KEY_RIGHT) {
if (f_pos == 3)
if (is_owner)
chl_end = 1;
dlg_one_down (ch_dlg);
f_pos++;
@ -526,7 +533,8 @@ static int advanced_chown_callback (Dlg_head * h, int Par, int Msg)
return 0;
}
static void init_chown_advanced (void)
static void
init_chown_advanced (void)
{
int i;
@ -538,9 +546,10 @@ static void init_chown_advanced (void)
flag_pos = 0;
x_toggle = 070;
ch_dlg = create_dlg (0, 0, 13, 74, dialog_colors, advanced_chown_callback,
"[Advanced Chown]", "achown", DLG_CENTER);
x_set_dialog_title (ch_dlg, _(" Chown advanced command "));
ch_dlg =
create_dlg (0, 0, 13, 74, dialog_colors, advanced_chown_callback,
"[Advanced Chown]", _(" Chown advanced command "),
DLG_CENTER);
#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), \

View File

@ -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,
const int *color_set,
int (*callback) (struct Dlg_head *, int, int),
char *help_ctx, char *name,
int flags)
char *help_ctx, const char *title, int flags)
{
Dlg_head *new_d;
char *t;
if (flags & DLG_CENTER){
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->lines = lines;
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);
}
@ -956,10 +962,14 @@ int dlg_select_nth_widget (Dlg_head *h, int n)
return dlg_select_widget (h, w->widget);
}
/* Set dialog title. This function should be eliminated. */
void
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);
g_free (t);
}

View File

@ -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,
const int *color_set,
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: */
#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);
/* Layout definitions */
void x_set_dialog_title (Dlg_head *h, const char *title);
/* Used in load_prompt() */
void update_cursor (Dlg_head *h);