Moved GTK+ uiWindow to the new child system and fixed a latent bug in uiGroup. Now it's just uiBox and the GTK+ port will be migrated!
This commit is contained in:
parent
77b53b5278
commit
ef0f36a8ec
|
@ -65,7 +65,8 @@ int uiGroupMargined(uiGroup *g)
|
||||||
void uiGroupSetMargined(uiGroup *g, int margined)
|
void uiGroupSetMargined(uiGroup *g, int margined)
|
||||||
{
|
{
|
||||||
g->margined = margined;
|
g->margined = margined;
|
||||||
childSetMargined(g->child, g->margined);
|
if (g->child != NULL)
|
||||||
|
childSetMargined(g->child, g->margined);
|
||||||
uiControlQueueResize(uiControl(g));
|
uiControlQueueResize(uiControl(g));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ struct uiWindow {
|
||||||
|
|
||||||
GtkWidget *menubar;
|
GtkWidget *menubar;
|
||||||
|
|
||||||
uiControl *child;
|
struct child *child;
|
||||||
GtkWidget *childbox;
|
|
||||||
int margined;
|
int margined;
|
||||||
|
|
||||||
int (*onClosing)(uiWindow *, void *);
|
int (*onClosing)(uiWindow *, void *);
|
||||||
|
@ -51,10 +50,8 @@ static void onDestroy(uiWindow *w)
|
||||||
// first hide ourselves
|
// first hide ourselves
|
||||||
gtk_widget_hide(w->widget);
|
gtk_widget_hide(w->widget);
|
||||||
// now destroy the child
|
// now destroy the child
|
||||||
if (w->child != NULL) {
|
if (w->child != NULL)
|
||||||
uiControlSetParent(w->child, NULL);
|
childDestroy(w->child);
|
||||||
uiControlDestroy(w->child);
|
|
||||||
}
|
|
||||||
// now destroy the menus, if any
|
// now destroy the menus, if any
|
||||||
if (w->menubar != NULL)
|
if (w->menubar != NULL)
|
||||||
freeMenubar(w->menubar);
|
freeMenubar(w->menubar);
|
||||||
|
@ -76,7 +73,7 @@ static void windowContainerUpdateState(uiControl *c)
|
||||||
uiWindow *w = uiWindow(c);
|
uiWindow *w = uiWindow(c);
|
||||||
|
|
||||||
if (w->child != NULL)
|
if (w->child != NULL)
|
||||||
controlUpdateState(w->child);
|
childUpdateState(w->child);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *uiWindowTitle(uiWindow *w)
|
char *uiWindowTitle(uiWindow *w)
|
||||||
|
@ -98,16 +95,14 @@ void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *, void *), void *data)
|
||||||
|
|
||||||
void uiWindowSetChild(uiWindow *w, uiControl *child)
|
void uiWindowSetChild(uiWindow *w, uiControl *child)
|
||||||
{
|
{
|
||||||
|
if (w->child != NULL)
|
||||||
|
childDestroy(w->child);
|
||||||
|
w->child = newChildWithBox(child, uiControl(w), w->vboxContainer, w->margined);
|
||||||
if (w->child != NULL) {
|
if (w->child != NULL) {
|
||||||
gtk_container_remove(GTK_CONTAINER(w->childbox),
|
gtk_widget_set_hexpand(childBox(w->child), TRUE);
|
||||||
GTK_WIDGET(uiControlHandle(w->child)));
|
gtk_widget_set_halign(childBox(w->child), GTK_ALIGN_FILL);
|
||||||
uiControlSetParent(w->child, NULL);
|
gtk_widget_set_vexpand(childBox(w->child), TRUE);
|
||||||
}
|
gtk_widget_set_valign(childBox(w->child), GTK_ALIGN_FILL);
|
||||||
w->child = child;
|
|
||||||
if (w->child != NULL) {
|
|
||||||
uiControlSetParent(w->child, uiControl(w));
|
|
||||||
gtk_container_add(GTK_CONTAINER(w->childbox),
|
|
||||||
GTK_WIDGET(uiControlHandle(w->child)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +114,8 @@ int uiWindowMargined(uiWindow *w)
|
||||||
void uiWindowSetMargined(uiWindow *w, int margined)
|
void uiWindowSetMargined(uiWindow *w, int margined)
|
||||||
{
|
{
|
||||||
w->margined = margined;
|
w->margined = margined;
|
||||||
setMargined(GTK_CONTAINER(w->childbox), w->margined);
|
if (w->child != NULL)
|
||||||
|
childSetMargined(w->child, w->margined);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
|
@ -147,14 +143,6 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
gtk_container_add(w->vboxContainer, w->menubar);
|
gtk_container_add(w->vboxContainer, w->menubar);
|
||||||
}
|
}
|
||||||
|
|
||||||
w->childbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
|
|
||||||
gtk_widget_set_hexpand(w->childbox, TRUE);
|
|
||||||
gtk_widget_set_halign(w->childbox, GTK_ALIGN_FILL);
|
|
||||||
gtk_widget_set_vexpand(w->childbox, TRUE);
|
|
||||||
gtk_widget_set_valign(w->childbox, GTK_ALIGN_FILL);
|
|
||||||
gtk_container_add(w->vboxContainer, w->childbox);
|
|
||||||
gtk_widget_show(w->childbox);
|
|
||||||
|
|
||||||
// show everything in the vbox, but not the GtkWindow itself
|
// show everything in the vbox, but not the GtkWindow itself
|
||||||
gtk_widget_show_all(w->vboxWidget);
|
gtk_widget_show_all(w->vboxWidget);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue