Subject: bug#50352: [feature/pgtk] Some menu items are blank when using global menu

From: Chen Zhenge <[email-masked]>
Date: Fri, 3 Sep 2021 16:15:31 +0800

Hi all,

I tried out the pgtk branch recently. It has some issues with my global 
menu widget. Specifically, When a new menu is created, some of its items 
are blank in the global menu.

Below are steps to reproduce the problem:

- Add a global menu widget. In my case I'm using xfce4-appmenu-plugin. 
Note that KDE's global menu widget seems to have its own bugs.

- gsettings set org.appmenu.gtk-module whitelist '["emacs"]'

- emacs -Q

- Open an elisp file

- Open the Emacs-Lisp menu, the first three items are blank

I did some debugging and found that this bug seems to be related to how 
emacs handles menu changes. In gtkutil.c:xg_update_menubar, emacs will 
simply rename the top-level menu when one menu is replaced by another 
(in ! val_in_menubar && ! iter_in_new_menubar branch). If I change the 
code to first remove the old menu, then add the new one, the items are 
displayed correctly.

In GNU Emacs 28.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 
3.24.24, cairo version 1.16.0)
  of 2021-09-03 built on debian
Repository revision: 4c49ec7f865bdad1629d2f125f71f4e506b258f2
Repository branch: feature/pgtk
Windowing system distributor 'System Description: Debian GNU/Linux 11 
(bullseye)

Configured using:
  'configure --with-pgtk'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XIM
GTK3 ZLIB

Important settings:
   value of $LANG: en_US.UTF-8
   locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-mode: t
   eldoc-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   indent-tabs-mode: t
   transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/pgtk-win pgtk-win term/common-win tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit pgtk lcms2 multi-tty make-network-process
emacs)

Memory information:
((conses 16 50339 6400)
  (symbols 48 6611 1)
  (strings 32 18173 2535)
  (string-bytes 1 600200)
  (vectors 16 13336)
  (vector-slots 8 178859 10679)
  (floats 8 21 35)
  (intervals 56 195 0)
  (buffers 992 10))