To: vim-dev@vim.org Subject: Patch 6.1.433 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.433 Problem: ":popup" only works for Win32. Solution: Add ":popup" support for GTK. (Daniel Elstner) Files: runtime/doc/gui.txt, src/ex_docmd.c, src/gui_gtk.c, src/menu.c, src/proto/gui_gtk.pro *** ../vim61.432/runtime/doc/gui.txt Tue May 7 20:49:56 2002 --- runtime/doc/gui.txt Fri Mar 28 19:35:32 2003 *************** *** 1,4 **** ! *gui.txt* For Vim version 6.1. Last change: 2002 May 07 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *gui.txt* For Vim version 6.1. Last change: 2003 Mar 28 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 692,700 **** 29 WinMaxWidth make current window use many columns 30 WinMinWidth make current window use few columns ! *win32-hidden-menus* ! In the Win32 GUI, starting a menu name with ']' excludes that menu from the ! main menu bar. You must then use the |:tearoff| command to display it. *popup-menu* In the Win32, GTK, Motif, Athena and Photon GUI, you can define the special --- 695,704 ---- 29 WinMaxWidth make current window use many columns 30 WinMinWidth make current window use few columns ! *hidden-menus* *win32-hidden-menus* ! In the Win32 and GTK+ GUI, starting a menu name with ']' excludes that menu ! from the main menu bar. You must then use the |:popup| or |:tearoff| command ! to display it. *popup-menu* In the Win32, GTK, Motif, Athena and Photon GUI, you can define the special *************** *** 770,780 **** If you do not want to remove a menu, but disable it for a moment, this can be done by adding the "enable" or "disable" keyword to a ":menu" command. Examples: > ! :menu disable File.Open :amenu enable * ! :amenu disable Tools.* ! The command applies to the modes as used with all menu commands. When the argument is "*", all menus are affected. Otherwise the given menu name and all existing submenus below it are affected. --- 774,785 ---- If you do not want to remove a menu, but disable it for a moment, this can be done by adding the "enable" or "disable" keyword to a ":menu" command. Examples: > ! :menu disable &File.&Open\.\.\. :amenu enable * ! :amenu disable &Tools.* ! The command applies to the modes as used with all menu commands. Note that ! characters like "&" need to be included for translated names to be found. When the argument is "*", all menus are affected. Otherwise the given menu name and all existing submenus below it are affected. *************** *** 796,802 **** the key. |<>|) ! Tooltips & Menu tips See section |42.4| in the user manual. --- 801,807 ---- the key. |<>|) ! 5.8 Tooltips & Menu tips See section |42.4| in the user manual. *************** *** 826,834 **** And delete it with: > :tunmenu MyMenu.Hello - When using the GTK GUI, and Vim has already opened the GUI window, the tooltip - must be defined before the ToolBar menu. Otherwise it won't show up. - Tooltips are currently only supported for the X11 and Win32 GUI. However, they should appear for the other gui platforms in the not too distant future. --- 831,836 ---- *************** *** 841,850 **** a menu item - you don't need to do a :tunmenu as well. ! 5.8 Popup Menus ! In the win32 gui, you can cause a menu to popup at the cursor. This behaves ! similarly to the PopUp menus except that any menu tree can be popped up. This command is for backwards compatibility, using it is discouraged, because it behaves in a strange way. --- 843,853 ---- a menu item - you don't need to do a :tunmenu as well. ! 5.9 Popup Menus ! In the Win32 and GTK+ GUI, you can cause a menu to popup at the cursor. ! This behaves similarly to the PopUp menus except that any menu tree can ! be popped up. This command is for backwards compatibility, using it is discouraged, because it behaves in a strange way. *************** *** 852,859 **** *:popup* *:popu* :pop[up] {name} Popup the menu {name}. The menu named must have at least one subentry, but need not ! appear on the menu-bar (see ! |win32-hidden-menus|). Example: > :popup File --- 855,862 ---- *:popup* *:popu* :pop[up] {name} Popup the menu {name}. The menu named must have at least one subentry, but need not ! appear on the menu-bar (see |hidden-menus|). ! {only available for Win32 and GTK GUI} Example: > :popup File *** ../vim61.432/src/ex_docmd.c Mon Mar 31 21:58:21 2003 --- src/ex_docmd.c Mon Mar 31 21:50:33 2003 *************** *** 191,197 **** #else # define ex_tearoff ex_ni #endif ! #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) static void ex_popup __ARGS((exarg_T *eap)); #else # define ex_popup ex_ni --- 191,197 ---- #else # define ex_tearoff ex_ni #endif ! #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) static void ex_popup __ARGS((exarg_T *eap)); #else # define ex_popup ex_ni *************** *** 5896,5902 **** } #endif ! #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) static void ex_popup(eap) exarg_T *eap; --- 5896,5902 ---- } #endif ! #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) static void ex_popup(eap) exarg_T *eap; *** ../vim61.432/src/gui_gtk.c Sat Mar 15 17:55:18 2003 --- src/gui_gtk.c Fri Mar 28 21:13:53 2003 *************** *** 262,268 **** { vimmenu_T *parent = menu->parent; ! if (menu_is_popup(menu->name)) { menu->submenu_id = gtk_menu_new(); return; --- 262,268 ---- { vimmenu_T *parent = menu->parent; ! if (menu->name[0] == ']' || menu_is_popup(menu->name)) { menu->submenu_id = gtk_menu_new(); return; *************** *** 310,318 **** /*ARGSUSED*/ static void ! menu_item_activate(GtkWidget * widget, gpointer data) { ! gui_menu_cb((vimmenu_T *) data); /* make sure the menu action is taken immediately */ if (gtk_main_level() > 0) --- 310,323 ---- /*ARGSUSED*/ static void ! menu_item_activate(GtkWidget *widget, gpointer data) { ! gui_menu_cb((vimmenu_T *)data); ! ! /* Work around a bug in GTK+ 1: we don't seem to get a focus-in ! * event after clicking a menu item shown via :popup. */ ! if (!gui.in_focus) ! gui_focus_change(TRUE); /* make sure the menu action is taken immediately */ if (gtk_main_level() > 0) *************** *** 592,598 **** { while (menu != NULL) { ! if (!menu_is_popup(menu->name)) { if (menu->submenu_id != 0) { --- 597,603 ---- { while (menu != NULL) { ! if (menu->name[0] != ']' && !menu_is_popup(menu->name)) { if (menu->submenu_id != 0) { *************** *** 1486,1492 **** gtk_menu_popup(GTK_MENU(menu->submenu_id), NULL, NULL, (GtkMenuPositionFunc)NULL, NULL, 3, (guint32)GDK_CURRENT_TIME); } ! #endif /* --- 1491,1533 ---- gtk_menu_popup(GTK_MENU(menu->submenu_id), NULL, NULL, (GtkMenuPositionFunc)NULL, NULL, 3, (guint32)GDK_CURRENT_TIME); } ! ! /* ! * Menu position callback; used by gui_make_popup() to place the menu ! * at the current text cursor position. ! */ ! /*ARGSUSED0*/ ! static void ! popup_menu_position_func(GtkMenu *menu, ! gint *x, gint *y, ! gpointer user_data) ! { ! if (curwin != NULL && gui.drawarea != NULL && gui.drawarea->window != NULL) ! { ! gdk_window_get_origin(gui.drawarea->window, x, y); ! ! /* Find the cursor position in the current window */ ! *x += FILL_X(W_WINCOL(curwin) + curwin->w_wcol + 1) + 1; ! *y += FILL_Y(W_WINROW(curwin) + curwin->w_wrow + 1) + 1; ! } ! } ! ! void ! gui_make_popup(char_u *path_name) ! { ! vimmenu_T *menu; ! ! menu = gui_find_menu(path_name); ! ! if (menu != NULL && menu->submenu_id != NULL) ! { ! gtk_menu_popup(GTK_MENU(menu->submenu_id), ! NULL, NULL, ! &popup_menu_position_func, NULL, ! 0U, (guint32)GDK_CURRENT_TIME); ! } ! } ! #endif /* FEAT_MENU */ /* *** ../vim61.432/src/menu.c Tue Mar 11 12:59:06 2003 --- src/menu.c Fri Mar 28 19:33:39 2003 *************** *** 2150,2158 **** EMSG2(_("E335: Menu not defined for %s mode"), mode); } ! #if defined(FEAT_GUI_MSWIN) || (defined(FEAT_BEVAL) \ ! && (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF))) \ ! || defined(PROTO) /* * Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy. */ --- 2150,2158 ---- EMSG2(_("E335: Menu not defined for %s mode"), mode); } ! #if defined(FEAT_GUI_MSWIN) \ ! || (defined(FEAT_GUI_GTK) && defined(FEAT_MENU)) \ ! || defined(FEAT_BEVAL_TIP) || defined(PROTO) /* * Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy. */ *** ../vim61.432/src/proto/gui_gtk.pro Tue Mar 11 12:59:06 2003 --- src/proto/gui_gtk.pro Fri Mar 28 19:33:39 2003 *************** *** 13,18 **** --- 13,19 ---- char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter)); int gui_mch_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int def_but, char_u *textfield)); void gui_mch_show_popupmenu __ARGS((vimmenu_T *menu)); + void gui_make_popup __ARGS((char_u *path_name)); void gui_mch_find_dialog __ARGS((exarg_T *eap)); void gui_mch_replace_dialog __ARGS((exarg_T *eap)); void gui_gtk_synch_fonts __ARGS((void)); *** ../vim61.432/src/version.c Mon Mar 31 21:58:22 2003 --- src/version.c Mon Mar 31 22:01:03 2003 *************** *** 613,614 **** --- 613,616 ---- { /* Add new patch number below this line */ + /**/ + 433, /**/ -- The software said it requires Windows 95 or better, so I installed Linux. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///