Skip to content

Instantly share code, notes, and snippets.

@acsellers
Created July 13, 2012 03:46
Show Gist options
  • Save acsellers/3102587 to your computer and use it in GitHub Desktop.
Save acsellers/3102587 to your computer and use it in GitHub Desktop.
A gtk interface for Go that feels right
//go-gtk
func on_window_resize(){
window := gtk.WidgetFromObject(builder.GetObject("main_window"))
switcher := gtk.WidgetFromObject(builder.GetObject("main_switcher"))
vline := gtk.WidgetFromObject(builder.GetObject("vline"))
win_alloc := new(gtk.GtkAllocation)
window.GetAllocation(win_alloc)
sw_alloc := new(gtk.GtkAllocation)
switcher.GetAllocation(sw_alloc)
if sw_alloc.Width != win_alloc.Width - 74 || sw_alloc.Height != win_alloc.Height {
vline.SetSizeRequest(2,win_alloc.Height)
switcher.SetSizeRequest(win_alloc.Width - 74, win_alloc.Height)
Debug.Println("Resized switcher")
}
}
//gg (Planned)
func onMainWindowResize(resize gg.Size){
MainInterface.GetNotebook("main_switcher").SetSize(resize.Width - 74, resize.Height)
MainInterface.GetVLine("vline").SetSize(2, resize.Height)
}
//OR maybe
window := gg.NewWindow()
window.OnResize = func(window gg.Window, resize gg.Size){
window.GetNotebook("main_switcher").SetSize(resize.Width - 74, resize.Height)
window.GetVLine("vline").SetSize(2, resize.Height)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment