Beispiel #1
0
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)
}
Beispiel #2
0
func (account *account) buildAccountSubmenu() {
	menuitem, _ := gtk.MenuItemNew()

	menuitem.SetLabel(account.session.GetConfig().Account)

	accountSubMenu, _ := gtk.MenuNew()
	menuitem.SetSubmenu(accountSubMenu)

	connectItem, _ := gtk.MenuItemNewWithMnemonic(i18n.Local("_Connect"))
	accountSubMenu.Append(connectItem)

	disconnectItem, _ := gtk.MenuItemNewWithMnemonic(i18n.Local("_Disconnect"))
	accountSubMenu.Append(disconnectItem)

	editItem, _ := gtk.MenuItemNewWithMnemonic(i18n.Local("_Edit..."))
	accountSubMenu.Append(editItem)

	removeItem, _ := gtk.MenuItemNewWithMnemonic(i18n.Local("_Remove"))
	accountSubMenu.Append(removeItem)

	connectAutomaticallyItem, _ := gtk.CheckMenuItemNewWithMnemonic(i18n.Local("Connect _Automatically"))
	accountSubMenu.Append(connectAutomaticallyItem)
	connectAutomaticallyItem.SetActive(account.session.GetConfig().ConnectAutomatically)

	alwaysEncryptItem, _ := gtk.CheckMenuItemNewWithMnemonic(i18n.Local("Always Encrypt Conversation"))
	accountSubMenu.Append(alwaysEncryptItem)
	alwaysEncryptItem.SetActive(account.session.GetConfig().AlwaysEncrypt)

	toggleConnectAndDisconnectMenuItems(account.session, connectItem, disconnectItem)

	connectItem.Connect("activate", account.Connect)
	disconnectItem.Connect("activate", account.disconnect)
	editItem.Connect("activate", account.edit)
	removeItem.Connect("activate", account.remove)
	connectAutomaticallyItem.Connect("activate", account.toggleAutoConnect)
	alwaysEncryptItem.Connect("activate", account.toggleAlwaysEncrypt)

	go account.watchAndToggleMenuItems(connectItem, disconnectItem)
	account.menu = menuitem
}
Beispiel #3
0
func (*RealGtk) MenuItemNewWithMnemonic(label string) (gtki.MenuItem, error) {
	return wrapMenuItem(gtk.MenuItemNewWithMnemonic(label))
}
Beispiel #4
0
func (m *GoAppMenu) Init() {
	var err error

	m.menubar, err = gtk.MenuBarNew()
	if err != nil {
		log.Fatal("Unable to create menubar:", err)
	}

	m.menuFile, err = gtk.MenuNew()
	if err != nil {
		log.Fatal("Unable to create menuFile:", err)
	}
	m.filemenu, err = gtk.MenuItemNewWithLabel("File")
	if err != nil {
		log.Fatal("Unable to create filemenu:", err)
	}
	m.fileNewSg, err = gtk.MenuItemNewWithLabel("New Signal Graph")
	if err != nil {
		log.Fatal("Unable to create fileNewSg:", err)
	}
	m.fileNewLib, err = gtk.MenuItemNewWithLabel("New Library")
	if err != nil {
		log.Fatal("Unable to create fileNewLib:", err)
	}
	m.fileNewPlat, err = gtk.MenuItemNewWithLabel("New Platform")
	if err != nil {
		log.Fatal("Unable to create fileNewPlat:", err)
	}
	m.fileNewMap, err = gtk.MenuItemNewWithLabel("New Mapping")
	if err != nil {
		log.Fatal("Unable to create fileNewPlat:", err)
	}
	m.fileOpen, err = gtk.MenuItemNewWithLabel("Open")
	if err != nil {
		log.Fatal("Unable to create fileOpen:", err)
	}
	m.fileSave, err = gtk.MenuItemNewWithLabel("Save")
	if err != nil {
		log.Fatal("Unable to create fileSave:", err)
	}
	m.fileSaveAs, err = gtk.MenuItemNewWithLabel("Save As")
	if err != nil {
		log.Fatal("Unable to create fileSaveAs:", err)
	}
	m.fileClose, err = gtk.MenuItemNewWithLabel("Close")
	if err != nil {
		log.Fatal("Unable to create fileClose:", err)
	}
	m.fileQuit, err = gtk.MenuItemNewWithLabel("Quit")
	if err != nil {
		log.Fatal("Unable to create fileQuit:", err)
	}
	m.menuFile.Append(m.fileNewSg)
	m.menuFile.Append(m.fileNewLib)
	m.menuFile.Append(m.fileNewPlat)
	m.menuFile.Append(m.fileNewMap)
	x, _ := gtk.SeparatorMenuItemNew()
	m.menuFile.Append(x)
	m.menuFile.Append(m.fileOpen)
	m.menuFile.Append(m.fileSave)
	m.menuFile.Append(m.fileSaveAs)
	x, _ = gtk.SeparatorMenuItemNew()
	m.menuFile.Append(x)
	m.menuFile.Append(m.fileClose)
	x, _ = gtk.SeparatorMenuItemNew()
	m.menuFile.Append(x)
	m.menuFile.Append(m.fileQuit)
	m.filemenu.SetSubmenu(m.menuFile)
	m.menubar.Append(m.filemenu)

	m.fileQuit.Connect("activate", func() {
		gtk.MainQuit()
	})

	m.menuEdit, err = gtk.MenuNew()
	if err != nil {
		log.Fatal("Unable to create menuEdit:", err)
	}
	m.editmenu, err = gtk.MenuItemNewWithMnemonic("_Edit")
	if err != nil {
		log.Fatal("Unable to create editmenu:", err)
	}
	m.editUndo, err = gtk.MenuItemNewWithMnemonic("_Undo")
	if err != nil {
		log.Fatal("Unable to create editUndo:", err)
	}
	m.editRedo, err = gtk.MenuItemNewWithMnemonic("_Redo")
	if err != nil {
		log.Fatal("Unable to create editRedo:", err)
	}
	m.editNew, err = gtk.MenuItemNewWithMnemonic("_New Element")
	if err != nil {
		log.Fatal("Unable to create editNew:", err)
	}
	m.editEdit, err = gtk.MenuItemNewWithMnemonic("_Edit")
	if err != nil {
		log.Fatal("Unable to create editEdit:", err)
	}
	m.editCopy, err = gtk.MenuItemNewWithMnemonic("_Copy")
	if err != nil {
		log.Fatal("Unable to create editCopy:", err)
	}
	m.editDelete, err = gtk.MenuItemNewWithMnemonic("_Delete")
	if err != nil {
		log.Fatal("Unable to create editDelete:", err)
	}
	m.editPaste, err = gtk.MenuItemNewWithMnemonic("_Paste")
	if err != nil {
		log.Fatal("Unable to create editPaste:", err)
	}
	m.menuEdit.Append(m.editUndo)
	m.menuEdit.Append(m.editRedo)
	x, _ = gtk.SeparatorMenuItemNew()
	m.menuEdit.Append(x)
	m.menuEdit.Append(m.editNew)
	m.menuEdit.Append(m.editEdit)
	m.menuEdit.Append(m.editDelete)
	x, _ = gtk.SeparatorMenuItemNew()
	m.menuEdit.Append(x)
	m.menuEdit.Append(m.editCopy)
	m.menuEdit.Append(m.editPaste)
	m.editmenu.SetSubmenu(m.menuEdit)
	m.menubar.Append(m.editmenu)

	m.menuView, err = gtk.MenuNew()
	if err != nil {
		log.Fatal("Unable to create menuView:", err)
	}
	m.viewmenu, err = gtk.MenuItemNewWithMnemonic("_View")
	if err != nil {
		log.Fatal("Unable to create viewmenu:", err)
	}
	m.viewExpand, err = gtk.MenuItemNewWithMnemonic("E_xpand")
	if err != nil {
		log.Fatal("Unable to create viewExpand:", err)
	}
	m.viewCollapse, err = gtk.MenuItemNewWithMnemonic("Co_llapse")
	if err != nil {
		log.Fatal("Unable to create viewCollapse:", err)
	}
	m.menuView.Append(m.viewExpand)
	m.menuView.Append(m.viewCollapse)
	m.viewmenu.SetSubmenu(m.menuView)
	m.menubar.Append(m.viewmenu)

	m.menuAbout, err = gtk.MenuNew()
	if err != nil {
		log.Fatal("Unable to create menuEdit:", err)
	}
	m.aboutmenu, err = gtk.MenuItemNewWithLabel("About")
	if err != nil {
		log.Fatal("Unable to create filemenu:", err)
	}
	m.aboutAbout, err = gtk.MenuItemNewWithLabel("About...")
	if err != nil {
		log.Fatal("Unable to create filemenu:", err)
	}
	m.aboutHelp, err = gtk.MenuItemNewWithLabel("Help")
	if err != nil {
		log.Fatal("Unable to create filemenu:", err)
	}
	m.menuAbout.Append(m.aboutAbout)
	x, _ = gtk.SeparatorMenuItemNew()
	m.menuAbout.Append(x)
	m.menuAbout.Append(m.aboutHelp)
	m.aboutmenu.SetSubmenu(m.menuAbout)
	m.menubar.Append(m.aboutmenu)

	log.Println("GoAppMenu initialized")
}