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