[v3 linux] setEnabled

This commit is contained in:
Travis McLane 2023-06-23 21:44:02 -05:00
commit de5cff799e
3 changed files with 36 additions and 7 deletions

View file

@ -412,6 +412,15 @@ func getScreens(app pointer) ([]*Screen, error) {
}
// widgets
func widgetSetSensitive(widget pointer, enabled bool) {
value := C.int(0)
if enabled {
value = C.int(1)
}
C.gtk_widget_set_sensitive((*C.GtkWidget)(widget), value)
}
func widgetSetVisible(widget pointer, hidden bool) {
if hidden {
C.gtk_widget_hide((*C.GtkWidget)(widget))
@ -488,7 +497,7 @@ func windowGetSize(window pointer) (int, int) {
return int(windowWidth), int(windowHeight)
}
func windowGetPosition(window pointer) (int, int) {
func windowGetRelativePosition(window pointer) (int, int) {
var x C.int
var y C.int
C.gtk_window_get_position((*C.GtkWindow)(window), &x, &y)

View file

@ -614,6 +614,14 @@ func getScreens(app pointer) ([]*Screen, error) {
}
// widgets
func widgetSetSensitive(widget pointer, enabled bool) {
value := 0
if enabled {
value = 1
}
gtkWidgetSetSensitive(widget, value)
}
func widgetSetVisible(widget pointer, hidden bool) {
if hidden {
gtkWidgetHide(widget)
@ -665,6 +673,12 @@ func windowFullscreen(window pointer) {
gtkWindowFullScreen(window)
}
func windowGetAbsolutePosition(window pointer) (int, int) {
var x, y int
gtkWindowGetPosition(window, &x, &y)
return x, y
}
func windowGetCurrentMonitor(window pointer) pointer {
// Get the monitor that the window is currently on
display := gtkWidgetGetDisplay(window)

View file

@ -159,7 +159,7 @@ func (w *linuxWebviewWindow) fullscreen() {
w.setMinMaxSize(0, 0, width*scale, height*scale)
w.setSize(width*scale, height*scale)
windowFullscreen(w.window)
w.setPosition(0, 0)
w.setRelativePosition(0, 0)
})
}
@ -356,7 +356,7 @@ func (w *linuxWebviewWindow) size() (int, int) {
return windowGetSize(w.window)
}
func (w *linuxWebviewWindow) setPosition(x, y int) {
func (w *linuxWebviewWindow) setRelativePosition(x, y int) {
mx, my, _, _, _ := windowGetCurrentMonitorGeometry(w.window)
globalApplication.dispatchOnMainThread(func() {
windowMove(w.window, x+mx, y+my)
@ -426,7 +426,7 @@ func (w *linuxWebviewWindow) run() {
w.setFrameless(w.parent.options.Frameless)
if w.parent.options.X != 0 || w.parent.options.Y != 0 {
w.setPosition(w.parent.options.X, w.parent.options.Y)
w.setRelativePosition(w.parent.options.X, w.parent.options.Y)
} else {
fmt.Println("attempting to set in the center")
w.center()
@ -460,7 +460,7 @@ func (w *linuxWebviewWindow) run() {
if !w.parent.options.Hidden {
w.show()
if w.parent.options.X != 0 || w.parent.options.Y != 0 {
w.setPosition(w.parent.options.X, w.parent.options.Y)
w.setRelativePosition(w.parent.options.X, w.parent.options.Y)
} else {
w.center() // needs to be queued until after GTK starts up!
}
@ -479,12 +479,12 @@ func (w *linuxWebviewWindow) setBackgroundColour(colour RGBA) {
windowSetBackgroundColour(w.webview, colour)
}
func (w *linuxWebviewWindow) position() (int, int) {
func (w *linuxWebviewWindow) relativePosition() (int, int) {
var x, y int
var wg sync.WaitGroup
wg.Add(1)
go globalApplication.dispatchOnMainThread(func() {
x, y = windowGetPosition(w.window)
x, y = windowGetRelativePosition(w.window)
wg.Done()
})
wg.Wait()
@ -495,6 +495,12 @@ func (w *linuxWebviewWindow) destroy() {
windowDestroy(w.window)
}
func (w *linuxWebviewWindow) setEnabled(enabled bool) {
globalApplication.dispatchOnMainThread(func() {
widgetSetSensitive(w.window, enabled)
})
}
func (w *linuxWebviewWindow) setHTML(html string) {
windowSetHTML(w.webview, html)
}