Removed the need for specifying if a GTK+ widget needs to be in a GtkViewport for it to be scrollable; the new control code finds out itself now in the same way newer versions of GTK+ do.
This commit is contained in:
parent
7b6a11d36a
commit
3134440f3d
|
@ -34,7 +34,7 @@ uiControl *uiNewButton(const char *text)
|
||||||
b = uiNew(struct button);
|
b = uiNew(struct button);
|
||||||
|
|
||||||
b->c = uiUnixNewControl(GTK_TYPE_BUTTON,
|
b->c = uiUnixNewControl(GTK_TYPE_BUTTON,
|
||||||
FALSE, FALSE, FALSE, b,
|
FALSE, FALSE, b,
|
||||||
"label", text,
|
"label", text,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ static void onDestroy(GtkWidget *widget, gpointer data)
|
||||||
uiFree(c);
|
uiFree(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean needsViewport, gboolean scrolledWindowHasBorder, void *data, const char *firstProperty, ...)
|
uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, void *data, const char *firstProperty, ...)
|
||||||
{
|
{
|
||||||
uiSingleWidgetControl *c;
|
uiSingleWidgetControl *c;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -73,10 +73,9 @@ uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean need
|
||||||
c->immediate = c->widget;
|
c->immediate = c->widget;
|
||||||
|
|
||||||
// TODO turn into bit field?
|
// TODO turn into bit field?
|
||||||
// TODO should we check to see if the GType implements GtkScrollable instead of having this passed as a parameter?
|
|
||||||
if (inScrolledWindow) {
|
if (inScrolledWindow) {
|
||||||
c->scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
|
c->scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
|
||||||
if (needsViewport)
|
if (!GTK_IS_SCROLLABLE(c->widget))
|
||||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(c->scrolledWindow), c->widget);
|
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(c->scrolledWindow), c->widget);
|
||||||
else
|
else
|
||||||
gtk_container_add(GTK_CONTAINER(c->scrolledWindow), c->widget);
|
gtk_container_add(GTK_CONTAINER(c->scrolledWindow), c->widget);
|
||||||
|
|
|
@ -9,10 +9,10 @@ This file assumes that you have included <gtk/gtk.h> and "ui.h" beforehand. It p
|
||||||
|
|
||||||
// uiUnixNewControl() creates a new uiControl with the given GTK+ control inside.
|
// uiUnixNewControl() creates a new uiControl with the given GTK+ control inside.
|
||||||
// The first parameter is the type of the control, as passed to the first argument of g_object_new().
|
// The first parameter is the type of the control, as passed to the first argument of g_object_new().
|
||||||
// The three scrolledWindow parameters allow placing scrollbars on the new control.
|
// The two scrolledWindow parameters allow placing scrollbars on the new control.
|
||||||
// The data parameter can be accessed with uiUnixControlData().
|
// The data parameter can be accessed with uiUnixControlData().
|
||||||
// The firstProperty parameter and beyond allow passing construct properties to the new control, as with g_object_new(); end this list with NULL.
|
// The firstProperty parameter and beyond allow passing construct properties to the new control, as with g_object_new(); end this list with NULL.
|
||||||
extern uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean needsViewport, gboolean scrolledWindowHasBorder, void *data, const char *firstProperty, ...);
|
extern uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, void *data, const char *firstProperty, ...);
|
||||||
extern void *uiUnixControlData(uiControl *c);
|
extern void *uiUnixControlData(uiControl *c);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue