[vim/vim] :tmenu does not show menu tip in GTK3 X11 GUI (#7810)

16 views
Skip to first unread message

Leonid V. Fedorenchik

unread,
Feb 9, 2021, 10:23:40 PM2/9/21
to vim/vim, Subscribed

Describe the bug

:tmenu does not show menu tip in GTK3 X11 GUI

To Reproduce
Following :tmenu documentation:

  1. Run gvim --clean
  2. :amenu MyMenu.Hello :echo "Hello"<CR>
  3. :tmenu MyMenu.Hello Displays a greeting.
  4. Tip is not shown in the command-line area when the mouse is over that item.

Expected behavior
Tip is shown in the command-line area when the mouse is over that item.

Environment (please complete the following information):

  • Vim version: 8.2.2489
  • OS: Manjaro KDE
  • GTK3 GUI


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Leonid V. Fedorenchik

unread,
Feb 15, 2021, 11:27:16 AM2/15/21
to vim/vim, Subscribed

I tried with 8.2.2000 - can repro this bug.
Also, test test_menu.vim (make test_menu) passes - seems broken test?
PS:
I tried to build earlier vim versions 8.2.0000, 8.2.0500, 8.2.1000 - but they all fail to compile with different python interpreter related errors (tried both python 3.9 and 3.7 with pipenv)

Leonid V. Fedorenchik

unread,
Mar 21, 2021, 9:52:40 AM3/21/21
to vim/vim, Subscribed

This patch adds menu item tooltips & prints message at bottom of the screen. The part around msg() call is wrong though, but it works. Would appreciate any help on how to improve the patch.

diff --git a/src/gui_gtk.c b/src/gui_gtk.c
index 48910b287..1cd21ef4d 100644
--- a/src/gui_gtk.c
+++ b/src/gui_gtk.c
@@ -684,6 +684,20 @@ menu_item_activate(GtkWidget *widget UNUSED, gpointer data)
     gui_menu_cb((vimmenu_T *)data);
 }
 
+    static void
+menu_item_select(GtkWidget *widget UNUSED, gpointer data)
+{
+    char_u *tooltip;
+    vimmenu_T *menu;
+
+    menu = (vimmenu_T *)data;
+    tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]);
+    if (tooltip != NULL)
+       msg(tooltip);
+    else
+       msg("");
+}
+
     void
 gui_mch_add_menu_item(vimmenu_T *menu, int idx)
 {
@@ -799,9 +813,12 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx)
        gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id),
                menu->id, idx);
 
-       if (menu->id != NULL)
+       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 +909,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;
 

Bram Moolenaar

unread,
Apr 5, 2021, 8:14:00 AM4/5/21
to vim/vim, Subscribed

Closed #7810 via ce5b06a.

Reply all
Reply to author
Forward
0 new messages