summaryrefslogtreecommitdiff
path: root/new/container_unix.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-13 12:05:14 -0400
committerPietro Gagliardi <[email protected]>2015-04-13 12:05:14 -0400
commit19b85182b83e1eb6d8b91209594adb2f405a19bf (patch)
treea29e5155c09a707373c785fd8491a14eb05eccd8 /new/container_unix.c
parent4839280b8291fc31bd3ea8669d7d0395c6914ba8 (diff)
Did the GTK+ conversion to uiParent. Now to build.
Diffstat (limited to 'new/container_unix.c')
-rw-r--r--new/container_unix.c132
1 files changed, 0 insertions, 132 deletions
diff --git a/new/container_unix.c b/new/container_unix.c
deleted file mode 100644
index ec5d2f0..0000000
--- a/new/container_unix.c
+++ /dev/null
@@ -1,132 +0,0 @@
-// 13 august 2014
-#include "uipriv_unix.h"
-
-G_DEFINE_TYPE(uiContainer, uiContainer, GTK_TYPE_CONTAINER)
-
-static void uiContainer_init(uiContainer *c)
-{
- if (options.debugLogAllocations)
- fprintf(stderr, "%p alloc uiContainer\n", c);
- c->children = g_ptr_array_new();
- gtk_widget_set_has_window(GTK_WIDGET(c), FALSE);
-}
-
-// instead of having GtkContainer itself unref all our controls, we'll run our own uiControlDestroy() functions for child, which will do that and more
-// we still chain up because we need to, but by that point there will be no children for GtkContainer to free
-static void uiContainer_dispose(GObject *obj)
-{
- uiContainer *c = uiContainer(obj);
-
- if (c->children != NULL) {
- g_ptr_array_unref(c->children);
- c->children = NULL;
- }
- if (c->child != NULL) {
- uiControlDestroy(c->child);
- c->child = NULL;
- }
- G_OBJECT_CLASS(uiContainer_parent_class)->dispose(obj);
-}
-
-static void uiContainer_finalize(GObject *obj)
-{
- G_OBJECT_CLASS(uiContainer_parent_class)->finalize(obj);
- if (options.debugLogAllocations)
- fprintf(stderr, "%p free\n", obj);
-}
-
-static void uiContainer_add(GtkContainer *container, GtkWidget *widget)
-{
- uiContainer *c = uiContainer(container);
-
- gtk_widget_set_parent(widget, GTK_WIDGET(c));
- if (c->children != NULL)
- g_ptr_array_add(c->children, widget);
-}
-
-static void uiContainer_remove(GtkContainer *container, GtkWidget *widget)
-{
- uiContainer *c = uiContainer(container);
-
- gtk_widget_unparent(widget);
- if (c->children != NULL)
- g_ptr_array_remove(c->children, widget);
-}
-
-#define gtkXMargin 12
-#define gtkYMargin 12
-#define gtkXPadding 12
-#define gtkYPadding 6
-
-static void uiContainer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- uiContainer *c = uiContainer(widget);
- uiSizing d;
- intmax_t x, y, width, height;
-
- gtk_widget_set_allocation(GTK_WIDGET(c), allocation);
- if (c->child == NULL)
- return;
- x = allocation->x;
- y = allocation->y;
- width = allocation->width;
- height = allocation->height;
- if (c->margined) {
- x += gtkXMargin;
- y += gtkYMargin;
- width -= 2 * gtkXMargin;
- height -= 2 * gtkYMargin;
- }
- d.xPadding = gtkXPadding;
- d.yPadding = gtkYPadding;
- uiControlResize(c->child, x, y, width, height, &d);
-}
-
-struct forall {
- GtkCallback callback;
- gpointer data;
-};
-
-static void doforall(gpointer obj, gpointer data)
-{
- struct forall *s = (struct forall *) data;
-
- (*(s->callback))(GTK_WIDGET(obj), s->data);
-}
-
-static void uiContainer_forall(GtkContainer *container, gboolean includeInternals, GtkCallback callback, gpointer data)
-{
- uiContainer *c = uiContainer(container);
- struct forall s;
-
- s.callback = callback;
- s.data = data;
- if (c->children != NULL)
- g_ptr_array_foreach(c->children, doforall, &s);
-}
-
-static void uiContainer_class_init(uiContainerClass *class)
-{
- G_OBJECT_CLASS(class)->dispose = uiContainer_dispose;
- G_OBJECT_CLASS(class)->finalize = uiContainer_finalize;
- GTK_WIDGET_CLASS(class)->size_allocate = uiContainer_size_allocate;
- GTK_CONTAINER_CLASS(class)->add = uiContainer_add;
- GTK_CONTAINER_CLASS(class)->remove = uiContainer_remove;
- GTK_CONTAINER_CLASS(class)->forall = uiContainer_forall;
-}
-
-GtkWidget *newContainer(void)
-{
- GtkWidget *w;
-
- w = GTK_WIDGET(g_object_new(uiContainerType, NULL));
- // call gtk_widget_show_all() here to make the container visible
- gtk_widget_show_all(w);
- return w;
-}
-
-void updateParent(uintptr_t parent)
-{
- if (parent != 0)
- gtk_widget_queue_resize(GTK_WIDGET(parent));
-}