Rename hotkey API:

* parse_hotkey to hotkey_new;
  * release_hotkey to hotkey_free.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-12-14 11:50:04 +03:00
parent d8a7a87747
commit 32a4b1ac85
6 changed files with 18 additions and 18 deletions

View File

@ -169,7 +169,7 @@ button_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm
}
case MSG_DESTROY:
release_hotkey (b->text);
hotkey_free (b->text);
return MSG_HANDLED;
default:
@ -213,7 +213,7 @@ button_new (int y, int x, int action, button_flags_t flags, const char *text, bc
b->action = action;
b->flags = flags;
b->text = parse_hotkey (text);
b->text = hotkey_new (text);
widget_init (w, y, x, 1, button_get_len (b), button_default_callback,
button_mouse_default_callback);
w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR | WOP_WANT_HOTKEY;
@ -240,8 +240,8 @@ button_set_text (WButton * b, const char *text)
{
Widget *w = WIDGET (b);
release_hotkey (b->text);
b->text = parse_hotkey (text);
hotkey_free (b->text);
b->text = hotkey_new (text);
b->hotpos = (b->text.hotkey != NULL) ? str_term_width1 (b->text.start) : -1;
w->cols = button_get_len (b);
widget_draw (w);

View File

@ -95,7 +95,7 @@ check_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
}
case MSG_DESTROY:
release_hotkey (c->text);
hotkey_free (c->text);
return MSG_HANDLED;
default:
@ -138,7 +138,7 @@ check_new (int y, int x, gboolean state, const char *text)
c = g_new (WCheck, 1);
w = WIDGET (c);
c->text = parse_hotkey (text);
c->text = hotkey_new (text);
/* 4 is width of "[X] " */
widget_init (w, y, x, 1, 4 + hotkey_width (c->text), check_callback, check_mouse_callback);
w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR | WOP_WANT_HOTKEY;

View File

@ -872,7 +872,7 @@ menu_entry_create (const char *name, long command)
entry = g_new (menu_entry_t, 1);
entry->first_letter = ' ';
entry->text = parse_hotkey (name);
entry->text = hotkey_new (name);
entry->command = command;
entry->shortcut = NULL;
@ -886,7 +886,7 @@ menu_entry_free (menu_entry_t * entry)
{
if (entry != NULL)
{
release_hotkey (entry->text);
hotkey_free (entry->text);
g_free (entry->shortcut);
g_free (entry);
}
@ -901,7 +901,7 @@ create_menu (const char *name, GList * entries, const char *help_node)
menu = g_new (menu_t, 1);
menu->start_x = 0;
menu->text = parse_hotkey (name);
menu->text = hotkey_new (name);
menu->entries = entries;
menu->max_entry_len = 1;
menu->max_hotkey_len = 0;
@ -916,8 +916,8 @@ create_menu (const char *name, GList * entries, const char *help_node)
void
menu_set_name (menu_t * menu, const char *name)
{
release_hotkey (menu->text);
menu->text = parse_hotkey (name);
hotkey_free (menu->text);
menu->text = hotkey_new (name);
}
/* --------------------------------------------------------------------------------------------- */
@ -925,7 +925,7 @@ menu_set_name (menu_t * menu, const char *name)
void
destroy_menu (menu_t * menu)
{
release_hotkey (menu->text);
hotkey_free (menu->text);
g_list_free_full (menu->entries, (GDestroyNotify) menu_entry_free);
g_free (menu->help_node);
g_free (menu);

View File

@ -135,7 +135,7 @@ radio_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
case MSG_DESTROY:
for (i = 0; i < r->count; i++)
release_hotkey (r->texts[i]);
hotkey_free (r->texts[i]);
g_free (r->texts);
return MSG_HANDLED;
@ -188,7 +188,7 @@ radio_new (int y, int x, int count, const char **texts)
{
int width;
r->texts[i] = parse_hotkey (texts[i]);
r->texts[i] = hotkey_new (texts[i]);
width = hotkey_width (r->texts[i]);
wmax = MAX (width, wmax);
}

View File

@ -116,7 +116,7 @@ widget_reorder (GList * l, gboolean set_top)
/* --------------------------------------------------------------------------------------------- */
struct hotkey_t
parse_hotkey (const char *text)
hotkey_new (const char *text)
{
hotkey_t result;
const char *cp, *p;
@ -151,7 +151,7 @@ parse_hotkey (const char *text)
/* --------------------------------------------------------------------------------------------- */
void
release_hotkey (const hotkey_t hotkey)
hotkey_free (const hotkey_t hotkey)
{
g_free (hotkey.start);
g_free (hotkey.hotkey);

View File

@ -164,9 +164,9 @@ typedef struct hotkey_t
/*** declarations of public functions ************************************************************/
/* create hotkey from text */
hotkey_t parse_hotkey (const char *text);
hotkey_t hotkey_new (const char *text);
/* release hotkey, free all mebers of hotkey_t */
void release_hotkey (const hotkey_t hotkey);
void hotkey_free (const hotkey_t hotkey);
/* return width on terminal of hotkey */
int hotkey_width (const hotkey_t hotkey);
/* draw hotkey of widget */