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


Golang gtk.Main函数代码示例

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


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

示例1: TestWebView_LoadHTML

func TestWebView_LoadHTML(t *testing.T) {
	webView := NewWebView()
	defer webView.Destroy()

	loadOk := false
	webView.Connect("load-failed", func() {
		t.Errorf("load failed")
	})
	webView.Connect("load-changed", func(_ *glib.Object, loadEvent LoadEvent) {
		switch loadEvent {
		case LoadFinished:
			loadOk = true
			gtk.MainQuit()
		}
	})

	glib.IdleAdd(func() bool {
		webView.LoadHTML("<p>hello</p>", "")
		return false
	})

	gtk.Main()

	if !loadOk {
		t.Error("!loadOk")
	}
}
开发者ID:elvuel,项目名称:go-webkit2,代码行数:27,代码来源:webview_test.go

示例2: TestWebView_URI

func TestWebView_URI(t *testing.T) {
	setup()
	defer teardown()

	mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {})

	wantURI := server.URL + "/"
	var gotURI string
	webView.Connect("notify::uri", func() {
		glib.IdleAdd(func() bool {
			gotURI = webView.URI()
			if gotURI != "" {
				gtk.MainQuit()
			}
			return false
		})
	})

	glib.IdleAdd(func() bool {
		webView.LoadURI(server.URL)
		return false
	})

	gtk.Main()

	if wantURI != gotURI {
		t.Errorf("want URI %q, got %q", wantURI, gotURI)
	}
}
开发者ID:elvuel,项目名称:go-webkit2,代码行数:29,代码来源:webview_test.go

示例3: main

func main() {
	gtk.Init(nil)
	initIcons()

	win := setupWindow("Go Example Testreport")

	var iter1, iter2 *gtk.TreeIter

	treeView, treeStore := setupTreeView()
	win.Add(treeView)

	// Add some rows to the tree store
	iter1 = addRow(treeStore, imageOK, "Testsuite 1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-2")
	addSubRow(treeStore, iter2, imageOK, "test1-2-1")
	addSubRow(treeStore, iter2, imageOK, "test1-2-2")
	addSubRow(treeStore, iter2, imageOK, "test1-2-3")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-3")
	iter1 = addRow(treeStore, imageFAIL, "Testsuite 2")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test2-1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test2-2")
	iter2 = addSubRow(treeStore, iter1, imageFAIL, "test2-3")
	addSubRow(treeStore, iter2, imageOK, "test2-3-1")
	addSubRow(treeStore, iter2, imageFAIL, "test2-3-2")

	win.ShowAll()
	gtk.Main()
}
开发者ID:yamnikov-oleg,项目名称:gotk3-examples,代码行数:29,代码来源:treeview2.go

示例4: main

func main() {
	gtk.Init(nil)
	window := ui.NewMainWindow()
	window.Window.ShowAll()

	gtk.Main()
}
开发者ID:juanfgs,项目名称:checkers,代码行数:7,代码来源:main.go

示例5: TestWebView_RunJavaScript

func TestWebView_RunJavaScript(t *testing.T) {
	webView := NewWebView()
	defer webView.Destroy()

	wantResultString := "abc"
	webView.Connect("load-changed", func(_ *glib.Object, loadEvent LoadEvent) {
		switch loadEvent {
		case LoadFinished:
			webView.RunJavaScript(`document.getElementById("foo").innerHTML`, func(result *gojs.Value, err error) {
				if err != nil {
					t.Errorf("RunJavaScript error: %s", err)
				}
				resultString := webView.JavaScriptGlobalContext().ToStringOrDie(result)
				if wantResultString != resultString {
					t.Errorf("want result string %q, got %q", wantResultString, resultString)
				}
				gtk.MainQuit()
			})
		}
	})

	glib.IdleAdd(func() bool {
		webView.LoadHTML(`<p id=foo>abc</p>`, "")
		return false
	})

	gtk.Main()
}
开发者ID:elvuel,项目名称:go-webkit2,代码行数:28,代码来源:webview_test.go

示例6: TestWebView_GetSnapshot

func TestWebView_GetSnapshot(t *testing.T) {
	webView := NewWebView()
	defer webView.Destroy()

	webView.Connect("load-changed", func(_ *glib.Object, loadEvent LoadEvent) {
		switch loadEvent {
		case LoadFinished:
			webView.GetSnapshot(func(img *image.RGBA, err error) {
				if err != nil {
					t.Errorf("GetSnapshot error: %q", err)
				}
				if img.Pix == nil {
					t.Error("!img.Pix")
				}
				if img.Stride == 0 || img.Rect.Max.X == 0 || img.Rect.Max.Y == 0 {
					t.Error("!img.Stride or !img.Rect.Max.X or !img.Rect.Max.Y")
				}
				gtk.MainQuit()
			})
		}
	})

	glib.IdleAdd(func() bool {
		webView.LoadHTML(`<p id=foo>abc</p>`, "")
		return false
	})

	gtk.Main()
}
开发者ID:elvuel,项目名称:go-webkit2,代码行数:29,代码来源:webview_test.go

示例7: Example

func Example() {
	gtk.Init(nil)
	go func() {
		runtime.LockOSThread()
		gtk.Main()
	}()

	ctx := webloop.New()
	view := ctx.NewView()
	defer view.Close()
	view.Open("http://google.com")
	err := view.Wait()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to load URL: %s", err)
		os.Exit(1)
	}
	res, err := view.EvaluateJavaScript("document.title")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to run JavaScript: %s", err)
		os.Exit(1)
	}
	fmt.Printf("JavaScript returned: %q\n", res)
	// output:
	// JavaScript returned: "Google"
}
开发者ID:pasangsherpa,项目名称:webloop,代码行数:25,代码来源:example_test.go

