Integrated the custom GTK+ container. Woo! Now to do minor fixups...
This commit is contained in:
parent
9cad7bf60b
commit
de22660ae4
|
@ -33,7 +33,7 @@ static void goContainer_init(goContainer *c)
|
|||
|
||||
static void goContainer_dispose(GObject *obj)
|
||||
{
|
||||
g_ptr_array_unref(c->children);
|
||||
g_ptr_array_unref(GOCONTAINER(obj)->children);
|
||||
G_OBJECT_CLASS(goContainer_parent_class)->dispose(obj);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ static void goContainer_remove(GtkContainer *container, GtkWidget *widget)
|
|||
static void goContainer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
|
||||
{
|
||||
gtk_widget_set_allocation(widget, allocation);
|
||||
containerResized(GOCONTAINER(widget)->gocontainer, allocation);
|
||||
containerResizing(GOCONTAINER(widget)->gocontainer, allocation);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -105,9 +105,9 @@ static void goContainer_class_init(goContainerClass *class)
|
|||
GTK_CONTAINER_CLASS(class)->forall = goContainer_forall;
|
||||
}
|
||||
|
||||
GtkWidget *newContainer(void *gocontianer)
|
||||
GtkWidget *newContainer(void *gocontainer)
|
||||
{
|
||||
GoContainer *c;
|
||||
goContainer *c;
|
||||
|
||||
c = (goContainer *) g_object_new(GOCONTAINER_TYPE, NULL);
|
||||
c->gocontainer = gocontainer;
|
||||
|
|
|
@ -10,14 +10,12 @@ import (
|
|||
)
|
||||
|
||||
// #include "gtk_unix.h"
|
||||
// extern void containerResizing(GtkWidget *, GdkRectangle *, gpointer);
|
||||
import "C"
|
||||
|
||||
type container struct {
|
||||
containerbase
|
||||
layoutwidget *C.GtkWidget
|
||||
layoutcontainer *C.GtkContainer
|
||||
layout *C.GtkLayout
|
||||
}
|
||||
|
||||
type sizing struct {
|
||||
|
@ -31,23 +29,12 @@ type sizing struct {
|
|||
}
|
||||
|
||||
func newContainer(child Control) *container {
|
||||
widget := C.gtk_layout_new(nil, nil)
|
||||
c := &container{
|
||||
layoutwidget: widget,
|
||||
layoutcontainer: (*C.GtkContainer)(unsafe.Pointer(widget)),
|
||||
layout: (*C.GtkLayout)(unsafe.Pointer(widget)),
|
||||
}
|
||||
c := new(container)
|
||||
widget := C.newContainer(unsafe.Pointer(c))
|
||||
c.layoutwidget = widget
|
||||
c.layoutcontainer = (*C.GtkContainer)(unsafe.Pointer(widget))
|
||||
c.child = child
|
||||
c.child.setParent(&controlParent{c.layoutcontainer})
|
||||
// we connect to the layout's size-allocate, not to the window's configure-event
|
||||
// this allows us to handle client-side decoration-based configurations (such as GTK+ on Wayland) properly
|
||||
// also see basecommitResize() in control_unix.go for additional notes
|
||||
// thanks to many people in irc.gimp.net/#gtk+ for help (including tristan for suggesting g_signal_connect_after())
|
||||
g_signal_connect_after(
|
||||
C.gpointer(unsafe.Pointer(c.layout)),
|
||||
"size-allocate",
|
||||
C.GCallback(C.containerResizing),
|
||||
C.gpointer(unsafe.Pointer(c)))
|
||||
return c
|
||||
}
|
||||
|
||||
|
@ -56,10 +43,9 @@ func (c *container) setParent(p *controlParent) {
|
|||
}
|
||||
|
||||
//export containerResizing
|
||||
func containerResizing(wid *C.GtkWidget, r *C.GdkRectangle, data C.gpointer) {
|
||||
c := (*container)(unsafe.Pointer(data))
|
||||
// the GtkLayout's coordinate system is localized, so the origin is (0, 0)
|
||||
c.resize(0, 0, int(r.width), int(r.height))
|
||||
func containerResizing(data unsafe.Pointer, r *C.GtkAllocation) {
|
||||
c := (*container)(data)
|
||||
c.resize(int(r.x), int(r.y), int(r.width), int(r.height))
|
||||
fmt.Printf("new size %d x %d\n", r.width, r.height)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue