mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
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:
parent
edddd5f5d3
commit
dad66d278b
34
src/widget.c
34
src/widget.c
@ -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,27 +333,21 @@ 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,
|
||||
if (b->text.hotkey != NULL)
|
||||
return g_strconcat (b->text.start, "&", b->text.hotkey,
|
||||
b->text.end, NULL);
|
||||
else
|
||||
return g_strdup (b->text.start);
|
||||
return g_strdup (b->text.start);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user