Fixed issues in the GTK+ uiParent change.

This commit is contained in:
Pietro Gagliardi 2015-04-13 12:12:00 -04:00
parent 19b85182b8
commit e4147f14af
3 changed files with 12 additions and 12 deletions

View File

@ -33,7 +33,7 @@ static void singleSetParent(uiControl *c, uiParent *parent)
singleWidget *s = (singleWidget *) (c->internal); singleWidget *s = (singleWidget *) (c->internal);
s->parent = parent; s->parent = parent;
gtk_container_add(GTK_CONTAINER(s->parent), s->immediate); gtk_container_add(GTK_CONTAINER(uiParentHandle(s->parent)), s->immediate);
uiParentUpdate(s->parent); uiParentUpdate(s->parent);
} }

View File

@ -34,7 +34,7 @@ static void uipParent_init(uipParent *p)
if (options.debugLogAllocations) if (options.debugLogAllocations)
fprintf(stderr, "%p alloc uipParent\n", p); fprintf(stderr, "%p alloc uipParent\n", p);
p->children = g_ptr_array_new(); p->children = g_ptr_array_new();
gtk_widget_set_has_window(GTK_WIDGET(c), FALSE); gtk_widget_set_has_window(GTK_WIDGET(p), 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 // instead of having GtkContainer itself unref all our controls, we'll run our own uiControlDestroy() functions for child, which will do that and more
@ -44,11 +44,11 @@ static void uipParent_dispose(GObject *obj)
uipParent *p = uipParent(obj); uipParent *p = uipParent(obj);
if (p->children != NULL) { if (p->children != NULL) {
g_ptr_array_unref(c->children); g_ptr_array_unref(p->children);
p->children = NULL; p->children = NULL;
} }
if (p->child != NULL) { if (p->child != NULL) {
uiControlDestroy(c->child); uiControlDestroy(p->child);
p->child = NULL; p->child = NULL;
} }
G_OBJECT_CLASS(uipParent_parent_class)->dispose(obj); G_OBJECT_CLASS(uipParent_parent_class)->dispose(obj);
@ -65,7 +65,7 @@ static void uipParent_add(GtkContainer *container, GtkWidget *widget)
{ {
uipParent *p = uipParent(container); uipParent *p = uipParent(container);
gtk_widget_set_parent(widget, GTK_WIDGET(c)); gtk_widget_set_parent(widget, GTK_WIDGET(p));
if (p->children != NULL) if (p->children != NULL)
g_ptr_array_add(p->children, widget); g_ptr_array_add(p->children, widget);
} }
@ -88,8 +88,8 @@ static void uipParent_size_allocate(GtkWidget *widget, GtkAllocation *allocation
uiSizing d; uiSizing d;
intmax_t x, y, width, height; intmax_t x, y, width, height;
gtk_widget_set_allocation(GTK_WIDGET(c), allocation); gtk_widget_set_allocation(GTK_WIDGET(p), allocation);
if (c->child == NULL) if (p->child == NULL)
return; return;
x = allocation->x + p->marginLeft; x = allocation->x + p->marginLeft;
y = allocation->y + p->marginTop; y = allocation->y + p->marginTop;
@ -97,7 +97,7 @@ static void uipParent_size_allocate(GtkWidget *widget, GtkAllocation *allocation
height = allocation->height - (p->marginTop + p->marginBottom); height = allocation->height - (p->marginTop + p->marginBottom);
d.xPadding = gtkXPadding; d.xPadding = gtkXPadding;
d.yPadding = gtkYPadding; d.yPadding = gtkYPadding;
uiControlResize(c->child, x, y, width, height, &d); uiControlResize(p->child, x, y, width, height, &d);
} }
struct forall { struct forall {
@ -120,7 +120,7 @@ static void uipParent_forall(GtkContainer *container, gboolean includeInternals,
s.callback = callback; s.callback = callback;
s.data = data; s.data = data;
if (p->children != NULL) if (p->children != NULL)
g_ptr_array_foreach(c->children, doforall, &s); g_ptr_array_foreach(p->children, doforall, &s);
} }
static void uipParent_class_init(uipParentClass *class) static void uipParent_class_init(uipParentClass *class)
@ -163,7 +163,7 @@ static void parentUpdate(uiParent *p)
{ {
uipParent *pp = uipParent(p->Internal); uipParent *pp = uipParent(p->Internal);
gtk_queue_resize(GTK_WIDGET(pp)); gtk_widget_queue_resize(GTK_WIDGET(pp));
} }
uiParent *uiNewParent(uintptr_t osParent) uiParent *uiNewParent(uintptr_t osParent)
@ -178,6 +178,6 @@ uiParent *uiNewParent(uintptr_t osParent)
p->Update = parentUpdate; p->Update = parentUpdate;
gtk_container_add(GTK_CONTAINER(osParent), GTK_WIDGET(p->Internal)); gtk_container_add(GTK_CONTAINER(osParent), GTK_WIDGET(p->Internal));
// and make it visible by default // and make it visible by default
gtk_widget_show_all(GTK_WIDGET(p->internal)); gtk_widget_show_all(GTK_WIDGET(p->Internal));
return p; return p;
} }

View File

@ -51,7 +51,7 @@ void uiTabAddPage(uiControl *c, const char *name, uiControl *child)
content = uiNewParent((uintptr_t) notebook); content = uiNewParent((uintptr_t) notebook);
uiParentSetChild(content, child); uiParentSetChild(content, child);
uiParentUpdate(content); uiParentUpdate(content);
gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), container, name); gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook), GTK_WIDGET(uiParentHandle(content)), name);
t->pages[t->len] = content; t->pages[t->len] = content;
t->len++; t->len++;