• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang gtk.ResponseType函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/gotk3/gotk3/gtk.ResponseType函数的典型用法代码示例。如果您正苦于以下问题:Golang ResponseType函数的具体用法?Golang ResponseType怎么用?Golang ResponseType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ResponseType函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
	}
}
开发者ID:VKCheung,项目名称:coyim,代码行数:60,代码来源:account_events.go


示例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
}
开发者ID:0x27,项目名称:coyim,代码行数:28,代码来源:fingerprint_verification.go


示例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
}
开发者ID:axel-freesp,项目名称:sge,代码行数:9,代码来源:editdialog.go


示例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()
	}
}
开发者ID:0x27,项目名称:coyim,代码行数:12,代码来源:ui.go


示例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()
	}
}
开发者ID:0x27,项目名称:coyim,代码行数:52,代码来源:account_events.go


示例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()
	})
}
开发者ID:PMaynard,项目名称:coyim,代码行数:50,代码来源:importer.go


示例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)
}
开发者ID:PMaynard,项目名称:coyim,代码行数:14,代码来源:master_password.go


示例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()
}
开发者ID:PMaynard,项目名称:coyim,代码行数:15,代码来源:ui.go


示例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
}
开发者ID:axel-freesp,项目名称:sge,代码行数:47,代码来源:menufile.go


示例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()
}
开发者ID:PMaynard,项目名称:coyim,代码行数:21,代码来源:importer.go


示例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
}
开发者ID:VKCheung,项目名称:coyim,代码行数:40,代码来源:registration.go


示例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 := &registrationForm{
		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
}
开发者ID:tanujmathur,项目名称:coyim,代码行数:39,代码来源:account.go


示例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()
}
开发者ID:PMaynard,项目名称:coyim,代码行数:23,代码来源:importer.go


示例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)
	}
}
开发者ID:sqp,项目名称:godock,代码行数:37,代码来源:maindock.go


示例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
}
开发者ID:grayleonard,项目名称:coyim,代码行数:24,代码来源:fingerprint_verification.go


示例16: SetDefaultResponse

func (v *dialog) SetDefaultResponse(v1 gtki.ResponseType) {
	v.internal.SetDefaultResponse(gtk.ResponseType(v1))
}
开发者ID:twstrike,项目名称:coyim,代码行数:3,代码来源:dialog.go


示例17: onFileChooserOpen

func onFileChooserOpen(obj *gtk.Button, data fileChooserData) {
	var parent *gtk.Window

	var title string
	var action gtk.FileChooserAction

	switch data.key.Type {
	case cftype.KeyFolderSelector:
		title = tran.Slate("Pick up a directory")
		action = gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER

	case cftype.KeyImageSelector:
		title = tran.Slate("Pick up an image")
		action = gtk.FILE_CHOOSER_ACTION_OPEN

	default:
		title = tran.Slate("Pick up a file")
		action = gtk.FILE_CHOOSER_ACTION_OPEN
	}

	dialog, _ := gtk.FileChooserDialogNewWith2Buttons(title, parent, action,
		"_OK", gtk.RESPONSE_OK, "_Cancel", gtk.RESPONSE_CANCEL)

	// Set the current folder to the current value in conf.
	value, _ := data.entry.GetText()
	if value == "" || value[0] != '/' {
		if data.key.IsType(cftype.KeyImageSelector) {
			println("need dir pictures")
			// dialog.SetCurrentFolder(filepath.Dir(value)) // g_get_user_special_dir (G_USER_DIRECTORY_PICTURES) :
		} else {
			println(os.Getenv("HOME"))
			dialog.SetCurrentFolder(os.Getenv("HOME"))
		}
	} else {
		dialog.SetCurrentFolder(filepath.Dir(value))
	}

	if data.key.IsType(cftype.KeyImageSelector) { // Add shortcuts to icons of the system.
		dialog.AddShortcutFolder("/usr/share/icons")
		dialog.AddShortcutFolder("/usr/share/pixmaps")
	}

	if data.key.IsType(cftype.KeyFileSelector, cftype.KeySoundSelector) { // Add shortcuts to system icons directories.
		filter := newgtk.FileFilter()
		filter.SetName(tran.Slate("All"))
		filter.AddPattern("*")
		dialog.AddFilter(filter)
	}

	if data.key.IsType(cftype.KeyFileSelector, cftype.KeyImageSelector) { // Preview and images filter.
		filter := newgtk.FileFilter()
		filter.SetName(tran.Slate("Image"))
		filter.AddPixbufFormats()
		dialog.AddFilter(filter)

		img := newgtk.Image()
		dialog.SetPreviewWidget(img)
		dialog.Connect("update-preview", onFileChooserUpdatePreview, img)
	}

	dialog.Show()
	answer := dialog.Run()
	if gtk.ResponseType(answer) == gtk.RESPONSE_OK {
		data.entry.SetText(dialog.GetFilename())
	}
	dialog.Destroy()
}
开发者ID:sqp,项目名称:godock,代码行数:67,代码来源:others.go


示例18: FileChooserDialogNewWith2Buttons

func (*RealGtk) FileChooserDialogNewWith2Buttons(title string, parent gtki.Window, action gtki.FileChooserAction, first_button_text string, first_button_id gtki.ResponseType, second_button_text string, second_button_id gtki.ResponseType) (gtki.FileChooserDialog, error) {
	return wrapFileChooserDialog(gtk.FileChooserDialogNewWith2Buttons(title, unwrapWindow(parent), gtk.FileChooserAction(action), first_button_text, gtk.ResponseType(first_button_id), second_button_text, gtk.ResponseType(second_button_id)))
}
开发者ID:twstrike,项目名称:coyim,代码行数:3,代码来源:real_gtk.go



注:本文中的github.com/gotk3/gotk3/gtk.ResponseType函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gtk.WindowNew函数代码示例发布时间:2022-05-23
下一篇:
Golang gtk.MainQuit函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap