Closed ghost closed 5 years ago
It works for me:
Oh wait sorry, the size works, the position doesn't change
Yes, I tested Move function too but it does nothing.
I tried to look at window.go and find the function SetPosition but there is just a binding to gtk_window_set_position, I cant help further maybe there is an error here? Where I can find the code for C.toGtkWindow(p) ?
p := unsafe.Pointer(v.GObject) return C.toGtkWindow(p)
So, Win Pos only works on startup. You gotta move it somehow else.I haven't done GTK in a while, so I am not sure how. Try this on startup for example:
appWindow.SetPosition(gtk.WIN_POS_MOUSE)
appWindow.SetTypeHint(gdk.WINDOW_TYPE_HINT_DIALOG)
What this does is basically suggesting the window manager to do something. Whether it actually does it, is up to the window manager.
Humm, I tried what you said, but its not working...
Maybe its a bug in upstream... tried a new Glade project changed all attributes to make the window at the center, the only setting that make the Window centred is to make it modal.
btw Iam using gnome 3.32
Well, I can assure you that it's wrong usage. If you wanna request a custom position, you gotta do it beforehand. If you wanna set the exact position beforehand, then use Window#Move. I am closing this, as it's deffo not a gtk bug or gotk3 bug.
Well i tried all solutions but its not working.
for the move function I used it and its not working for me (check the comment in the code provided). I tried your solution Setting the position @ activate signal not working too. I used glade to make sure is not related to gotk3
Ill go ask gnome team then.
Try this, that's what I meant.
package main
import (
"log"
"os"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
"github.com/gotk3/gotk3/gdk"
)
func main() {
const appID = "bla.bla.com"
gtk.Init(nil)
application, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE)
if err != nil {
log.Fatal("Could not create application.", err)
}
application.Connect("activate", onActivated)
application.Run(os.Args)
}
func onActivated(app *gtk.Application) {
appWindow, err := gtk.ApplicationWindowNew(app)
if err != nil {
log.Fatal("Could not create application window.", err)
}
button, err := gtk.ButtonNewWithLabel("Center Window")
if err != nil {
log.Fatal("Could not create button.", err)
}
appWindow.SetTitle("Basic Application.")
button.Connect("clicked", onButtonReleased, appWindow.Window)
appWindow.SetTypeHint(gdk.WINDOW_TYPE_HINT_DIALOG)
appWindow.Move(20,20)
appWindow.Add(button)
appWindow.ShowAll()
}
func onButtonReleased(btn *gtk.Button, userData interface{}) {
if win, ok := userData.(gtk.Window); ok {
win.SetTitle("Centred Application.")
win.SetSizeRequest(800, 600)
win.SetPosition(gtk.WIN_POS_CENTER)
//this is not working also
//win.SetGravity(gdk.GDK_GRAVITY_CENTER)
//win.Move(0, 0)
}
}
I leave a comment here if someone run in the same issue. After talking with gnome team in irc, they said that wayland doesn't let an application move its windows.
Oh. I am on X11.
Hi,
the function SetPosition for Window or ApplicationWindow is not working, I'm not sure if im doing it right, I just started learning GTK.
here is the code I used to test:
Any idea? Thanks
EDIT: Forgot to say that the title and Size request are working.