本文整理汇总了Golang中github.com/gotk3/gotk3/gtk.Init函数的典型用法代码示例。如果您正苦于以下问题:Golang Init函数的具体用法?Golang Init怎么用?Golang Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
gtk.Init(nil)
go func() {
runtime.LockOSThread()
gtk.Main()
}()
}
示例2: 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()
}
示例3: NewGTK
// NewGTK returns a new client for a GTK ui
func NewGTK(version string) UI {
coyimVersion = version
//*.mo files should be in ./i18n/locale_code.utf8/LC_MESSAGES/
glib.InitI18n("coy", "./i18n")
gtk.Init(argsWithApplicationName())
ret := >kUI{
commands: make(chan interface{}, 5),
toggleConnectAllAutomaticallyRequest: make(chan bool, 100),
setShowAdvancedSettingsRequest: make(chan bool, 100),
}
var err error
flags := glib.APPLICATION_FLAGS_NONE
if *config.MultiFlag {
flags = glib.APPLICATION_NON_UNIQUE
}
ret.app, err = gtk.ApplicationNew("im.coy.CoyIM", flags)
if err != nil {
panic(err)
}
ret.keySupplier = config.CachingKeySupplier(ret.getMasterPassword)
ret.accountManager = newAccountManager(ret)
return ret
}
示例4: 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"
}
示例5: main
func main() {
gtk.Init(nil)
window := ui.NewMainWindow()
window.Window.ShowAll()
gtk.Main()
}
示例6: 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()
}
示例7: main
func main() {
gtk.Init(nil)
go func() {
appdbus.StandAlone(TVPlay.NewApplet)
gtk.MainQuit()
}()
gtk.Main()
}
示例8: 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()
}()
})
}
示例9: InitGtk
// InitGtk provides GTK start and stop callbacks.
//
func InitGtk() (onstart, onstop func()) {
gtkStart := func() {
GRRTHREADS()
// runtime.LockOSThread()
gtk.Init(nil)
gtk.Main()
}
return gtkStart, gtk.MainQuit
}
示例10: main
func main() {
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
panicIfNotNil(err)
win.Connect("destroy", func() {
gtk.MainQuit()
})
win.SetDefaultSize(1280, 720)
win.SetTitle("mauIRC Desktop")
// Create a new grid widget to arrange child widgets
grid, err := gtk.GridNew()
panicIfNotNil(err)
grid.SetOrientation(gtk.ORIENTATION_VERTICAL)
loginLabel, err := gtk.LabelNew("Log in to mauIRC")
panicIfNotNil(err)
email, err := gtk.EntryNew()
panicIfNotNil(err)
password, err := gtk.EntryNew()
panicIfNotNil(err)
password.SetVisibility(false)
btn, err := gtk.ButtonNewWithLabel("Log in")
panicIfNotNil(err)
grid.Attach(loginLabel, 0, 2, 1, 1)
grid.Attach(email, 0, 3, 1, 1)
grid.Attach(password, 0, 4, 1, 1)
grid.Attach(btn, 0, 5, 1, 1)
//grid.Attach(nb, 1, 1, 1, 2)
//nb.SetHExpand(true)
//nb.SetVExpand(true)
/*nbChild, err := gtk.LabelNew("Notebook content")
if err != nil {
log.Fatal("Unable to create button:", err)
}
nbTab, err := gtk.LabelNew("Tab label")
if err != nil {
log.Fatal("Unable to create label:", err)
}
nb.AppendPage(nbChild, nbTab)*/
win.Add(grid)
win.ShowAll()
gtk.Main()
}
示例11: main
func main() {
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.Connect("destroy", func() {
gtk.MainQuit()
})
win.Add(windowWidget())
// Native GTK is not thread safe, and thus, gotk3's GTK bindings may not
// be used from other goroutines. Instead, glib.IdleAdd() must be used
// to add a function to run in the GTK main loop when it is in an idle
// state.
//
// Two examples of using glib.IdleAdd() are shown below. The first runs
// a user created function, LabelSetTextIdle, and passes it two
// arguments for a label and the text to set it with. The second calls
// (*gtk.Label).SetText directly, passing in only the text as an
// argument.
//
// If the function passed to glib.IdleAdd() returns one argument, and
// that argument is a bool, this return value will be used in the same
// manner as a native g_idle_add() call. If this return value is false,
// the function will be removed from executing in the GTK main loop's
// idle state. If the return value is true, the function will continue
// to execute when the GTK main loop is in this state.
go func() {
for {
time.Sleep(time.Second)
s := fmt.Sprintf("Set a label %d time(s)!", nSets)
_, err := glib.IdleAdd(LabelSetTextIdle, topLabel, s)
if err != nil {
log.Fatal("IdleAdd() failed:", err)
}
nSets++
s = fmt.Sprintf("Set a label %d time(s)!", nSets)
_, err = glib.IdleAdd(bottomLabel.SetText, s)
if err != nil {
log.Fatal("IdleAdd() failed:", err)
}
nSets++
}
}()
win.ShowAll()
gtk.Main()
}
示例12: TestConfig
func TestConfig(t *testing.T) {
gtk.Init(nil)
build := vdata.TestInit(vdata.New(log.NewLog(log.Logs), nil, nil), vdata.PathTestConf())
if build == nil {
return
}
build.BuildAll(pageswitch.New())
assert.Equal(t, countChanged(t, build), 0, "Build unchanged")
build.KeyWalk(vdata.TestValues)
assert.Equal(t, countChanged(t, build), 32, "Build full change")
}
示例13: main
func main() {
gtk.Init(nil)
win := setup_window(winTitle)
box := newStackFull()
win.Add(box)
// Recursively show all widgets contained in this window.
win.ShowAll()
// Begin executing the GTK main loop. This blocks until
// gtk.MainQuit() is run.
gtk.Main()
}
示例14: main
func main() {
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.Connect("destroy", func() {
gtk.MainQuit()
})
win.Add(windowWidget())
win.ShowAll()
gtk.Main()
}
示例15: Test_builderForDefinition_useGoFileIfXMLDoesntExists
func (s *UIReaderSuite) Test_builderForDefinition_useGoFileIfXMLDoesntExists(c *C) {
gtk.Init(nil)
removeFile("definitions/Test.xml")
//writeTestFile("definitions/TestDefinition.xml", testFile)
ui := "Test"
builder := builderForDefinition(ui)
win, getErr := builder.GetObject("conversation")
if getErr != nil {
fmt.Errorf("\nFailed to get window \n%s", getErr.Error())
c.Fail()
}
w, h := win.(*gtk.Window).GetSize()
c.Assert(h, Equals, 500)
c.Assert(w, Equals, 400)
}