本文整理汇总了Golang中github.com/mattn/go-gtk/gtk.MainQuit函数的典型用法代码示例。如果您正苦于以下问题:Golang MainQuit函数的具体用法?Golang MainQuit怎么用?Golang MainQuit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MainQuit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
}
示例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()
}
示例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()
}
示例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
}
示例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()
}
示例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
}
示例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()
}
示例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()
}
}
示例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()
}
示例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()
}
示例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
}
示例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()
}
}
})
}
示例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()
}
示例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)
}
示例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()
}