func toArray(groupList gtki.ListStore) []string { groups := []string{} iter, ok := groupList.GetIterFirst() for ok { gValue, _ := groupList.GetValue(iter, 0) if group, err := gValue.GetString(); err == nil { groups = append(groups, group) } ok = groupList.IterNext(iter) } return groups }
func filterCertificates(oldCerts []*config.CertificatePin, newList gtki.ListStore) []*config.CertificatePin { allPins := make(map[string]bool) iter, ok := newList.GetIterFirst() for ok { vv, _ := newList.GetValue(iter, 2) pp, _ := vv.GetString() allPins[pp] = true ok = newList.IterNext(iter) } newCerts := []*config.CertificatePin{} for _, cc := range oldCerts { if allPins[hex.EncodeToString(cc.Fingerprint)] { newCerts = append(newCerts, cc) } } return newCerts }
func valAt(s gtki.ListStore, iter gtki.TreeIter, col int) interface{} { gv, _ := s.GetValue(iter, col) vv, _ := gv.GoValue() return vv }
func (u *gtkUI) newCustomConversation() { accounts := make([]*account, 0, len(u.accounts)) for i := range u.accounts { acc := u.accounts[i] if acc.connected() { accounts = append(accounts, acc) } } var dialog gtki.Window var model gtki.ListStore var accountInput gtki.ComboBox var peerInput gtki.Entry builder := newBuilder("NewCustomConversation") builder.getItems( "NewCustomConversation", &dialog, "accounts-model", &model, "accounts", &accountInput, "address", &peerInput, ) for _, acc := range accounts { iter := model.Append() model.SetValue(iter, 0, acc.session.GetConfig().Account) model.SetValue(iter, 1, acc.session.GetConfig().ID()) } if len(accounts) > 0 { accountInput.SetActive(0) } builder.ConnectSignals(map[string]interface{}{ "on_close_signal": func() { dialog.Destroy() }, "on_start_signal": func() { iter, err := accountInput.GetActiveIter() if err != nil { log.Printf("Error encountered when getting account: %v", err) return } val, err := model.GetValue(iter, 1) if err != nil { log.Printf("Error encountered when getting account: %v", err) return } accountID, _ := val.GetString() account, ok := u.roster.getAccount(accountID) if !ok { return } jid, _ := peerInput.GetText() u.roster.openConversationView(account, jid, true) dialog.Destroy() }, }) dialog.SetTransientFor(u.window) dialog.ShowAll() }