0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.2717: GTK menu items don't show a tooltip

Problem:    GTK menu items don't show a tooltip.
Solution:   Add a callback to show the tooltip. (Leonid V. Fedorenchik,
            closes #8067, closes #7810)
This commit is contained in:
Bram Moolenaar
2021-04-05 14:13:20 +02:00
parent 0b94e297af
commit ce5b06a6a9
2 changed files with 29 additions and 2 deletions

View File

@@ -684,6 +684,28 @@ menu_item_activate(GtkWidget *widget UNUSED, gpointer data)
gui_menu_cb((vimmenu_T *)data);
}
static void
menu_item_select(GtkWidget *widget UNUSED, gpointer data)
{
vimmenu_T *menu;
char_u *tooltip;
static int did_msg = FALSE;
menu = (vimmenu_T *)data;
tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]);
if (tooltip != NULL && utf_valid_string(tooltip, NULL))
{
msg((char *)tooltip);
did_msg = TRUE;
}
else if (did_msg)
{
msg("");
did_msg = FALSE;
}
CONVERT_TO_UTF8_FREE(tooltip);
}
void
gui_mch_add_menu_item(vimmenu_T *menu, int idx)
{
@@ -800,8 +822,12 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx)
menu->id, idx);
if (menu->id != NULL)
{
g_signal_connect(G_OBJECT(menu->id), "activate",
G_CALLBACK(menu_item_activate), menu);
g_signal_connect(G_OBJECT(menu->id), "select",
G_CALLBACK(menu_item_select), menu);
}
}
}
#endif // FEAT_MENU
@@ -892,8 +918,7 @@ get_menu_position(vimmenu_T *menu)
void
gui_mch_menu_set_tip(vimmenu_T *menu)
{
if (menu->id != NULL && menu->parent != NULL
&& gui.toolbar != NULL && menu_is_toolbar(menu->parent->name))
if (menu->id != NULL && menu->parent != NULL && gui.toolbar != NULL)
{
char_u *tooltip;

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2717,
/**/
2716,
/**/