本文整理汇总了Golang中github.com/mattn/go-gtk/gdk.ThreadsEnter函数的典型用法代码示例。如果您正苦于以下问题:Golang ThreadsEnter函数的具体用法?Golang ThreadsEnter怎么用?Golang ThreadsEnter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ThreadsEnter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: UseTool
func (rw *RegionWrapper) UseTool(x, z int) {
gdk.ThreadsLeave()
defer gdk.ThreadsEnter()
if !rw.toolsEnabled {
return
}
if rw.tool.IsSlow() {
rw.toolsEnabled = false
rw.guicbs.setBusy(true)
go func() {
rw.tool.Do(rw.bio, rw, x, z)
rw.guicbs.setBusy(false)
rw.toolsEnabled = true
gdk.ThreadsEnter()
rw.redraw()
gdk.ThreadsLeave()
}()
} else {
rw.tool.Do(rw.bio, rw, x, z)
}
}
开发者ID:kch42,项目名称:biomed,代码行数:25,代码来源:region_wrapper.go
示例2: RenderHtml
func RenderHtml(html, baseuri string) string {
result := ""
fmt.Printf("Starting load\n")
//go func() {
gdk.ThreadsEnter()
webview.GetMainFrame().LoadString(html, "text/html", "UTF-8", baseuri)
//webview.LoadUri("http://google.com")
gdk.ThreadsLeave()
fmt.Printf("Ending load\n")
//}()
//for gtk.EventsPending() {
// fmt.Printf("Iteration\n")
// gtk.MainIteration()
//}
timeout := make(chan bool, 1)
go func() {
time.Sleep(4 * time.Second)
timeout <- true
}()
select {
case <-c:
fmt.Printf("read from channel\n")
case <-timeout:
fmt.Printf("timeout\n")
}
//gdk.ThreadsEnter()
result = getHtml(webview)
//gdk.ThreadsLeave()
return result
}
开发者ID:zackb,项目名称:code,代码行数:34,代码来源:webkit.go
示例3: KeyboardHandler
// KeyboardHandler handle events from keyboard
func KeyboardHandler(event chan *KeyPressEvent, terminal vte3.Terminal) {
for {
kpe := <-event
log.Printf("[DEBUG] KeyPressEvent : %#v", kpe)
gdk.ThreadsEnter()
switch kpe.KeyVal {
case gdk.KEY_plus:
if kpe.GetModifier() == CTRL {
log.Printf("[DEBUG] +")
}
break
case gdk.KEY_minus:
if kpe.GetModifier() == CTRL {
log.Printf("[DEBUG] -")
}
break
case gdk.KEY_equal:
if kpe.GetModifier() == CTRL {
log.Printf("[DEBUG] =")
}
break
case gdk.KEY_exclam:
if kpe.GetModifier() == CTRL {
log.Printf("[DEBUG] About")
}
break
}
gdk.ThreadsLeave()
}
}
开发者ID:nlamirault,项目名称:mert,代码行数:31,代码来源:keyboard.go
示例4: KeyboardHandler
// KeyboardHandler handle events from keyboard
func KeyboardHandler(event chan *keyhandler.KeyPressEvent, window *gtk.Window,
repl *gtk.Entry, URLEntry *gtk.Entry, notebook *gtk.Notebook) {
for {
kpe := <-event
log.Printf("[DEBUG] KeyPressEvent : %v", kpe)
gdk.ThreadsEnter()
switch kpe.KeyVal {
case gdk.KEY_Escape:
repl.SetVisible(false)
break
case gdk.KEY_colon:
if !repl.IsFocus() && !URLEntry.IsFocus() {
repl.SetVisible(true)
repl.GrabFocus()
repl.SetText(":")
repl.SetPosition(1)
}
break
case gdk.KEY_Return:
if repl.IsFocus() {
text := repl.GetText()
log.Printf("Repl text : %s", text)
if len(text) > 0 {
command.Run(text, window, "")
}
repl.SetText("")
}
break
// case gdk.KEY_w:
// if kpe.GetModifier() == keyhandler.CTRL {
// log.Printf("[DEBUG] nb : %d", notebook.GetNPages())
// notebook.RemovePage(notebook.GetCurrentPage())
// log.Printf("[DEBUG] nb : %d", notebook.GetNPages())
// }
// break
case gdk.KEY_t:
if kpe.GetModifier() == keyhandler.CTRL {
log.Printf("[DEBUG] New tab")
log.Printf("[DEBUG] nb : %d", notebook.GetNPages())
log.Printf("[DEBUG] current : %d",
notebook.GetCurrentPage())
tab := ui.NewBrowser("")
page := gtk.NewFrame("")
//fmt.Sprintf("%d", notebook.GetNPages()+1))
notebook.AppendPage(page, gtk.NewLabel("New tab"))
page.Add(tab.VBox)
log.Printf("[DEBUG] nb : %d", notebook.GetNPages())
notebook.ShowAll()
}
break
case gdk.KEY_q:
if kpe.GetModifier() == keyhandler.CTRL {
gtk.MainQuit()
}
break
}
gdk.ThreadsLeave()
}
}
开发者ID:nlamirault,项目名称:actarus,代码行数:60,代码来源:keyboard.go
示例5: InitWebKit
func InitWebKit() {
gtk.Init(nil)
gdk.ThreadsInit()
c = make(chan bool, 2)
gdk.ThreadsEnter()
webview = CreateWebView(func() {
fmt.Printf("HEEEERLoad Finished\n")
c <- true
})
gdk.ThreadsLeave()
go func() {
gdk.ThreadsEnter()
gtk.Main()
gdk.ThreadsLeave()
}()
}
开发者ID:zackb,项目名称:code,代码行数:17,代码来源:webkit.go
示例6: pulsate
func (w *GhSyncWindow) pulsate(progressBar *gtk.GtkProgressBar) {
for w.isSyncing {
gdk.ThreadsEnter()
progressBar.Pulse()
gdk.ThreadsLeave()
time.Sleep(time.Duration(100) * time.Millisecond)
}
}
开发者ID:chdorner,项目名称:ghighlighter,代码行数:8,代码来源:sync_window.go
示例7: tileUpdater
func (rw *RegionWrapper) tileUpdater() {
for _ = range rw.tileUpdates {
todelete := make(map[XZPos]bool)
for pos := range rw.Maptiles {
if (pos.X < rw.startX) || (pos.Z < rw.startZ) || (pos.X >= rw.endX) || (pos.Z >= rw.endZ) {
todelete[pos] = true
}
}
gdk.ThreadsEnter()
for pos := range todelete {
if tile, ok := rw.Maptiles[pos]; ok {
tile.Unref()
delete(rw.Maptiles, pos)
}
if tile, ok := rw.Biotiles[pos]; ok {
tile.Unref()
delete(rw.Biotiles, pos)
}
if _, ok := rw.bioCache[pos]; ok {
delete(rw.bioCache, pos)
}
}
if rw.region != nil {
for z := rw.startZ; z < rw.endZ; z++ {
scanX:
for x := rw.startX; x < rw.endX; x++ {
pos := XZPos{x, z}
if _, ok := rw.Biotiles[pos]; ok {
continue scanX
}
chunk, err := rw.region.Chunk(x, z)
switch err {
case nil:
case mcmap.NotAvailable:
continue scanX
default:
rw.guicbs.reportFail(fmt.Sprintf("Could not get chunk %d, %d: %s", x, z, err))
return
}
rw.Maptiles[pos], rw.Biotiles[pos], rw.bioCache[pos] = rw.renderTile(chunk)
chunk.MarkUnused()
rw.redraw()
}
}
}
gdk.ThreadsLeave()
}
}
开发者ID:kch42,项目名称:biomed,代码行数:58,代码来源:region_wrapper.go
示例8: tabby_server
func tabby_server() {
var focus_line int
buf := make([]byte, 1024)
for {
c, _ := listener.Accept()
if nil != c {
nread, err := c.Read(buf)
if 0 >= nread {
tabby_log("server: read from unix socket: " + err.Error())
c.Close()
continue
}
// At this point buf contains '\n' separated file names preceeded by focus
// line number. Double '\n' at the end of list.
gdk.ThreadsEnter()
opened_cnt := 0
s := buf[:]
for cnt := 0; ; cnt++ {
en := strings.Index(string(s), "\n")
if 0 == en {
break
}
if 0 == cnt {
focus_line, _ = strconv.Atoi(string(s[:en]))
} else {
if open_file_from_args(string(s[:en]), focus_line) {
opened_cnt++
}
}
s = s[en+1:]
}
if opened_cnt > 0 {
main_window.Present()
file_tree_store()
new_file := file_stack_pop()
file_save_current()
file_switch_to(new_file)
}
gdk.ThreadsLeave()
c.Close()
} else {
// Dirty hack! There is no way to distinguish two cases:
// 1) Accept returns error because socket was closed on tabby exit.
// 2) Real error occured.
// Commenting this line out to avoid misleading error messages on exit.
//tabby_log(e.String())
return
}
}
}
开发者ID:udhos,项目名称:tabby,代码行数:56,代码来源:args.go
示例9: Write
func (g *GuiController) Write(dmxUniverse *dmx.DMXUniverse) error {
gdk.ThreadsEnter()
for i := 0; i < 3*8; i += 3 {
c := gdk.NewColorRGB(dmxUniverse.Channels[i], dmxUniverse.Channels[i+1], dmxUniverse.Channels[i+2])
g.buttons[i/3].ModifyBG(gtk.STATE_NORMAL, c)
}
gdk.ThreadsLeave()
return nil
}
开发者ID:uvgroovy,项目名称:dmx,代码行数:13,代码来源:dmxd.go
示例10: main
func main() {
glib.ThreadInit(nil)
gdk.ThreadsInit()
gdk.ThreadsEnter()
gtk.Init(nil)
gui := new(GUI)
gui.Init()
gui.Show()
gtk.Main()
gdk.ThreadsLeave()
}
开发者ID:kch42,项目名称:biomed,代码行数:13,代码来源:main.go
示例11: main
func main() {
gdk.ThreadsInit()
if false == init_args() {
return
}
load_options()
defer save_options()
gdk.ThreadsEnter()
gtk.Init(nil)
init_tabby()
gtk.Main()
}
开发者ID:udhos,项目名称:tabby,代码行数:13,代码来源:main.go
示例12: main
func main() {
runtime.GOMAXPROCS(10)
glib.ThreadInit(nil)
gdk.ThreadsInit()
gdk.ThreadsEnter()
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
label1 := gtk.NewLabel("")
vbox.Add(label1)
label2 := gtk.NewLabel("")
vbox.Add(label2)
window.Add(vbox)
window.SetSizeRequest(100, 100)
window.ShowAll()
time.Sleep(1000 * 1000 * 100)
go (func() {
for i := 0; i < 300000; i++ {
gdk.ThreadsEnter()
label1.SetLabel(strconv.Itoa(i))
gdk.ThreadsLeave()
}
gtk.MainQuit()
})()
go (func() {
for i := 300000; i >= 0; i-- {
gdk.ThreadsEnter()
label2.SetLabel(strconv.Itoa(i))
gdk.ThreadsLeave()
}
gtk.MainQuit()
})()
gtk.Main()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:39,代码来源:threads.go
示例13: SetBiomeAt
func (rw *RegionWrapper) SetBiomeAt(x, z int, bio mcmap.Biome) {
cx, cz, bx, bz := mcmap.BlockToChunk(x, z)
pos := XZPos{cx, cz}
chunk, err := rw.region.Chunk(cx, cz)
switch err {
case nil:
case mcmap.NotAvailable:
return
default:
rw.guicbs.reportFail(fmt.Sprintf("Error while getting chunk %d, %d: %s", cx, cz, err))
return
}
chunk.SetBiome(bx, bz, bio)
var newcol *gdk.Color
if rw.fixSnowIce {
newcol = rw.fixWeather(bio, bx, bz, chunk)
}
chunk.MarkModified()
// Update cache
if bc, ok := rw.bioCache[pos]; ok {
bc[bz*mcmap.ChunkSizeXZ+bx] = bio
}
// Update tile
if biotile, ok := rw.Biotiles[pos]; ok {
gdk.ThreadsEnter()
drawable := biotile.GetDrawable()
gc := gdk.NewGC(drawable)
gc.SetRgbFgColor(rw.bioLookup.Color(bio))
drawable.DrawRectangle(gc, true, bx*zoom, bz*zoom, zoom, zoom)
if newcol != nil {
drawable = rw.Maptiles[pos].GetDrawable()
gc = gdk.NewGC(drawable)
gc.SetRgbFgColor(newcol)
drawable.DrawRectangle(gc, true, bx*zoom, bz*zoom, zoom, zoom)
}
gdk.ThreadsLeave()
}
}
开发者ID:kch42,项目名称:biomed,代码行数:47,代码来源:region_wrapper.go
示例14: Startup
func Startup() {
gdk.ThreadsInit()
gdk.ThreadsEnter()
initializeEnvironment()
gtk.Init(nil)
window := windows.MainWindow()
window.ShowAll()
config := models.Config()
if config.AccessToken == "" {
authWindow := windows.AuthWindow()
authWindow.ShowAll()
}
gtk.Main()
}
开发者ID:chdorner,项目名称:ghighlighter,代码行数:17,代码来源:main.go
示例15: guiMain
func guiMain(ch <-chan Accounts) {
glib.ThreadInit(nil)
gdk.ThreadsInit()
gdk.ThreadsEnter()
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("password")
window.Connect("destroy", gtk.MainQuit)
entry := gtk.NewEntry()
store := gtk.NewListStore(glib.G_TYPE_STRING)
treeview := gtk.NewTreeView()
treeview.SetModel(store)
// treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("icon", gtk.NewCellRendererPixbuf(), "pixbuf", 0))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("name", gtk.NewCellRendererText(), "text", 0))
go func() {
for accounts := range ch {
gthread(func() {
store.Clear()
for _, a := range accounts {
var iter gtk.TreeIter
store.Append(&iter)
store.Set(&iter, 0, a.Name)
}
})
}
}()
swin := gtk.NewScrolledWindow(nil, nil)
swin.Add(treeview)
vbox := gtk.NewVBox(false, 0)
vbox.PackStart(entry, false, false, 1)
vbox.PackStart(swin, true, true, 0)
window.Add(vbox)
window.SetSizeRequest(460, 640)
window.SetResizable(false)
window.ShowAll()
}
开发者ID:pocke,项目名称:password,代码行数:45,代码来源:gui.go
示例16: unlinked_main
func unlinked_main() {
devices := SearchValid()
for _, x := range devices {
MainGui.appendItem("/dev/hidraw"+strconv.FormatUint(x.SeqNum(), 10), x.SysAttrValue("product"))
}
/////////// THIS IS JUST FOR DEBUG PURPOSE //////////////
//MainGui.appendItem("prova1", "prova 123")
//MainGui.appendItem("prova2", "Prova 123")
//MainGui.appendItem("prova3", "prova 123")
//MainGui.appendItem("prova4", "prova 1234")
///////////////////////////////////////////////////////
gdk.ThreadsEnter()
MainGui.SplashWindow.Hide()
//ctx := MainGui.Status.GetContextId("prova 123")
MainGui.Status.Push(0, "ready for operate")
MainGui.MainWindow.ShowAll()
gdk.ThreadsLeave()
}
开发者ID:spaghetty,项目名称:gunnify,代码行数:18,代码来源:gunnify.go
示例17: inotify_observe
func inotify_observe() {
buf := make([]byte, event_size*NEVENTS)
for {
collect := inotify_observe_collect(buf)
if 0 == len(collect) {
continue
}
gdk.ThreadsEnter()
file_save_current()
reload := inotify_dialog(collect)
for name, _ := range collect {
rec, rec_found := file_map[name]
if false == rec_found {
tabby_log("inotify_observe: " + name + " not found in file_map")
continue
}
if reload {
// Reload file content.
read_ok, buf := open_file_read_to_buf(name, true)
if read_ok {
rec.buf = buf
rec.modified = false
inotify_rm_watch(name)
inotify_add_watch(name)
} else {
rec.modified = true
}
} else {
// Keep file as is.
rec.modified = true
}
}
file_tree_store()
// So as to renew current TextBuffer it is required to switch to cur_file.
file_switch_to(cur_file)
gdk.ThreadsLeave()
}
}
开发者ID:udhos,项目名称:tabby,代码行数:38,代码来源:inotify_unix.go
示例18: buttonChanged
func (mw *MapWidget) buttonChanged(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
bev := *(**gdk.EventButton)(unsafe.Pointer(&arg))
switch gdk.EventType(bev.Type) {
case gdk.BUTTON_RELEASE:
if mw.panning {
mw.panning = false
mw.updateChunkBounds()
gdk.ThreadsLeave()
mw.regWrap.UpdateTiles()
gdk.ThreadsEnter()
}
mw.continueTool = false
case gdk.BUTTON_PRESS:
switch bev.Button {
case 1:
if !mw.regWrap.RegionLoaded() {
return
}
x := (mw.offX + int(bev.X)) / zoom
z := (mw.offZ + int(bev.Y)) / zoom
mw.regWrap.UseTool(x, z)
mw.updateGUI()
if !mw.regWrap.ToolSingleClick() {
mw.continueTool = true
}
case 2:
mw.panning = true
}
}
}
开发者ID:kch42,项目名称:biomed,代码行数:37,代码来源:mapwidget.go
示例19: main
func main() {
gtk.Init(&os.Args)
gdk.ThreadsInit()
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Twitter!")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
scrolledwin := gtk.NewScrolledWindow(nil, nil)
textview := gtk.NewTextView()
textview.SetEditable(false)
textview.SetCursorVisible(false)
scrolledwin.Add(textview)
vbox.Add(scrolledwin)
buffer := textview.GetBuffer()
tag := buffer.CreateTag("blue", map[string]string{
"foreground": "#0000FF", "weight": "700"})
button := gtk.NewButtonWithLabel("Update Timeline")
button.SetTooltipMarkup("update <b>public timeline</b>")
button.Clicked(func() {
b, err := ioutil.ReadFile("settings.json")
if err != nil {
fmt.Println(`"settings.json" not found: `, err)
return
}
var config map[string]string
err = json.Unmarshal(b, &config)
if err != nil {
fmt.Println(`can't read "settings.json": `, err)
return
}
client := &oauth.Client{
Credentials: oauth.Credentials{
config["ClientToken"], config["ClientSecret"]}}
cred := &oauth.Credentials{
config["AccessToken"], config["AccessSecret"]}
gdk.ThreadsEnter()
button.SetSensitive(false)
gdk.ThreadsLeave()
go func() {
ts, err := twitterstream.Open(client, cred,
"https://stream.twitter.com/1/statuses/filter.json",
url.Values{"track": {"picplz,instagr"}})
if err != nil {
println(err.Error())
return
}
for ts.Err() == nil {
t := tweet{}
if err := ts.UnmarshalNext(&t); err != nil {
fmt.Println("error reading tweet: ", err)
continue
}
var iter gtk.TextIter
pixbufbytes, resp := readURL(t.User.ProfileImageUrl)
gdk.ThreadsEnter()
buffer.GetStartIter(&iter)
if resp != nil {
buffer.InsertPixbuf(&iter, bytes2pixbuf(pixbufbytes, resp.Header.Get("Content-Type")))
}
gdk.ThreadsLeave()
gdk.ThreadsEnter()
buffer.Insert(&iter, " ")
buffer.InsertWithTag(&iter, t.User.ScreenName, tag)
buffer.Insert(&iter, ":"+t.Text+"\n")
gtk.MainIterationDo(false)
gdk.ThreadsLeave()
}
}()
})
vbox.PackEnd(button, false, false, 0)
window.Add(vbox)
window.SetSizeRequest(800, 500)
window.ShowAll()
gdk.ThreadsEnter()
gtk.Main()
gdk.ThreadsLeave()
}
开发者ID:arip33,项目名称:go-gtk,代码行数:83,代码来源:twitterstream.go
示例20: main
func main() {
gdk.ThreadsInit()
gtk.Init(&os.Args)
window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
window.SetTitle("Twitter!")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.VBox(false, 1)
scrolledwin := gtk.ScrolledWindow(nil, nil)
textview := gtk.TextView()
textview.SetEditable(false)
textview.SetCursorVisible(false)
scrolledwin.Add(textview)
vbox.Add(scrolledwin)
buffer := textview.GetBuffer()
tag := buffer.CreateTag("blue", map[string]string{
"foreground": "#0000FF", "weight": "700"})
button := gtk.ButtonWithLabel("Update Timeline")
button.SetTooltipMarkup("update <b>public timeline</b>")
button.Clicked(func() {
go func() {
gdk.ThreadsEnter()
button.SetSensitive(false)
gdk.ThreadsLeave()
r, err := http.Get("http://twitter.com/statuses/public_timeline.json")
if err == nil {
var b []byte
if r.ContentLength == -1 {
b, err = ioutil.ReadAll(r.Body)
} else {
b = make([]byte, r.ContentLength)
_, err = io.ReadFull(r.Body, b)
}
if err != nil {
println(err.String())
return
}
var j interface{}
json.NewDecoder(bytes.NewBuffer(b)).Decode(&j)
arr := j.([]interface{})
for i := 0; i < len(arr); i++ {
data := arr[i].(map[string]interface{})
icon := data["user"].(map[string]interface{})["profile_image_url"].(string)
var iter gtk.GtkTextIter
gdk.ThreadsEnter()
buffer.GetStartIter(&iter)
buffer.InsertPixbuf(&iter, url2pixbuf(icon))
gdk.ThreadsLeave()
name := data["user"].(map[string]interface{})["screen_name"].(string)
text := data["text"].(string)
gdk.ThreadsEnter()
buffer.Insert(&iter, " ")
buffer.InsertWithTag(&iter, name, tag)
buffer.Insert(&iter, ":"+text+"\n")
gtk.MainIterationDo(false)
gdk.ThreadsLeave()
}
}
button.SetSensitive(true)
}()
})
vbox.PackEnd(button, false, false, 0)
window.Add(vbox)
window.SetSizeRequest(800, 500)
window.ShowAll()
gdk.ThreadsEnter()
gtk.Main()
gdk.ThreadsLeave()
}
开发者ID:bmatsuo,项目名称:go-gtk,代码行数:73,代码来源:twitter.go
注:本文中的github.com/mattn/go-gtk/gdk.ThreadsEnter函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论