]> granicus.if.org Git - vim/commitdiff
patch 8.2.2717: GTK menu items don't show a tooltip v8.2.2717
authorBram Moolenaar <Bram@vim.org>
Mon, 5 Apr 2021 12:13:20 +0000 (14:13 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 5 Apr 2021 12:13:20 +0000 (14:13 +0200)
Problem:    GTK menu items don't show a tooltip.
Solution:   Add a callback to show the tooltip. (Leonid V. Fedorenchik,
            closes #8067, closes #7810)

src/gui_gtk.c
src/version.c

index c172fa49d0f4058f748204d5548a5154ec9c33fd..3c435f9609367d201d7bc151568d387f1dfda6b5 100644 (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;
 
index d38b6ba065427ca254c657d9ac57f2b987557b9a..f22d0cb2506ff891a88b99571aba176ad10ba283 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2717,
 /**/
     2716,
 /**/