Skip to content

Commit

Permalink
#228: re-use menu items so that we can re-use the 'Info' menu
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@10712 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 1, 2015
1 parent fe4092f commit 86bc34c
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/xpra/platform/darwin/osx_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from xpra.platform.paths import get_icon

from xpra.log import Logger
log = Logger("tray", "osx")
log = Logger("osx", "tray", "menu")


#control which menus are shown in the OSX global menu:
Expand Down Expand Up @@ -105,21 +105,30 @@ def add_full_menu(self):
return
self.full = True
assert self.client
if SHOW_ABOUT_XPRA:
info = self.menus.get("Info")
info_menu = info.get_submenu()
info_menu.append(self.make_sessioninfomenuitem())
info_menu.append(self.make_bugreportmenuitem())
menus = self.get_extra_menus()
for label, submenu in menus:
item = self.menuitem(label)
item = None
#try to find an existing menu item matching this label:
for x in self.menu_bar.get_children():
if hasattr(x, "get_label") and x.get_label()==label:
log("found existing menu item for %s: %s", label, x)
item = x
break
if item is None:
item = self.menuitem(label)
item.set_submenu(submenu)
item.show_all()
self.add_to_menu_bar(item)
self.menu_bar.show_all()

def get_extra_menus(self):
menus = []
if SHOW_ABOUT_XPRA:
info_menu = self.make_menu()
info_menu.append(self.menuitem("About Xpra", "information.png", None, about))
info_menu.append(self.make_sessioninfomenuitem())
info_menu.append(self.make_bugreportmenuitem())
menus.append(("Info", info_menu))
if SHOW_FEATURES_MENU:
features_menu = self.make_menu()
menus.append(("Features", features_menu))
Expand Down

0 comments on commit 86bc34c

Please sign in to comment.