From 098e59dc13e2c57c766732bbdef6dfb817b932b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Jadi?= Date: Fri, 28 Jun 2013 17:16:27 +0200 Subject: [PATCH] * src/xwidget.h (xwidget_view): Convert member `model' to Lisp_Object. (XXWIDGET_VIEW_P, XXWIDGET_VIEW): Add standard macros to manipulate xwidget_view. * src/xwidget.c: Fix access to model in xwidget_view (now a Lisp_Object). --- src/xwidget.c | 14 +++++++------- src/xwidget.h | 8 ++++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/xwidget.c b/src/xwidget.c index 57d27a2b3c7..2f5e423ce42 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -444,7 +444,7 @@ xwidget_slider_changed (GtkRange *range, for (int i = 0; i < MAX_XWIDGETS; i++) { xv = &xwidget_views[i]; - if(xv->initialized && xvp->model == xv->model){ + if(xv->initialized && EQ (xvp->model, xv->model)){ g_signal_handler_block( xv->widget,xv->handler_id); } } @@ -452,7 +452,7 @@ xwidget_slider_changed (GtkRange *range, for (int i = 0; i < MAX_XWIDGETS; i++) { xv = &xwidget_views[i]; - if(xv->initialized && xvp->model == xv->model){ + if(xv->initialized && EQ (xvp->model, xv->model)){ gtk_range_set_value(GTK_RANGE(xv->widget), v); g_signal_handler_unblock( xv->widget,xv->handler_id); } @@ -474,7 +474,7 @@ xwidget_osr_damage_event_callback (GtkWidget *widget, GdkEventExpose *event, gpo for (int i = 0; i < MAX_XWIDGETS; i++)//todo mvc refactor { xv = &xwidget_views[i]; - if(xv->initialized && xv->model == xw){ + if(xv->initialized && XXWIDGET (xv->model) == xw){ gtk_widget_queue_draw (xv->widget); //redraw all views, the master has changed } } @@ -958,7 +958,7 @@ xwidget_osr_event_set_embedder (GtkWidget *widget, GdkEvent *event, gpointer xv) { - xwidget_set_embedder_view(((struct xwidget_view*) xv)->model, + xwidget_set_embedder_view(XXWIDGET (((struct xwidget_view*) xv)->model), (struct xwidget_view*) xv); } @@ -986,7 +986,7 @@ xwidget_init_view (struct xwidget *xww, xv->initialized = 1; xv->w = s->w; - xv->model = xww; + XSETXWIDGET(xv->model, xww); //widget creation if(EQ(xww->type, Qbutton)) @@ -1380,7 +1380,7 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0, doc: for (int i = 0; i < MAX_XWIDGETS; i++) //TODO MVC refactor lazy linear search { xv = &xwidget_views[i]; - if(xv->initialized && xv->model == xw){ + if(xv->initialized && XXWIDGET (xv->model) == xw){ gtk_layout_set_size (GTK_LAYOUT (xv->widgetwindow), xw->width, xw->height); gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xw->width, xw->height); } @@ -1718,7 +1718,7 @@ xwidget_view_lookup (struct xwidget* xw, struct window *w) struct xwidget_view* xv = NULL; for (int i = 0; i < MAX_XWIDGETS; i++){ xv = &xwidget_views[i]; - if (xv->initialized && (xv->model == xw) && (xv->w == w)) + if (xv->initialized && (XXWIDGET (xv->model) == xw) && (xv->w == w)) return xv; } return NULL; /* we didnt find a matching view */ diff --git a/src/xwidget.h b/src/xwidget.h index 530b087796c..eb5bc60c788 100644 --- a/src/xwidget.h +++ b/src/xwidget.h @@ -43,9 +43,9 @@ struct xwidget{ //struct for each xwidget view -struct xwidget_view{ +struct xwidget_view { struct vectorlike_header header; - struct xwidget* model; //TODO should be lisp + Lisp_Object model; //here ends the lisp part. @@ -72,10 +72,14 @@ struct xwidget_view{ /* Test for xwidget (xwidget . spec) (car must be the symbol xwidget)*/ #define XWIDGETP(x) (CONSP (x) && EQ (XCAR (x), Qxwidget)) + /* Test for xwidget pseudovector*/ #define XXWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET) #define XXWIDGET(a) (eassert (XXWIDGETP(a)),(struct xwidget *) XPNTR(a)) +/* Test for xwidget_view pseudovector */ +#define XXWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW) +#define XXWIDGET_VIEW(a) (eassert (XXWIDGET_VIEW_P(a)),(struct xwidget_view *) XPNTR(a)) struct xwidget_type { -- 2.39.2