当前位置: 首页>>代码示例>>Golang>>正文


Golang gdk.ThreadsLeave函数代码示例

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


在下文中一共展示了ThreadsLeave函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例6: 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

示例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() {
	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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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