本文整理汇总了Golang中github.com/mattn/go-gtk/gtk.MainQuit函数的典型用法代码示例。如果您正苦于以下问题:Golang MainQuit函数的具体用法?Golang MainQuit怎么用?Golang MainQuit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MainQuit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
gtk.Init(&os.Args)
window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
window.Connect("delete-event", func() {
println("Delete-event occured\n")
})
window.Connect("destroy", func() { gtk.MainQuit() })
button := gtk.ButtonWithLabel("Hello, World")
button.Clicked(func() {
println("Hello, World\n")
})
button.Clicked(func() {
gtk.MainQuit()
})
window.Add(button)
window.ShowAll()
gtk.Main()
}
开发者ID:Dearth,项目名称:Character_Sheet,代码行数:25,代码来源:test.go
示例2: main
func main() {
FreeConsole()
gtk.Init(nil)
screenHeight := gdk.ScreenHeight()
screenWidth := gdk.ScreenWidth()
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("mgc")
window.SetIconName("gtk-about")
window.Connect("destroy", func() {
gtk.MainQuit()
})
vbox := gtk.NewVBox(false, 0)
menubar := gtk.NewMenuBar()
vbox.PackStart(menubar, false, false, 0)
menu := gtk.NewMenuItemWithMnemonic("_File")
menubar.Append(menu)
submenu := gtk.NewMenu()
menu.SetSubmenu(submenu)
menuitem := gtk.NewMenuItemWithMnemonic("E_xit")
menuitem.Connect("activate", func() {
gtk.MainQuit()
})
submenu.Append(menuitem)
hpaned := gtk.NewHPaned()
leftFrame := gtk.NewFrame("")
rightFrame := gtk.NewFrame("")
leftLabel := gtk.NewLabel("Left")
rightLabel := gtk.NewLabel("Right")
leftFrame.Add(leftLabel)
rightFrame.Add(rightLabel)
hpaned.Pack1(leftFrame, true, false)
hpaned.Pack2(rightFrame, true, false)
vbox.Add(hpaned)
window.Add(vbox)
window.SetSizeRequest(screenWidth/4*3, screenHeight/4*3)
window.ShowAll()
gtk.Main()
}
开发者ID:vsannikov,项目名称:mgc,代码行数:54,代码来源:main.go
示例3: main
func main() {
gtk.Init(&os.Args)
glib.SetApplicationName("go-gtk-statusicon-example")
mi := gtk.NewMenuItemWithLabel("Popup!")
mi.Connect("activate", func() {
gtk.MainQuit()
})
nm := gtk.NewMenu()
nm.Append(mi)
nm.ShowAll()
si := gtk.NewStatusIconFromStock(gtk.STOCK_FILE)
si.SetTitle("StatusIcon Example")
si.SetTooltipMarkup("StatusIcon Example")
si.Connect("popup-menu", func(cbx *glib.CallbackContext) {
nm.Popup(nil, nil, gtk.StatusIconPositionMenu, si, uint(cbx.Args(0)), uint(cbx.Args(1)))
})
println(`
Can you see statusicon in systray?
If you don't see it and if you use 'unity', try following.
# gsettings set com.canonical.Unity.Panel systray-whitelist \
"$(gsettings get com.canonical.Unity.Panel systray-whitelist \|
sed -e "s/]$/, 'go-gtk-statusicon-example']/")"
`)
gtk.Main()
}
开发者ID:JessonChan,项目名称:go-gtk,代码行数:31,代码来源:statusicon.go
示例4: CreateGuiController
func CreateGuiController() *GuiController {
guiController := &GuiController{}
guiController.buttons = make([]*gtk.Button, 0)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("GTK Go!")
window.SetIconName("gtk-dialog-info")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
fmt.Println("got destroy!", ctx.Data().(string))
gtk.MainQuit()
}, "foo")
buttonsBox := gtk.NewHBox(false, 1)
black := gdk.NewColorRGB(0, 0, 0)
for i := 0; i < 8; i++ {
button := gtk.NewButtonWithLabel(fmt.Sprint(i))
button.ModifyBG(gtk.STATE_NORMAL, black)
guiController.buttons = append(guiController.buttons, button)
buttonsBox.Add(button)
}
window.Add(buttonsBox)
window.SetSizeRequest(600, 600)
window.ShowAll()
return guiController
}
开发者ID:uvgroovy,项目名称:dmx,代码行数:30,代码来源:dmxd.go
示例5: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("Hello GTK+Go world!")
window.SetIconName("gtk-dialog-info")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
gtk.MainQuit()
}, "foo")
vbox := gtk.NewVBox(false, 1)
button := gtk.NewButtonWithLabel("Hello world!")
button.SetTooltipMarkup("Say Hello World to everybody!")
button.Clicked(func() {
messagedialog := gtk.NewMessageDialog(
button.GetTopLevelAsWindow(),
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
"Hello!")
messagedialog.Response(func() {
messagedialog.Destroy()
})
messagedialog.Run()
})
vbox.PackStart(button, false, false, 0)
window.Add(vbox)
window.SetSizeRequest(300, 50)
window.ShowAll()
gtk.Main()
}
开发者ID:olecya,项目名称:goeg,代码行数:30,代码来源:golang_hello.go
示例6: initWebView
func initWebView() *webkit.WebView {
gtk.Init(nil)
webview := webkit.NewWebView()
webview.Connect("load-error", func() {
fmt.Printf("Load Error: %s\n", webview.GetUri())
})
webview.Connect("onload-event", func() {
fmt.Printf("Onload Event: %s\n", webview.GetUri())
})
webview.Connect("resource-load-finished", func(wv interface{}) {
fmt.Printf("Resource Load Finished: %v\n", wv)
})
webview.Connect("load-committed", func() {
//entry.SetText(webview.GetUri())
fmt.Printf("Load Committed: %s\n", webview.GetUri())
})
webview.Connect("load-finished", func() {
//entry.SetText(webview.GetUri())
fmt.Printf("Load Finished: %s\n", webview.GetUri())
//time.Sleep(time.Second)
title := webview.GetTitle()
webview.ExecuteScript("document.title=document.documentElement.innerHTML")
str := webview.GetTitle()
webview.ExecuteScript("document.title=" + title)
fmt.Printf("Html: %s\n", str)
gtk.MainQuit()
})
webview.LoadHtmlString(HTML_STRING, ".")
gtk.Main()
return webview
}
开发者ID:zackb,项目名称:code,代码行数:32,代码来源:webkit.go
示例7: main
func main() {
gtk.Init(nil)
window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
window.SetTitle("Click me")
label := gtk.Label("There have been no clicks yet")
var clicks int
button := gtk.ButtonWithLabel("click me")
button.Clicked(func() {
clicks++
if clicks == 1 {
label.SetLabel("Button clicked 1 time")
} else {
label.SetLabel(fmt.Sprintf("Button clicked %d times",
clicks))
}
})
vbox := gtk.VBox(false, 1)
vbox.Add(label)
vbox.Add(button)
window.Add(vbox)
window.Connect("destroy", func() {
gtk.MainQuit()
})
window.ShowAll()
gtk.Main()
}
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:26,代码来源:simple-windowed-application.go
示例8: 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
示例9: exit_cb
func exit_cb() {
// Are-you-sure-you-want-to-exit-because-file-is-unsaved logic will be here.
session_save()
if nil != listener {
listener.Close()
}
gtk.MainQuit()
}
开发者ID:mattn,项目名称:tabby,代码行数:8,代码来源:menu_callback.go
示例10: main
func main() {
gtk.Init(nil)
window := CreateWindow()
window.SetPosition(gtk.WIN_POS_CENTER)
window.Connect("destroy", func(ctx *glib.CallbackContext) {
fmt.Println("destroy pending...")
gtk.MainQuit()
}, "foo")
window.ShowAll()
gtk.Main()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:11,代码来源:action.go
示例11: buildMenuBar
func (w *GhMainWindow) buildMenuBar() *gtk.GtkMenuBar {
menubar := gtk.MenuBar()
fileMenuItem := gtk.MenuItemWithMnemonic("_File")
menubar.Append(fileMenuItem)
fileMenu := gtk.Menu()
fileMenuItem.SetSubmenu(fileMenu)
syncMenuItem := gtk.MenuItemWithMnemonic("_Sync")
syncMenuItem.Connect("activate", func() {
w.openSyncWindow()
})
fileMenu.Append(syncMenuItem)
separatorMenuItem := gtk.SeparatorMenuItem()
fileMenu.Append(separatorMenuItem)
quitMenuItem := gtk.MenuItemWithMnemonic("_Quit")
quitMenuItem.Connect("activate", func() {
gtk.MainQuit()
})
fileMenu.Append(quitMenuItem)
viewMenuItem := gtk.MenuItemWithMnemonic("_View")
menubar.Append(viewMenuItem)
viewMenu := gtk.Menu()
viewMenuItem.SetSubmenu(viewMenu)
queuedHighlightsMenuItem := gtk.MenuItemWithMnemonic("Queued _Highlights")
queuedHighlightsMenuItem.Connect("activate", func() {
w.openQueuedHighlightsWindow()
})
viewMenu.Append(queuedHighlightsMenuItem)
helpMenuItem := gtk.MenuItemWithMnemonic("_Help")
menubar.Append(helpMenuItem)
helpMenu := gtk.Menu()
helpMenuItem.SetSubmenu(helpMenu)
aboutMenuItem := gtk.MenuItemWithMnemonic("About")
aboutMenuItem.Connect("activate", func() {
aboutDialog := AboutDialog()
dialog := aboutDialog.GtkAboutDialog
dialog.Run()
dialog.Destroy()
})
helpMenu.Append(aboutMenuItem)
return menubar
}
开发者ID:chdorner,项目名称:ghighlighter,代码行数:53,代码来源:main_window.go
示例12: bindKeys
func (window *GhAuthWindow) bindKeys() {
window.Connect("key-press-event", func(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
keyEvent := *(**gdk.EventKey)(unsafe.Pointer(&arg))
if int(keyEvent.State) == int(gdk.GDK_CONTROL_MASK) {
if keyEvent.Keyval == gdk.GDK_KEY_w {
window.Destroy()
} else if keyEvent.Keyval == gdk.GDK_KEY_q {
gtk.MainQuit()
}
}
})
}
开发者ID:chdorner,项目名称:ghighlighter,代码行数:13,代码来源:auth_window.go
示例13: 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
示例14: buildGUI
func (g *Gui) buildGUI() {
g.MainWindow = gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
g.MainWindow.SetPosition(gtk.WIN_POS_CENTER)
g.MainWindow.SetTitle("Gunnify")
g.MainWindow.SetIconName("gtk-dialog-info")
g.MainWindow.Connect("destroy", func(ctx *glib.CallbackContext) {
println("got destroy!", ctx.Data().(string))
gtk.MainQuit()
}, "foo")
g.MainWindow.SetSizeRequest(600, 300)
vbox := gtk.NewVBox(false, 0)
g.buildList(vbox)
g.MainWindow.Add(vbox)
}
开发者ID:spaghetty,项目名称:gunnify,代码行数:14,代码来源:gunnify.go
示例15: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetSizeRequest(150, 50)
window.SetPosition(gtk.WIN_POS_CENTER)
window.Connect("destroy", func(ctx *glib.CallbackContext) {
gtk.MainQuit()
}, nil)
label := gtk.NewLabel("hello world")
window.Add(label)
window.ShowAll()
gtk.Main()
}
开发者ID:ecdhe,项目名称:various_language_examples,代码行数:16,代码来源:go_gogtk.go
示例16: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("GTK Go!")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
fmt.Println("got destroy!", ctx.Data().(string))
gtk.MainQuit()
}, "foo")
//--------------------------------------------------------
// GtkHBox
//--------------------------------------------------------
fixed := gtk.NewFixed()
//--------------------------------------------------------
// GtkSpinButton
//--------------------------------------------------------
spinbutton1 := gtk.NewSpinButtonWithRange(1.0, 10.0, 1.0)
spinbutton1.SetDigits(3)
spinbutton1.Spin(gtk.SPIN_STEP_FORWARD, 7.0)
fixed.Put(spinbutton1, 40, 50)
spinbutton1.OnValueChanged(func() {
val := spinbutton1.GetValueAsInt()
fval := spinbutton1.GetValue()
fmt.Println("SpinButton changed, new value: " + strconv.Itoa(val) + " | " + strconv.FormatFloat(fval, 'f', 2, 64))
min, max := spinbutton1.GetRange()
fmt.Println("Range: " + strconv.FormatFloat(min, 'f', 2, 64) + " " + strconv.FormatFloat(max, 'f', 2, 64))
fmt.Println("Digits: " + strconv.Itoa(int(spinbutton1.GetDigits())))
})
adjustment := gtk.NewAdjustment(2.0, 1.0, 8.0, 2.0, 0.0, 0.0)
spinbutton2 := gtk.NewSpinButton(adjustment, 1.0, 1)
spinbutton2.SetRange(0.0, 20.0)
spinbutton2.SetValue(18.0)
spinbutton2.SetIncrements(2.0, 4.0)
fixed.Put(spinbutton2, 150, 50)
//--------------------------------------------------------
// Event
//--------------------------------------------------------
window.Add(fixed)
window.SetSizeRequest(600, 600)
window.ShowAll()
gtk.Main()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:47,代码来源:spinbutton.go
示例17: build
func (window *GhAuthWindow) build() {
window.bindKeys()
window.SetModal(true)
window.SetTitle("Readmill Authentication")
window.Connect("destroy", func() {
config := models.Config()
if config.AccessToken == "" {
gtk.MainQuit()
}
})
scrolledWindow := gtk.ScrolledWindow(nil, nil)
scrolledWindow.SetPolicy(gtk.GTK_POLICY_AUTOMATIC, gtk.GTK_POLICY_AUTOMATIC)
scrolledWindow.SetShadowType(gtk.GTK_SHADOW_IN)
webview := webkit.WebView()
webview.Connect("load-committed", func() {
uri := webview.GetUri()
matched, _ := regexp.MatchString(`^`+constants.READMILL_REDIRECT_URI+`/\?code=`, uri)
if matched {
webview.StopLoading()
codeRegex, _ := regexp.Compile(`\?code=([^&]*)`)
result := codeRegex.FindStringSubmatch(uri)
code := result[1]
token := readmilloauth.GetToken(constants.READMILL_CLIENT_ID, constants.READMILL_CLIENT_SECRET, constants.READMILL_REDIRECT_URI, code)
userId := readmilloauth.GetUserId(token)
config := models.Config()
config.AccessToken = token
config.UserId = userId
config.Write()
window.Destroy()
}
})
scrolledWindow.Add(webview)
authorizeUri := readmilloauth.AuthorizeUri(constants.READMILL_CLIENT_ID, constants.READMILL_REDIRECT_URI)
webview.LoadUri(authorizeUri)
window.Add(scrolledWindow)
window.SetSizeRequest(500, 650)
}
开发者ID:chdorner,项目名称:ghighlighter,代码行数:45,代码来源:auth_window.go
示例18: ShortTime
// ShortTime creates a GTK fullscreen window for the shorttime clients.
// No username/password required, only click 'start' button to log in
func ShortTime(client string, minutes int) (user string) {
// Inital window configuration
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
defer window.Destroy()
window.Fullscreen()
window.SetKeepAbove(true)
window.SetTitle("Mycel Login")
// Build GUI
frame := gtk.NewFrame("Logg deg på " + client)
frame.SetLabelAlign(0.5, 0.5)
var imageLoader *gdkpixbuf.Loader
imageLoader, _ = gdkpixbuf.NewLoaderWithMimeType("image/png")
imageLoader.Write(logo_png())
imageLoader.Close()
logo := gtk.NewImageFromPixbuf(imageLoader.GetPixbuf())
info := gtk.NewLabel("")
info.SetMarkup("<span foreground='red'>Dette er en korttidsmaskin\nMaks " +
strconv.Itoa(minutes) + " minutter!</span>")
button := gtk.NewButtonWithLabel("\nStart\n")
vbox := gtk.NewVBox(false, 20)
vbox.SetBorderWidth(20)
vbox.Add(logo)
vbox.Add(info)
vbox.Add(button)
frame.Add(vbox)
center := gtk.NewAlignment(0.5, 0.5, 0, 0)
center.Add(frame)
window.Add(center)
// Connect GUI event signals to function callbacks
button.Connect("clicked", func() {
gtk.MainQuit()
})
window.Connect("delete-event", func() bool {
return true
})
window.ShowAll()
gtk.Main()
return "Anonym"
}
开发者ID:digibib,项目名称:mycel-client,代码行数:47,代码来源:shorttime.go
示例19: main
func main() {
gtk.Init(&os.Args)
dialog := gtk.Dialog()
dialog.SetTitle("number input")
vbox := dialog.GetVBox()
label := gtk.Label("Numnber:")
vbox.Add(label)
input := gtk.Entry()
input.SetEditable(true)
vbox.Add(input)
input.Connect("insert-text", func(ctx *glib.CallbackContext) {
a := (*[2000]uint8)(unsafe.Pointer(ctx.Args(0)))
p := (*int)(unsafe.Pointer(ctx.Args(2)))
i := 0
for a[i] != 0 {
i++
}
s := string(a[0:i])
if s == "." {
if *p == 0 {
input.StopEmission("insert-text")
}
} else {
_, err := strconv.ParseFloat(s, 64)
if err != nil {
input.StopEmission("insert-text")
}
}
})
button := gtk.ButtonWithLabel("OK")
button.Connect("clicked", func() {
println(input.GetText())
gtk.MainQuit()
})
vbox.Add(button)
dialog.ShowAll()
gtk.Main()
}
开发者ID:leif,项目名称:go-gtk,代码行数:45,代码来源:number.go
示例20: main
func main() {
gtk.Init(&os.Args)
mi := gtk.MenuItemWithLabel("Popup!")
mi.Connect("activate", func() {
gtk.MainQuit()
})
nm := gtk.Menu()
nm.Append(mi)
nm.ShowAll()
si := gtk.StatusIconFromStock(gtk.GTK_STOCK_FILE)
si.Connect("popup-menu", func(cbx *glib.CallbackContext) {
nm.Popup(nil, nil, gtk.GtkStatusIconPositionMenu, si, uint(cbx.Args(0)), uint(cbx.Args(1)))
})
gtk.Main()
}
开发者ID:caengcjd,项目名称:go-gtk,代码行数:18,代码来源:statusicon.go
注:本文中的github.com/mattn/go-gtk/gtk.MainQuit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论