hopefully fix that shit for good

This commit is contained in:
StapleButter 2017-10-05 01:58:41 +02:00
parent a84caacb03
commit d895dfc9fb

View File

@ -20,6 +20,8 @@ struct uiWindow {
uiControl *child;
int margined;
int width, height;
int (*onClosing)(uiWindow *, void *);
void *onClosingData;
void (*onContentSizeChanged)(uiWindow *, void *);
@ -127,6 +129,20 @@ static void uiWindowShow(uiControl *c)
// don't use gtk_widget_show(); that doesn't bring to front or give keyboard focus
// (gtk_window_present() does call gtk_widget_show() though)
gtk_window_present(w->window);
// set the size properly
int width = w->width;
int height = w->height;
if (w->menubar)
{
GtkRequisition min, nat;
int menuheight;
gtk_widget_get_preferred_size(w->menubar, &min, &nat);
menuheight = min.height;
if (nat.height > menuheight) menuheight = nat.height;
height += menuheight;
}
gtk_window_resize(w->window, width, height);
}
uiUnixControlDefaultHide(uiWindow)
@ -299,6 +315,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar,
w->menubar = makeMenubar(uiWindow(w));
gtk_container_add(w->vboxContainer, w->menubar);
}
else
w->menubar = NULL;
w->childHolderWidget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
w->childHolderContainer = GTK_CONTAINER(w->childHolderWidget);
@ -309,10 +327,6 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar,
gtk_box_set_homogeneous(GTK_BOX(w->childHolderWidget), TRUE);
gtk_container_add(w->vboxContainer, w->childHolderWidget);
// TODO: set client size properly
// menubar can consume height
// gtk_widget_set_size_request() is not good as it sets a minimum size
// show everything in the vbox, but not the GtkWindow itself
gtk_widget_show_all(w->vboxWidget);
@ -335,5 +349,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar,
gtk_window_set_resizable(w->window, resizable?TRUE:FALSE);
w->width = width;
w->height = height;
return w;
}