Add new type: gtk-widget. It represents pointer to GtkWidget.

This commit is contained in:
Sergey Cherepanov 2012-11-25 20:26:25 +11:00 committed by Lassi Kortela
parent 79bfa12850
commit 4b150c5f7c
2 changed files with 46 additions and 1 deletions

View File

@ -32,8 +32,20 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "config.h" #include "config.h"
extern int T_GtkWidget;
#define GTKWIDGET(x) ((struct S_GtkWidget *)POINTER(x))
struct S_GtkWidget {
Object tag;
GtkWidget *widget;
};
C_LINKAGE_BEGIN C_LINKAGE_BEGIN
extern GtkWidget *Get_GtkWidget (Object w);
extern Object Make_GtkWidget (GtkWidget *w);
extern void elk_init_gtk_gtkmain (void); extern void elk_init_gtk_gtkmain (void);
extern void elk_init_gtk_gtkwidget (void); extern void elk_init_gtk_gtkwidget (void);

View File

@ -30,5 +30,38 @@
#include "gtk.h" #include "gtk.h"
void elk_init_gtk_gtkwidget () { int T_GtkWidget;
GtkWidget *Get_GtkWidget (Object w) {
Check_Type (w, T_GtkWidget);
return GTKWIDGET(w)->widget;
}
Object Make_GtkWidget (GtkWidget *w) {
Object yield;
yield = Alloc_Object (sizeof (struct S_GtkWidget), T_GtkWidget, 0);
GTKWIDGET(yield)->widget = w;
return yield;
}
static int GtkWidget_Equal (Object x, Object y) {
return GTKWIDGET(x)->widget == GTKWIDGET(y)->widget;
}
static int GtkWidget_Print (Object x, Object port, int raw, int depth,
int len) {
Printf (port, "#[gtk-widget %lu]", (unsigned long)GTKWIDGET(x)->widget);
return 0;
}
static Object GtkWidgetp (Object x) {
return TYPE(x) == T_GtkWidget ? True : False;
}
void elk_init_gtk_gtkwidget () {
T_GtkWidget = Define_Type (0, "gtk-widget", NOFUNC,
sizeof (struct S_GtkWidget), GtkWidget_Equal, GtkWidget_Equal,
GtkWidget_Print, NOFUNC);
Define_Primitive (GtkWidgetp, "gtk-widget?", 1, 1, EVAL);
} }