Ejemplo n.º 1
0
func (s *sysData) center() {
	ret := make(chan struct{})
	defer close(ret)
	uitask <- func() {
		if C.gtk_widget_get_visible(s.widget) == C.FALSE {
			// hint to the WM to make it centered when it is shown again
			// thanks to Jasper in irc.gimp.net/#gtk+
			C.gtk_window_set_position(togtkwindow(s.widget), C.GTK_WIN_POS_CENTER)
		} else {
			var width, height C.gint

			s.resetposition()
			//we should be able to use gravity to simplify this, but it doesn't take effect immediately, and adding show calls does nothing (thanks Jasper in irc.gimp.net/#gtk+)
			C.gtk_window_get_size(togtkwindow(s.widget), &width, &height)
			C.gtk_window_move(togtkwindow(s.widget),
				(C.gdk_screen_width()/2)-(width/2),
				(C.gdk_screen_height()/2)-(width/2))
		}
		ret <- struct{}{}
	}
	<-ret
}
Ejemplo n.º 2
0
func gtk_window_get_size(window *C.GtkWidget) (int, int) {
	var width, height C.gint

	C.gtk_window_get_size(togtkwindow(window), &width, &height)
	return int(width), int(height)
}
Ejemplo n.º 3
0
// GetSize is a wrapper around gtk_window_get_size().
func (v *Window) GetSize() (width, height int) {
	var w, h C.gint
	C.gtk_window_get_size(v.native(), &w, &h)
	return int(w), int(h)
}