Ticked #1552: fixed non-standard button location in dialogs.

First step: refactoring of WButton widget API.
(button_len): renamed to button_get_len and made global.
(button_get_text): const argument.
Removed trailing spaces.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-09-06 10:35:00 +04:00
parent edddd5f5d3
commit dad66d278b
2 changed files with 16 additions and 21 deletions

View File

@ -290,11 +290,11 @@ button_event (Gpm_Event *event, void *data)
return MOU_NORMAL;
}
static int
button_len (const struct hotkey_t text, unsigned int flags)
int
button_get_len (const WButton *b)
{
int ret = hotkey_width (text);
switch (flags) {
int ret = hotkey_width (b->text);
switch (b->flags) {
case DEFPUSH_BUTTON:
ret += 6;
break;
@ -317,13 +317,13 @@ button_new (int y, int x, int action, int flags, const char *text,
{
WButton *b = g_new (WButton, 1);
b->text = parse_hotkey (text);
init_widget (&b->widget, y, x, 1, button_len (b->text, flags),
button_callback, button_event);
b->action = action;
b->flags = flags;
b->text = parse_hotkey (text);
init_widget (&b->widget, y, x, 1, button_get_len (b),
button_callback, button_event);
b->selected = 0;
b->callback = callback;
widget_want_hotkey (b->widget, 1);
@ -333,7 +333,7 @@ button_new (int y, int x, int action, int flags, const char *text,
}
const char *
button_get_text (WButton *b)
button_get_text (const WButton *b)
{
if (b->text.hotkey != NULL)
return g_strconcat (b->text.start, "&", b->text.hotkey,
@ -345,15 +345,9 @@ button_get_text (WButton *b)
void
button_set_text (WButton *b, const char *text)
{
/*
g_free (b->text);
b->text = g_strdup (text);
b->widget.cols = button_len (text, b->flags);
button_scan_hotkey(b);
*/
release_hotkey (b->text);
b->text = parse_hotkey (text);
b->widget.cols = button_len (b->text, b->flags);
b->widget.cols = button_get_len (b);
dlg_redraw (b->widget.parent);
}

View File

@ -225,8 +225,9 @@ void gauge_show (WGauge *g, int shown);
/* Buttons */
/* return copy of button text */
const char *button_get_text (WButton *b);
const char *button_get_text (const WButton *b);
void button_set_text (WButton *b, const char *text);
int button_get_len (const WButton *b);
/* Listbox manager */
WLEntry *listbox_get_data (WListbox *l, int pos);