Switched GTK+ uiGroup to the new child functions.

This commit is contained in:
Pietro Gagliardi 2015-08-28 16:43:41 -04:00
parent a6da02b3f7
commit 19c9b0f9da
2 changed files with 13 additions and 25 deletions

View File

@ -57,6 +57,7 @@ struct child *newChildWithBox(uiControl *child, uiControl *parent, GtkContainer
if (child == NULL) if (child == NULL)
return NULL; return NULL;
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show(box);
c = newChild(child, parent, GTK_CONTAINER(box)); c = newChild(child, parent, GTK_CONTAINER(box));
c->box = box; c->box = box;
gtk_container_add(parentContainer, c->box); gtk_container_add(parentContainer, c->box);

View File

@ -5,11 +5,11 @@ struct uiGroup {
uiUnixControl c; uiUnixControl c;
GtkWidget *widget; GtkWidget *widget;
GtkContainer *container; GtkContainer *container;
GtkBin *bin;
GtkFrame *frame; GtkFrame *frame;
// unfortunately, even though a GtkFrame is a GtkBin, calling gtk_container_set_border_width() on it /includes/ the GtkFrame's label; we don't want tht // unfortunately, even though a GtkFrame is a GtkBin, calling gtk_container_set_border_width() on it /includes/ the GtkFrame's label; we don't want tht
GtkWidget *box; struct child *child;
uiControl *child;
int margined; int margined;
}; };
@ -24,11 +24,8 @@ uiUnixDefineControlWithOnDestroy(
static void onDestroy(uiGroup *g) static void onDestroy(uiGroup *g)
{ {
if (g->child != NULL) { if (g->child != NULL)
uiControlSetParent(g->child, NULL); childDestroy(g->child);
uiControlDestroy(g->child);
}
gtk_widget_destroy(g->box);
} }
static void groupContainerUpdateState(uiControl *c) static void groupContainerUpdateState(uiControl *c)
@ -36,7 +33,7 @@ static void groupContainerUpdateState(uiControl *c)
uiGroup *g = uiGroup(c); uiGroup *g = uiGroup(c);
if (g->child != NULL) if (g->child != NULL)
controlUpdateState(g->child); childUpdateState(g->child);
} }
char *uiGroupTitle(uiGroup *g) char *uiGroupTitle(uiGroup *g)
@ -53,18 +50,11 @@ void uiGroupSetTitle(uiGroup *g, const char *text)
void uiGroupSetChild(uiGroup *g, uiControl *child) void uiGroupSetChild(uiGroup *g, uiControl *child)
{ {
if (g->child != NULL) { if (g->child != NULL)
gtk_container_remove(GTK_CONTAINER(g->box), childRemove(g->child);
GTK_WIDGET(uiControlHandle(g->child))); g->child = newChildWithBox(child, uiControl(g), g->container, g->margined);
uiControlSetParent(g->child, NULL); if (g->child != NULL)
} uiControlQueueResize(uiControl(g));
g->child = child;
if (g->child != NULL) {
uiControlSetParent(g->child, uiControl(g));
gtk_container_add(GTK_CONTAINER(g->box),
GTK_WIDGET(uiControlHandle(g->child)));
uiControlQueueResize(g->child);
}
} }
int uiGroupMargined(uiGroup *g) int uiGroupMargined(uiGroup *g)
@ -75,7 +65,7 @@ int uiGroupMargined(uiGroup *g)
void uiGroupSetMargined(uiGroup *g, int margined) void uiGroupSetMargined(uiGroup *g, int margined)
{ {
g->margined = margined; g->margined = margined;
setMargined(GTK_CONTAINER(g->box), g->margined); childSetMargined(g->child, g->margined);
uiControlQueueResize(uiControl(g)); uiControlQueueResize(uiControl(g));
} }
@ -91,6 +81,7 @@ uiGroup *uiNewGroup(const char *text)
g->widget = gtk_frame_new(text); g->widget = gtk_frame_new(text);
g->container = GTK_CONTAINER(g->widget); g->container = GTK_CONTAINER(g->widget);
g->bin = GTK_BIN(g->widget);
g->frame = GTK_FRAME(g->widget); g->frame = GTK_FRAME(g->widget);
// with GTK+, groupboxes by default have frames and slightly x-offset regular text // with GTK+, groupboxes by default have frames and slightly x-offset regular text
@ -108,10 +99,6 @@ uiGroup *uiNewGroup(const char *text)
gtk_label_set_attributes(label, boldlist); gtk_label_set_attributes(label, boldlist);
pango_attr_list_unref(boldlist); // thanks baedert in irc.gimp.net/#gtk+ pango_attr_list_unref(boldlist); // thanks baedert in irc.gimp.net/#gtk+
g->box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add(g->container, g->box);
gtk_widget_show(g->box);
uiUnixFinishNewControl(g, uiGroup); uiUnixFinishNewControl(g, uiGroup);
uiControl(g)->ContainerUpdateState = groupContainerUpdateState; uiControl(g)->ContainerUpdateState = groupContainerUpdateState;