summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-13 23:37:54 -0400
committerPietro Gagliardi <[email protected]>2014-08-13 23:37:54 -0400
commitde22660ae46b1b8054d37af9150081752b023e16 (patch)
tree9c4abf05ca7ee7513f6fd68a362065654959a4a5
parent9cad7bf60b60daab0145fc7c1f11ede9cb00e1fd (diff)
Integrated the custom GTK+ container. Woo! Now to do minor fixups...
-rw-r--r--redo/container_unix.c8
-rw-r--r--redo/container_unix.go28
2 files changed, 11 insertions, 25 deletions
diff --git a/redo/container_unix.c b/redo/container_unix.c
index 4fae714..15a2ecb 100644
--- a/redo/container_unix.c
+++ b/redo/container_unix.c
@@ -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;
diff --git a/redo/container_unix.go b/redo/container_unix.go
index 1b48fba..513f9d1 100644
--- a/redo/container_unix.go
+++ b/redo/container_unix.go
@@ -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)
}