summaryrefslogtreecommitdiff
path: root/new
diff options
context:
space:
mode:
Diffstat (limited to 'new')
-rw-r--r--new/button_unix.c10
-rw-r--r--new/newcontrol_unix.c8
-rw-r--r--new/ui_unix.h5
3 files changed, 12 insertions, 11 deletions
diff --git a/new/button_unix.c b/new/button_unix.c
index 9c6fa2b..986e81d 100644
--- a/new/button_unix.c
+++ b/new/button_unix.c
@@ -23,18 +23,14 @@ static void defaultOnClicked(uiControl *c, void *data)
uiControl *uiNewButton(const char *text)
{
struct button *b;
- GParameter props[1];
GtkWidget *widget;
b = uiNew(struct button);
- props[0].name = "label";
- g_value_init(&(props[0].value), G_TYPE_STRING);
- g_value_set_string(&(props[0].value), text);
b->c = uiUnixNewControl(GTK_TYPE_BUTTON,
- 1, props,
- FALSE, FALSE, FALSE, b);
- g_value_unset(&(props[0].value)); // thanks to gregier in irc.gimp.net/#gtk+
+ FALSE, FALSE, FALSE, b,
+ "label", text,
+ NULL);
widget = GTK_WIDGET(uiControlHandle(b->c));
g_signal_connect(widget, "clicked", G_CALLBACK(onClicked), b);
diff --git a/new/newcontrol_unix.c b/new/newcontrol_unix.c
index 3123685..87aa105 100644
--- a/new/newcontrol_unix.c
+++ b/new/newcontrol_unix.c
@@ -60,12 +60,16 @@ static void singleContainerHide(uiControl *c)
// TODO connect free function
-uiControl *uiUnixNewControl(GType type, guint nConstructParams, GParameter *constructParams, gboolean inScrolledWindow, gboolean needsViewport, gboolean scrolledWindowHasBorder, void *data)
+uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean needsViewport, gboolean scrolledWindowHasBorder, void *data, const char *firstProperty, ...)
{
uiSingleWidgetControl *c;
+ va_list ap;
c = uiNew(uiSingleWidgetControl);
- c->widget = GTK_WIDGET(g_object_newv(type, nConstructParams, constructParams));
+
+ va_start(ap, firstProperty);
+ c->widget = GTK_WIDGET(g_object_new_valist(type, firstProperty, ap));
+ va_end(ap);
c->immediate = c->widget;
// TODO turn into bit field?
diff --git a/new/ui_unix.h b/new/ui_unix.h
index 19e8180..06b6ed8 100644
--- a/new/ui_unix.h
+++ b/new/ui_unix.h
@@ -8,10 +8,11 @@ This file assumes that you have included <gtk/gtk.h> and "ui.h" beforehand. It p
#define __UI_UI_UNIX_H__
// uiUnixNewControl() creates a new uiControl with the given GTK+ control inside.
-// The first three parameters are used for creating the control itself and are the same as passed to g_object_newv().
+// 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 data parameter can be accessed with uiUnixControlData().
-extern uiControl *uiUnixNewControl(GType type, guint nConstructParams, GParameter *constructParams, gboolean inScrolledWindow, gboolean needsViewport, gboolean scrolledWindowHasBorder, void *data);
+// 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 void *uiUnixControlData(uiControl *c);
#endif