forked from Leak_Technologies/VideoTools
Rewrite gtkplayer entry cleanly
This commit is contained in:
parent
a4653dd116
commit
2e4b433f01
|
|
@ -34,13 +34,11 @@ func main() {
|
|||
grid.SetRowHomogeneous(false)
|
||||
win.Add(grid)
|
||||
|
||||
// Two panes for compare; left/right
|
||||
left := newPane()
|
||||
right := newPane()
|
||||
|
||||
controls := buildControls(win, left, right)
|
||||
grid.Attach(controls, 0, 0, 2, 1)
|
||||
|
||||
grid.Attach(left.area, 0, 1, 1, 1)
|
||||
grid.Attach(right.area, 1, 1, 1, 1)
|
||||
|
||||
|
|
@ -73,6 +71,7 @@ func newPane() *pane {
|
|||
return
|
||||
}
|
||||
p.mpv = mpv
|
||||
|
||||
if w, ok := da.GetWindow(); ok && w != nil {
|
||||
if xid := getWindowID(w); xid != 0 {
|
||||
_ = mpv.SetWID(xid)
|
||||
|
|
@ -90,7 +89,6 @@ func buildControls(win *gtk.Window, left, right *pane) *gtk.Box {
|
|||
box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 6)
|
||||
row1, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 4)
|
||||
row2, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 4)
|
||||
row3, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 4)
|
||||
|
||||
openL, _ := gtk.ButtonNewWithLabel("Open Left")
|
||||
openR, _ := gtk.ButtonNewWithLabel("Open Right")
|
||||
|
|
@ -145,7 +143,6 @@ func buildControls(win *gtk.Window, left, right *pane) *gtk.Box {
|
|||
}
|
||||
})
|
||||
|
||||
// Poll meta/progress
|
||||
go func() {
|
||||
t := time.NewTicker(500 * time.Millisecond)
|
||||
defer t.Stop()
|
||||
|
|
@ -167,7 +164,6 @@ func buildControls(win *gtk.Window, left, right *pane) *gtk.Box {
|
|||
|
||||
box.PackStart(row1, false, false, 0)
|
||||
box.PackStart(row2, false, false, 0)
|
||||
box.PackStart(row3, false, false, 0)
|
||||
return box
|
||||
}
|
||||
|
||||
|
|
@ -209,16 +205,14 @@ func metaSummary(a, b *pane) string {
|
|||
|
||||
// getWindowID returns the native window handle (XID on X11, HWND on Windows).
|
||||
func getWindowID(w *gdk.Window) uint64 {
|
||||
// X11
|
||||
if xid := gdkWindowGetXID(w); xid != 0 {
|
||||
return uint64(xid)
|
||||
if w == nil {
|
||||
return 0
|
||||
}
|
||||
// TODO: add Windows handle if needed.
|
||||
return 0
|
||||
return uint64(gdkWindowGetXID(w))
|
||||
}
|
||||
|
||||
// gdkWindowGetXID extracts the XID from a GDK window when running on X11.
|
||||
func gdkWindowGetXID(w *gdk.Window) uint {
|
||||
// gotk3 provides this method on GDK windows under X11
|
||||
return uint(w.GetXID())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user