forked from jshiffer/go-xmpp
fix gui.
This commit is contained in:
parent
d92790f748
commit
df2ef04578
@ -11,14 +11,14 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
gtk.Init(&os.Args)
|
gtk.Init(&os.Args)
|
||||||
|
|
||||||
window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
|
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
|
||||||
window.SetTitle("GoTalk")
|
window.SetTitle("GoTalk")
|
||||||
window.Connect("destroy", func() {
|
window.Connect("destroy", func() {
|
||||||
gtk.MainQuit()
|
gtk.MainQuit()
|
||||||
})
|
})
|
||||||
vbox := gtk.VBox(false, 1)
|
vbox := gtk.NewVBox(false, 1)
|
||||||
scrolledwin := gtk.ScrolledWindow(nil, nil)
|
scrolledwin := gtk.NewScrolledWindow(nil, nil)
|
||||||
textview := gtk.TextView()
|
textview := gtk.NewTextView()
|
||||||
textview.SetEditable(false)
|
textview.SetEditable(false)
|
||||||
textview.SetCursorVisible(false)
|
textview.SetCursorVisible(false)
|
||||||
scrolledwin.Add(textview)
|
scrolledwin.Add(textview)
|
||||||
@ -26,44 +26,44 @@ func main() {
|
|||||||
|
|
||||||
buffer := textview.GetBuffer()
|
buffer := textview.GetBuffer()
|
||||||
|
|
||||||
entry := gtk.Entry()
|
entry := gtk.NewEntry()
|
||||||
vbox.PackEnd(entry, false, false, 0)
|
vbox.PackEnd(entry, false, false, 0)
|
||||||
|
|
||||||
window.Add(vbox)
|
window.Add(vbox)
|
||||||
window.SetSizeRequest(300, 400)
|
window.SetSizeRequest(300, 400)
|
||||||
window.ShowAll()
|
window.ShowAll()
|
||||||
|
|
||||||
dialog := gtk.Dialog()
|
dialog := gtk.NewDialog()
|
||||||
dialog.SetTitle(window.GetTitle())
|
dialog.SetTitle(window.GetTitle())
|
||||||
sgroup := gtk.SizeGroup(gtk.GTK_SIZE_GROUP_HORIZONTAL)
|
sgroup := gtk.NewSizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
|
||||||
|
|
||||||
hbox := gtk.HBox(false, 1)
|
hbox := gtk.NewHBox(false, 1)
|
||||||
dialog.GetVBox().Add(hbox)
|
dialog.GetVBox().Add(hbox)
|
||||||
label := gtk.Label("username:")
|
label := gtk.NewLabel("username:")
|
||||||
sgroup.AddWidget(label)
|
sgroup.AddWidget(label)
|
||||||
hbox.Add(label)
|
hbox.Add(label)
|
||||||
username := gtk.Entry()
|
username := gtk.NewEntry()
|
||||||
hbox.Add(username)
|
hbox.Add(username)
|
||||||
|
|
||||||
hbox = gtk.HBox(false, 1)
|
hbox = gtk.NewHBox(false, 1)
|
||||||
dialog.GetVBox().Add(hbox)
|
dialog.GetVBox().Add(hbox)
|
||||||
label = gtk.Label("password:")
|
label = gtk.NewLabel("password:")
|
||||||
sgroup.AddWidget(label)
|
sgroup.AddWidget(label)
|
||||||
hbox.Add(label)
|
hbox.Add(label)
|
||||||
password := gtk.Entry()
|
password := gtk.NewEntry()
|
||||||
password.SetVisibility(false)
|
password.SetVisibility(false)
|
||||||
hbox.Add(password)
|
hbox.Add(password)
|
||||||
|
|
||||||
dialog.AddButton(gtk.GTK_STOCK_OK, int(gtk.GTK_RESPONSE_OK))
|
dialog.AddButton(gtk.STOCK_OK, int(gtk.RESPONSE_OK))
|
||||||
dialog.AddButton(gtk.GTK_STOCK_CANCEL, int(gtk.GTK_RESPONSE_CANCEL))
|
dialog.AddButton(gtk.STOCK_CANCEL, int(gtk.RESPONSE_CANCEL))
|
||||||
dialog.SetDefaultResponse(int(gtk.GTK_RESPONSE_OK))
|
dialog.SetDefaultResponse(int(gtk.RESPONSE_OK))
|
||||||
dialog.SetTransientFor(window)
|
dialog.SetTransientFor(window)
|
||||||
dialog.ShowAll()
|
dialog.ShowAll()
|
||||||
res := dialog.Run()
|
res := dialog.Run()
|
||||||
username_ := username.GetText()
|
username_ := username.GetText()
|
||||||
password_ := password.GetText()
|
password_ := password.GetText()
|
||||||
dialog.Destroy()
|
dialog.Destroy()
|
||||||
if res != int(gtk.GTK_RESPONSE_OK) {
|
if res != gtk.RESPONSE_OK {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var iter gtk.GtkTextIter
|
var iter gtk.TextIter
|
||||||
buffer.GetStartIter(&iter)
|
buffer.GetStartIter(&iter)
|
||||||
buffer.Insert(&iter, chat.Remote+": "+chat.Text+"\n")
|
buffer.Insert(&iter, chat.Remote+": "+chat.Text+"\n")
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user