示例8: TestWebView_LoadURI_load_failed

func TestWebView_LoadURI_load_failed(t *testing.T) {
	webView := NewWebView()
	defer webView.Destroy()

	loadFailed := false
	loadFinished := false
	webView.Connect("load-failed", func() {
		loadFailed = true
	})
	webView.Connect("load-changed", func(_ *glib.Object, loadEvent LoadEvent) {
		switch loadEvent {
		case LoadFinished:
			loadFinished = true
			gtk.MainQuit()
		}
	})

	glib.IdleAdd(func() bool {
		// Load a bad URL to trigger load failure.
		webView.LoadURI("http://127.0.0.1:99999")
		return false
	})

	gtk.Main()

	if !loadFailed {
		t.Error("!loadFailed")
	}
	if !loadFinished {
		t.Error("!loadFinished")
	}
}
开发者ID:elvuel,项目名称:go-webkit2,代码行数:32,代码来源:webview_test.go

示例9: init

func init() {
	gtk.Init(nil)
	go func() {
		runtime.LockOSThread()
		gtk.Main()
	}()
}
开发者ID:ezoic,项目名称:webloop,代码行数:7,代码来源:webloop_test.go

示例10: main

func main() {
	// Initialize GTK without parsing any command line arguments.
	gtk.Init(nil)

	// Create a new toplevel window, set its title, and connect it to the
	// "destroy" signal to exit the GTK main loop when it is destroyed.
	win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
	if err != nil {
		log.Fatal("Unable to create window:", err)
	}
	win.SetTitle("Simple Example")
	win.Connect("destroy", func() {
		gtk.MainQuit()
	})

	// Create a new label widget to show in the window.
	list, err := gtk.ListBoxNew()
	if err != nil {
		log.Fatal("Unable to create label:", err)
	}
	gtkList = list
	// Add the label to the window.
	win.Add(gtkList)

	// Set the default window size.
	win.SetDefaultSize(640/2, 1136/2)

	// Recursively show all widgets contained in this window.
	win.ShowAll()

	// Begin executing the GTK main loop.  This blocks until
	// gtk.MainQuit() is run.
	go getEntries()
	gtk.Main()
}
开发者ID:MobiusHorizons,项目名称:GoStudentNews,代码行数:35,代码来源:main.go

示例11: TestWebView_Title

func TestWebView_Title(t *testing.T) {
	webView := NewWebView()
	defer webView.Destroy()

	wantTitle := "foo"
	var gotTitle string
	webView.Connect("notify::title", func() {
		glib.IdleAdd(func() bool {
			gotTitle = webView.Title()
			if gotTitle != "" {
				gtk.MainQuit()
			}
			return false
		})
	})

	glib.IdleAdd(func() bool {
		webView.LoadHTML("<html><head><title>"+wantTitle+"</title></head><body></body></html>", "")
		return false
	})

	gtk.Main()

	if wantTitle != gotTitle {
		t.Errorf("want title %q, got %q", wantTitle, gotTitle)
	}
}
开发者ID:elvuel,项目名称:go-webkit2,代码行数:27,代码来源:webview_test.go

示例12: TestWebView_RunJavaScript_exception

func TestWebView_RunJavaScript_exception(t *testing.T) {
	webView := NewWebView()
	defer webView.Destroy()

	wantErr := errors.New("An exception was raised in JavaScript")
	webView.Connect("load-changed", func(_ *glib.Object, loadEvent LoadEvent) {
		switch loadEvent {
		case LoadFinished:
			webView.RunJavaScript(`throw new Error("foo")`, func(result *gojs.Value, err error) {
				if result != nil {
					ctx := webView.JavaScriptGlobalContext()
					t.Errorf("want result == nil, got %q", ctx.ToStringOrDie(result))
				}
				if !reflect.DeepEqual(wantErr, err) {
					t.Errorf("want error %q, got %q", wantErr, err)
				}
				gtk.MainQuit()
			})
		}
	})

	glib.IdleAdd(func() bool {
		webView.LoadHTML(`<p></p>`, "")
		return false
	})

	gtk.Main()
}
开发者ID:elvuel,项目名称:go-webkit2,代码行数:28,代码来源:webview_test.go

示例13: main

func main() {
	gtk.Init(nil)
	go func() {
		appdbus.StandAlone(TVPlay.NewApplet)
		gtk.MainQuit()
	}()
	gtk.Main()
}
开发者ID:sqp,项目名称:godock,代码行数:8,代码来源:applet.go

示例14: StartGTK

// StartGTK ensures that the GTK+ main loop has started. If it has already been
// started by StartGTK, it will not start it again. If another goroutine is
// already running the GTK+ main loop, StartGTK's behavior is undefined.
func (h *StaticRenderer) StartGTK() {
	startGTKOnce.Do(func() {
		gtk.Init(nil)
		go func() {
			runtime.LockOSThread()
			gtk.Main()
		}()
	})
}
开发者ID:ezoic,项目名称:webloop,代码行数:12,代码来源:static_renderer.go

示例15: Loop

func (u *gtkUI) Loop() {
	go u.loadConfig(*config.ConfigFile)

	go u.watchCommands()
	go u.observeAccountEvents()

	doInUIThread(u.mainWindow)
	gtk.Main()
}
开发者ID:0x27,项目名称:coyim,代码行数:9,代码来源:ui.go


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