func (account *account) appendMenuTo(submenu *gtk.Menu) { if account.menu != nil { account.destroyMenu() } account.buildAccountSubmenu() account.menu.Show() submenu.Append(account.menu) }
// WrapMenu wraps a gtk menu as a menu builder. // func WrapMenu(menu *gtk.Menu) *Menu { return &Menu{ Menu: *menu, groups: make(map[int]*glib.SList), callNewItem: func(menu *gtk.Menu, label, iconPath string) *gtk.MenuItem { item := newgtk.MenuItemWithLabel(label) menu.Append(item) return item }, callNewSubMenu: func(menu *gtk.Menu, label, iconPath string) (*gtk.Menu, *gtk.MenuItem) { gtkmenu := newgtk.Menu() item := newgtk.MenuItemWithLabel(label) menu.Append(item) item.SetSubmenu(gtkmenu) return gtkmenu, item }, } }
func (u *gtkUI) buildStaticAccountsMenu(submenu *gtk.Menu) { connectAutomaticallyItem, _ := gtk.CheckMenuItemNewWithMnemonic(i18n.Local("Connect On _Startup")) u.config.WhenLoaded(func(a *config.ApplicationConfig) { connectAutomaticallyItem.SetActive(a.ConnectAutomatically) }) connectAutomaticallyItem.Connect("activate", func() { u.setConnectAllAutomatically(connectAutomaticallyItem.GetActive()) }) submenu.Append(connectAutomaticallyItem) connectAllMenu, _ := gtk.MenuItemNewWithMnemonic(i18n.Local("_Connect All")) connectAllMenu.Connect("activate", func() { u.connectAllAutomatics(true) }) submenu.Append(connectAllMenu) sep2, _ := gtk.SeparatorMenuItemNew() submenu.Append(sep2) addAccMenu, _ := gtk.MenuItemNewWithMnemonic(i18n.Local("_Add...")) addAccMenu.Connect("activate", u.showAddAccountWindow) submenu.Append(addAccMenu) importMenu, _ := gtk.MenuItemNewWithMnemonic(i18n.Local("_Import...")) importMenu.Connect("activate", u.runImporter) submenu.Append(importMenu) registerAccMenu, _ := gtk.MenuItemNewWithMnemonic(i18n.Local("_Register...")) registerAccMenu.Connect("activate", u.showServerSelectionWindow) submenu.Append(registerAccMenu) }