From 3134440f3d10893fc715a555e5bd89eb8b12c9b1 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 8 Apr 2015 16:24:11 -0400 Subject: [PATCH] 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. --- button_unix.c | 2 +- newcontrol_unix.c | 5 ++--- ui_unix.h | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/button_unix.c b/button_unix.c index 8ab9aa68..a39bdf52 100644 --- a/button_unix.c +++ b/button_unix.c @@ -34,7 +34,7 @@ uiControl *uiNewButton(const char *text) b = uiNew(struct button); b->c = uiUnixNewControl(GTK_TYPE_BUTTON, - FALSE, FALSE, FALSE, b, + FALSE, FALSE, b, "label", text, NULL); diff --git a/newcontrol_unix.c b/newcontrol_unix.c index b424aa65..e032f8b4 100644 --- a/newcontrol_unix.c +++ b/newcontrol_unix.c @@ -60,7 +60,7 @@ static void onDestroy(GtkWidget *widget, gpointer data) 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; va_list ap; @@ -73,10 +73,9 @@ uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean need c->immediate = c->widget; // 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) { 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); else gtk_container_add(GTK_CONTAINER(c->scrolledWindow), c->widget); diff --git a/ui_unix.h b/ui_unix.h index 06b6ed89..4e4f6e8d 100644 --- a/ui_unix.h +++ b/ui_unix.h @@ -9,10 +9,10 @@ This file assumes that you have included and "ui.h" beforehand. It p // 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 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 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); #endif