本文整理匯總了Golang中github.com/gotk3/gotk3/gtk.ResponseType函數的典型用法代碼示例。如果您正苦於以下問題:Golang ResponseType函數的具體用法?Golang ResponseType怎麽用?Golang ResponseType使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ResponseType函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handlePeerEvent
func (u *gtkUI) handlePeerEvent(ev events.Peer) {
identityWarning := func(cv conversationView) {
cv.updateSecurityWarning()
cv.showIdentityVerificationWarning(u)
}
switch ev.Type {
case events.IQReceived:
//TODO
log.Printf("received iq: %v\n", ev.From)
case events.OTREnded:
peer := ev.From
account := u.findAccountForSession(ev.Session)
convWindowNowOrLater(account, peer, func(cv conversationView) {
cv.displayNotification(i18n.Local("Private conversation lost."))
cv.updateSecurityWarning()
})
case events.OTRNewKeys:
peer := ev.From
account := u.findAccountForSession(ev.Session)
convWindowNowOrLater(account, peer, func(cv conversationView) {
cv.displayNotificationVerifiedOrNot(i18n.Local("Private conversation started."), i18n.Local("Unverified conversation started."))
identityWarning(cv)
})
case events.OTRRenewedKeys:
peer := ev.From
account := u.findAccountForSession(ev.Session)
convWindowNowOrLater(account, peer, func(cv conversationView) {
cv.displayNotificationVerifiedOrNot(i18n.Local("Successfully refreshed the private conversation."), i18n.Local("Successfully refreshed the unverified private conversation."))
identityWarning(cv)
})
case events.SubscriptionRequest:
confirmDialog := authorizePresenceSubscriptionDialog(&u.window.Window, ev.From)
doInUIThread(func() {
responseType := gtk.ResponseType(confirmDialog.Run())
switch responseType {
case gtk.RESPONSE_YES:
ev.Session.HandleConfirmOrDeny(ev.From, true)
case gtk.RESPONSE_NO:
ev.Session.HandleConfirmOrDeny(ev.From, false)
default:
// We got a different response, such as a close of the window. In this case we want
// to keep the subscription request open
}
confirmDialog.Destroy()
})
case events.Subscribed:
jid := ev.Session.GetConfig().Account
log.Printf("[%s] Subscribed to %s\n", jid, ev.From)
u.rosterUpdated()
case events.Unsubscribe:
jid := ev.Session.GetConfig().Account
log.Printf("[%s] Unsubscribed from %s\n", jid, ev.From)
u.rosterUpdated()
}
}
示例2: verifyFingerprintDialog
func verifyFingerprintDialog(account *account, uid string, parent *gtk.Window) gtk.ResponseType {
accountConfig := account.session.GetConfig()
//TODO: review whether it should create new conversations
//Anyway, if it has created the conversation this function could return
//(there is no theirFP in this case)
conversation, _ := account.session.EnsureConversationWith(uid)
ourFp := conversation.OurFingerprint()
theirFp := conversation.TheirFingerprint()
dialog := buildVerifyFingerprintDialog(accountConfig.Account, ourFp, uid, theirFp)
defer dialog.Destroy()
dialog.SetTransientFor(parent)
dialog.ShowAll()
responseType := gtk.ResponseType(dialog.Run())
switch responseType {
case gtk.RESPONSE_YES:
account.executeCmd(client.AuthorizeFingerprintCmd{
Account: accountConfig,
Peer: uid,
Fingerprint: theirFp,
})
}
return responseType
}
示例3: Run
func (dialog *EditDialog) Run(fts *models.FilesTreeStore) (job *EditorJob, ok bool) {
ok = (gtk.ResponseType(dialog.Dialog().Run()) == gtk.RESPONSE_OK)
if ok {
job = dialog.CollectJob()
//log.Println("editEdit terminated: OK", job)
}
dialog.Dialog().Destroy()
return
}
示例4: feedbackDialog
func (u *gtkUI) feedbackDialog() {
builder := builderForDefinition("Feedback")
obj, _ := builder.GetObject("dialog")
dialog := obj.(*gtk.MessageDialog)
dialog.SetTransientFor(u.window)
response := dialog.Run()
if gtk.ResponseType(response) == gtk.RESPONSE_CLOSE {
dialog.Destroy()
}
}
示例5: handlePeerEvent
func (u *gtkUI) handlePeerEvent(ev session.PeerEvent) {
switch ev.Type {
case session.IQReceived:
//TODO
log.Printf("received iq: %v\n", ev.From)
case session.OTREnded:
peer := ev.From
account := u.findAccountForSession(ev.Session)
convWin, ok := account.getConversationWith(peer)
if !ok {
log.Println("Could not find a conversation window")
return
}
convWin.updateSecurityWarning()
case session.OTRNewKeys:
peer := ev.From
account := u.findAccountForSession(ev.Session)
convWin, ok := account.getConversationWith(peer)
if !ok {
log.Println("Could not find a conversation window")
return
}
convWin.updateSecurityWarning()
convWin.showIdentityVerificationWarning(u)
case session.SubscriptionRequest:
confirmDialog := authorizePresenceSubscriptionDialog(u.window, ev.From)
doInUIThread(func() {
responseType := gtk.ResponseType(confirmDialog.Run())
switch responseType {
case gtk.RESPONSE_YES:
ev.Session.HandleConfirmOrDeny(ev.From, true)
case gtk.RESPONSE_NO:
ev.Session.HandleConfirmOrDeny(ev.From, false)
default:
// We got a different response, such as a close of the window. In this case we want
// to keep the subscription request open
}
confirmDialog.Destroy()
})
case session.Subscribed:
jid := ev.Session.GetConfig().Account
log.Printf("[%s] Subscribed to %s\n", jid, ev.From)
u.rosterUpdated()
case session.Unsubscribe:
jid := ev.Session.GetConfig().Account
log.Printf("[%s] Unsubscribed from %s\n", jid, ev.From)
u.rosterUpdated()
}
}
示例6: runImporter
func (u *gtkUI) runImporter() {
importSettings := make(map[applicationAndAccount]bool)
allImports := importer.TryImportAll()
builder := builderForDefinition("Importer")
win, _ := builder.GetObject("importerWindow")
w := win.(*gtk.Dialog)
store, _ := builder.GetObject("importAccountsStore")
s := store.(*gtk.ListStore)
for appName, v := range allImports {
for _, vv := range v {
for _, a := range vv.Accounts {
it := s.Append()
s.SetValue(it, 0, appName)
s.SetValue(it, 1, a.Account)
s.SetValue(it, 2, false)
}
}
}
rend, _ := builder.GetObject("import-this-account-renderer")
rr := rend.(*gtk.CellRendererToggle)
rr.Connect("toggled", func(_ interface{}, path string) {
iter, _ := s.GetIterFromString(path)
current, _ := valAt(s, iter, 2).(bool)
app, _ := valAt(s, iter, 0).(string)
acc, _ := valAt(s, iter, 1).(string)
importSettings[applicationAndAccount{app, acc}] = !current
s.SetValue(iter, 2, !current)
})
w.Connect("response", func(_ interface{}, rid int) {
if gtk.ResponseType(rid) == gtk.RESPONSE_OK {
u.doActualImportOf(importSettings, allImports)
}
w.Destroy()
})
u.connectShortcutsChildWindow(&w.Window)
doInUIThread(func() {
w.SetTransientFor(u.window)
w.ShowAll()
})
}
示例7: wouldYouLikeToEncryptYourFile
func (u *gtkUI) wouldYouLikeToEncryptYourFile(k func(bool)) {
dialogID := "AskToEncrypt"
builder := builderForDefinition(dialogID)
dialogOb, _ := builder.GetObject(dialogID)
encryptDialog := dialogOb.(*gtk.MessageDialog)
encryptDialog.SetDefaultResponse(gtk.RESPONSE_YES)
encryptDialog.SetTransientFor(u.window)
responseType := gtk.ResponseType(encryptDialog.Run())
result := responseType == gtk.RESPONSE_YES
encryptDialog.Destroy()
k(result)
}
示例8: confirmAccountRemoval
func (u *gtkUI) confirmAccountRemoval(acc *config.Account, removeAccountFunc func(*config.Account)) {
builder := builderForDefinition("ConfirmAccountRemoval")
obj, _ := builder.GetObject("RemoveAccount")
dialog := obj.(*gtk.MessageDialog)
dialog.SetTransientFor(u.window)
dialog.SetProperty("text", acc.Account)
response := dialog.Run()
if gtk.ResponseType(response) == gtk.RESPONSE_YES {
removeAccountFunc(acc)
}
dialog.Destroy()
}
示例9: runFileDialog
// empty fTypes means all types enabled
func runFileDialog(fTypes []FileType, toSave bool, announce string) (filename string, ok bool) {
var action gtk.FileChooserAction
var buttonText string
if toSave {
action = gtk.FILE_CHOOSER_ACTION_SAVE
buttonText = "Save"
} else {
action = gtk.FILE_CHOOSER_ACTION_OPEN
buttonText = "Open"
}
dialog, err := gtk.FileChooserDialogNewWith2Buttons(
announce,
nil,
action,
"Cancel",
gtk.RESPONSE_CANCEL,
buttonText,
gtk.RESPONSE_OK)
if err != nil {
log.Printf("runFileDialog error: %s\n", err)
return
}
if len(fTypes) == 0 {
for _, t := range allFileTypes {
fTypes = append(fTypes, t)
}
}
if len(fTypes) == 1 {
log.Printf("runFileDialog: set current to %s.\n", dirMgr.Current(fTypes[0]))
dialog.SetCurrentFolder(dirMgr.Current(fTypes[0]))
} else {
log.Printf("runFileDialog: set current to %s.\n", backend.XmlRoot())
dialog.SetCurrentFolder(backend.XmlRoot())
}
for _, ft := range fTypes {
ff, _ := gtk.FileFilterNew()
ff.SetName(descriptionFileTypes[ft])
ff.AddPattern(fmt.Sprintf("*.%s", string(ft)))
dialog.AddFilter(ff)
}
response := dialog.Run()
ok = (gtk.ResponseType(response) == gtk.RESPONSE_OK)
filename = dialog.GetFilename()
dialog.Destroy()
return
}
示例10: importFingerprintsForDialog
func (u *gtkUI) importFingerprintsForDialog(account *config.Account, w *gtk.Dialog) {
dialog, _ := gtk.FileChooserDialogNewWith2Buttons(
i18n.Local("Import fingerprints"),
&w.Window,
gtk.FILE_CHOOSER_ACTION_OPEN,
i18n.Local("_Cancel"),
gtk.RESPONSE_CANCEL,
i18n.Local("_Import"),
gtk.RESPONSE_OK,
)
if gtk.ResponseType(dialog.Run()) == gtk.RESPONSE_OK {
num, ok := u.importFingerprintsFor(account, dialog.GetFilename())
if ok {
u.notify(i18n.Local("Fingerprints imported"), fmt.Sprintf(i18n.Local("%d fingerprint(s) were imported correctly."), num))
} else {
u.notify(i18n.Local("Failure importing fingerprints"), fmt.Sprintf(i18n.Local("Couldn't import any fingerprints from %s."), dialog.GetFilename()))
}
}
dialog.Destroy()
}
示例11: renderForm
func (f *registrationForm) renderForm(title, instructions string, fields []interface{}) error {
f.addFields(fields)
builder := builderForDefinition("RegistrationForm")
obj, _ := builder.GetObject("dialog")
dialog := obj.(*gtk.Dialog)
dialog.SetTitle(title)
obj, _ = builder.GetObject("instructions")
label := obj.(*gtk.Label)
label.SetText(instructions)
label.SetSelectable(true)
obj, _ = builder.GetObject("grid")
grid := obj.(*gtk.Grid)
for i, field := range f.fields {
grid.Attach(field.label, 0, i+1, 1, 1)
grid.Attach(field.widget, 1, i+1, 1, 1)
}
grid.ShowAll()
dialog.SetTransientFor(f.parent)
wait := make(chan error)
doInUIThread(func() {
resp := gtk.ResponseType(dialog.Run())
switch resp {
case gtk.RESPONSE_APPLY:
wait <- f.accepted()
default:
wait <- errRegistrationAborted
}
dialog.Destroy()
})
return <-wait
}
示例12: showServerSelectionWindow
func (u *gtkUI) showServerSelectionWindow() error {
builder := builderForDefinition("AccountRegistration")
obj, _ := builder.GetObject("dialog")
d := obj.(*gtk.Dialog)
defer d.Destroy()
d.SetTransientFor(u.window)
d.ShowAll()
resp := d.Run()
if gtk.ResponseType(resp) != gtk.RESPONSE_APPLY {
return nil
}
obj, _ = builder.GetObject("server")
iter, _ := obj.(*gtk.ComboBox).GetActiveIter()
obj, _ = builder.GetObject("servers-model")
val, _ := obj.(*gtk.ListStore).GetValue(iter, 0)
server, _ := val.GetString()
form := ®istrationForm{
parent: u.window,
server: server,
}
saveFn := func() {
u.addAndSaveAccountConfig(form.conf)
if acc, ok := u.getAccountByID(form.conf.ID()); ok {
acc.session.WantToBeOnline = true
acc.Connect()
}
}
go requestAndRenderRegistrationForm(form.server, form.renderForm, saveFn)
return nil
}
示例13: exportFingerprintsForDialog
func (u *gtkUI) exportFingerprintsForDialog(account *config.Account, w *gtk.Dialog) {
dialog, _ := gtk.FileChooserDialogNewWith2Buttons(
i18n.Local("Export fingerprints"),
&w.Window,
gtk.FILE_CHOOSER_ACTION_SAVE,
i18n.Local("_Cancel"),
gtk.RESPONSE_CANCEL,
i18n.Local("_Export"),
gtk.RESPONSE_OK,
)
dialog.SetCurrentName("otr.fingerprints")
if gtk.ResponseType(dialog.Run()) == gtk.RESPONSE_OK {
ok := u.exportFingerprintsFor(account, dialog.GetFilename())
if ok {
u.notify(i18n.Local("Fingerprints exported"), i18n.Local("Fingerprints were exported correctly."))
} else {
u.notify(i18n.Local("Failure exporting fingerprints"), fmt.Sprintf(i18n.Local("Couldn't export fingerprints to %s."), dialog.GetFilename()))
}
}
dialog.Destroy()
}
示例14: dialogAskBackend
func dialogAskBackend() {
// Need to keep the string as it is for translation.
str := "OpenGL allows you to use the hardware acceleration, reducing the CPU load to the minimum.\nIt also allows some pretty visual effects similar to Compiz.\nHowever, some cards and/or their drivers don't fully support it, which may prevent the dock from running correctly.\nDo you want to activate OpenGL ?\n (To not show this dialog, launch the dock from the Application menu,\n or with the -o option to force OpenGL and -c to force cairo.)"
dialog := newgtk.Dialog()
dialog.SetTitle(tran.Slate("Use OpenGL in Cairo-Dock"))
dialog.AddButton(tran.Slate("Yes"), gtk.RESPONSE_YES)
dialog.AddButton(tran.Slate("No"), gtk.RESPONSE_NO)
labelTxt := newgtk.Label(tran.Slate(str))
content, _ := dialog.GetContentArea()
content.PackStart(labelTxt, false, false, 0)
askBox := newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 3)
content.PackStart(askBox, false, false, 0)
labelSave := newgtk.Label(tran.Slate("Remember this choice"))
check := newgtk.CheckButton()
askBox.PackEnd(check, false, false, 0)
askBox.PackEnd(labelSave, false, false, 0)
dialog.ShowAll()
answer := dialog.Run() // has its own main loop, so we can call it before gtk_main.
remember := check.GetActive()
dialog.Destroy()
if answer == int(gtk.RESPONSE_NO) {
gldi.GLBackendDeactivate()
}
if remember { // save user choice to file.
value := ternary.String(gtk.ResponseType(answer) == gtk.RESPONSE_YES, "opengl", "cairo")
updateHiddenFile("default backend", value)
}
}
示例15: verifyFingerprintDialog
func verifyFingerprintDialog(account *account, uid string, parent *gtk.Window) gtk.ResponseType {
accountConfig := account.session.GetConfig()
conversation, _ := account.session.ConversationManager().EnsureConversationWith(uid)
ourFp := conversation.OurFingerprint()
theirFp := conversation.TheirFingerprint()
dialog := buildVerifyFingerprintDialog(accountConfig.Account, ourFp, uid, theirFp)
defer dialog.Destroy()
dialog.SetTransientFor(parent)
dialog.ShowAll()
responseType := gtk.ResponseType(dialog.Run())
switch responseType {
case gtk.RESPONSE_YES:
account.executeCmd(client.AuthorizeFingerprintCmd{
Account: accountConfig,
Peer: uid,
Fingerprint: theirFp,
})
}
return responseType
}