Exemplo n.º 1
0
func (u *gtkUI) buildAccountsMenu() {
	accountsLock.Lock()
	defer accountsLock.Unlock()

	submenu, _ := gtk.MenuNew()

	for _, account := range u.accounts {
		account.appendMenuTo(submenu)
	}

	if len(u.accounts) > 0 {
		sep, _ := gtk.SeparatorMenuItemNew()
		submenu.Append(sep)
	}

	u.buildStaticAccountsMenu(submenu)

	submenu.ShowAll()

	u.accountsMenu.SetSubmenu(submenu)
}
Exemplo n.º 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
}
Exemplo n.º 3
0
func (*RealGtk) MenuNew() (gtki.Menu, error) {
	return wrapMenu(gtk.MenuNew())
}
Exemplo n.º 4
0
Arquivo: newgtk.go Projeto: sqp/godock
// Menu creates a *gtk.Menu.
func Menu() *gtk.Menu {
	w, _ := gtk.MenuNew()
	return w
}
Exemplo n.º 5
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")
}