From: joakim@verona.se
To: emacs-devel@gnu.org
Subject: Re: embedding gtk widgets in a buffer
Date: Thu, 08 May 2008 02:21:13 +0200 [thread overview]
Message-ID: <m3zlr1fxxi.fsf@verona.se> (raw)
In-Reply-To: <m3ej8dhf6q.fsf@verona.se> (joakim@verona.se's message of "Thu, 08 May 2008 01:23:09 +0200")
[-- Attachment #1: Type: text/plain, Size: 123 bytes --]
joakim@verona.se writes:
Heres the actual patch. As I said previously, its early times yet, and
its not beautiful code.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: emacsembedgtk.diff --]
[-- Type: text/x-patch, Size: 24024 bytes --]
=== modified file 'src/Makefile.in'
--- src/Makefile.in 2008-03-04 20:29:10 +0000
+++ src/Makefile.in 2008-04-09 07:17:55 +0000
@@ -593,6 +593,7 @@
process.o callproc.o \
region-cache.o sound.o atimer.o \
doprnt.o strftime.o intervals.o textprop.o composite.o md5.o \
+ xwidget.o \
$(MSDOS_OBJ) $(MAC_OBJ) $(CYGWIN_OBJ) $(FONTOBJ)
/* Object files used on some machine or other.
@@ -1221,6 +1222,8 @@
sound.o: sound.c dispextern.h $(config_h)
atimer.o: atimer.c atimer.h systime.h $(config_h)
+xwidget.o: xwidget.c xwidget.h
+
/* The files of Lisp proper */
alloc.o: alloc.c process.h frame.h window.h buffer.h puresize.h syssignal.h keyboard.h \
=== modified file 'src/dispextern.h'
--- src/dispextern.h 2008-03-02 05:30:51 +0000
+++ src/dispextern.h 2008-05-07 21:38:08 +0000
@@ -26,7 +26,6 @@
#define DISPEXTERN_H_INCLUDED
#ifdef HAVE_X_WINDOWS
-
#include <X11/Xlib.h>
#ifdef USE_X_TOOLKIT
#include <X11/Intrinsic.h>
@@ -283,7 +282,10 @@
IMAGE_GLYPH,
/* Glyph is a space of fractional width and/or height. */
- STRETCH_GLYPH
+ STRETCH_GLYPH,
+
+ /* Glyph is an external widget drawn by the GUI toolkit. */
+ XWIDGET_GLYPH
};
@@ -333,7 +335,7 @@
/* Which kind of glyph this is---character, image etc. Value
should be an enumerator of type enum glyph_type. */
- unsigned type : 2;
+ unsigned type : 3;
/* 1 means this glyph was produced from multibyte text. Zero
means it was produced from unibyte text, i.e. charsets aren't
@@ -394,6 +396,8 @@
/* Image ID for image glyphs (type == IMAGE_GLYPH). */
unsigned img_id;
+ unsigned xwidget_id;
+
/* Sub-structure for type == STRETCH_GLYPH. */
struct
{
@@ -1229,6 +1233,8 @@
/* Image, if any. */
struct image *img;
+ int xwidget_id;
+
/* Slice */
struct glyph_slice slice;
@@ -1798,7 +1804,9 @@
IT_TRUNCATION,
/* Continuation glyphs. See the comment for IT_TRUNCATION. */
- IT_CONTINUATION
+ IT_CONTINUATION,
+
+ IT_XWIDGET
};
@@ -1841,6 +1849,7 @@
GET_FROM_C_STRING,
GET_FROM_IMAGE,
GET_FROM_STRETCH,
+ GET_FROM_XWIDGET,
NUM_IT_METHODS
};
@@ -1985,6 +1994,12 @@
struct {
Lisp_Object object;
} stretch;
+ /* method == GET_FROM_XWIDGET */
+ struct {
+ Lisp_Object object;
+ int xwidget_lalala;
+ } xwidget;
+
} u;
/* current text and display positions. */
@@ -2088,6 +2103,10 @@
/* If what == IT_IMAGE, the id of the image to display. */
int image_id;
+ /* If what == IT_XWIDGET*/
+ int xwidget_id;
+
+
/* Values from `slice' property. */
struct it_slice slice;
@@ -3110,3 +3129,4 @@
/* arch-tag: c65c475f-1c1e-4534-8795-990b8509fd65
(do not change this comment) */
+
=== modified file 'src/emacs.c'
--- src/emacs.c 2008-03-14 08:40:13 +0000
+++ src/emacs.c 2008-04-09 19:18:33 +0000
@@ -54,6 +54,8 @@
#include "buffer.h"
#include "window.h"
+#include "xwidget.h"
+
#include "systty.h"
#include "blockinput.h"
#include "syssignal.h"
@@ -1612,6 +1614,7 @@
syms_of_xterm ();
syms_of_xfns ();
syms_of_fontset ();
+ syms_of_xwidget();
#ifdef HAVE_X_SM
syms_of_xsmfns ();
#endif
=== modified file 'src/gtkutil.c'
--- src/gtkutil.c 2008-03-30 23:37:59 +0000
+++ src/gtkutil.c 2008-05-07 15:30:40 +0000
@@ -795,6 +795,10 @@
/* Create and set up the GTK widgets for frame F.
Return 0 if creation failed, non-zero otherwise. */
+GtkWidget *gwfixed;
+
+GtkWidget *getGwfixed(){return gwfixed;};
+
int
xg_create_frame_widgets (f)
FRAME_PTR f;
@@ -817,7 +821,7 @@
xg_set_screen (wtop, f);
wvbox = gtk_vbox_new (FALSE, 0);
- wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */
+ gwfixed = wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */
if (! wtop || ! wvbox || ! wfixed)
{
=== modified file 'src/xdisp.c'
--- src/xdisp.c 2008-04-02 03:27:06 +0000
+++ src/xdisp.c 2008-05-07 21:44:13 +0000
@@ -191,6 +191,7 @@
#include "region-cache.h"
#include "fontset.h"
#include "blockinput.h"
+#include "xwidget.h"
#ifdef HAVE_X_WINDOWS
#include "xterm.h"
@@ -939,6 +940,7 @@
static int next_element_from_buffer P_ ((struct it *));
static int next_element_from_composition P_ ((struct it *));
static int next_element_from_image P_ ((struct it *));
+static int next_element_from_xwidget P_ ((struct it *));
static int next_element_from_stretch P_ ((struct it *));
static void load_overlay_strings P_ ((struct it *, int));
static int init_from_display_pos P_ ((struct it *, struct window *,
@@ -3891,6 +3893,7 @@
if (CONSP (prop)
/* Simple properties. */
&& !EQ (XCAR (prop), Qimage)
+ && !EQ (XCAR (prop), Qxwidget)
&& !EQ (XCAR (prop), Qspace)
&& !EQ (XCAR (prop), Qwhen)
&& !EQ (XCAR (prop), Qslice)
@@ -4000,6 +4003,7 @@
Lisp_Object location, value;
struct text_pos start_pos, save_pos;
int valid_p;
+ printf("handle_single_display_spec:\n");
/* If SPEC is a list of the form `(when FORM . VALUE)', evaluate FORM.
If the result is non-nil, use VALUE instead of SPEC. */
@@ -4283,11 +4287,22 @@
LOCATION specifies where to display: `left-margin',
`right-margin' or nil. */
+
+ printf("handle_single_display_spec xwidgetp:%d imagep:%d spacep:%d display_replaced_before_p:%d stringp:%d\n",
+ XWIDGETP(value),
+ valid_image_p (value),
+ (CONSP (value) && EQ (XCAR (value), Qspace)),
+ display_replaced_before_p,
+ STRINGP (value));
+
valid_p = (STRINGP (value)
+
#ifdef HAVE_WINDOW_SYSTEM
|| (FRAME_WINDOW_P (it->f) && valid_image_p (value))
#endif /* not HAVE_WINDOW_SYSTEM */
- || (CONSP (value) && EQ (XCAR (value), Qspace)));
+ || (CONSP (value) && EQ (XCAR (value), Qspace))
+ || XWIDGETP(value)
+ );
if (valid_p && !display_replaced_before_p)
{
@@ -4333,8 +4348,20 @@
it->object = value;
*position = it->position = start_pos;
}
+ else if (XWIDGETP(value))
+ {
+ printf("handle_single_display_spec: im an xwidget!!\n");
+ it->what = IT_XWIDGET;
+ it->method = GET_FROM_XWIDGET;
+ it->position = start_pos;
+ it->object = NILP (object) ? it->w->buffer : object;
+ *position = start_pos;
+
+ it->xwidget_id=lookup_xwidget(value);
+
+ }
#ifdef HAVE_WINDOW_SYSTEM
- else
+ else //if nothing else, its an image
{
it->what = IT_IMAGE;
it->image_id = lookup_image (it->f, value);
@@ -4398,7 +4425,8 @@
return (CONSP (prop)
&& (EQ (XCAR (prop), Qimage)
- || EQ (XCAR (prop), Qspace)));
+ || EQ (XCAR (prop), Qspace)
+ || XWIDGETP(prop)));
}
@@ -5187,6 +5215,10 @@
case GET_FROM_STRETCH:
p->u.stretch.object = it->object;
break;
+ case GET_FROM_XWIDGET:
+ p->u.xwidget.object = it->object;
+ break;
+
}
p->position = it->position;
p->current = it->current;
@@ -5234,6 +5266,10 @@
it->object = p->u.image.object;
it->slice = p->u.image.slice;
break;
+ case GET_FROM_XWIDGET:
+ it->object = p->u.xwidget.object;
+ break;
+
case GET_FROM_COMPOSITION:
it->object = p->u.comp.object;
it->c = p->u.comp.c;
@@ -5701,7 +5737,8 @@
next_element_from_string,
next_element_from_c_string,
next_element_from_image,
- next_element_from_stretch
+ next_element_from_stretch,
+ next_element_from_xwidget
};
#define GET_NEXT_DISPLAY_ELEMENT(it) (*get_next_element[(it)->method]) (it)
@@ -6159,6 +6196,7 @@
case GET_FROM_IMAGE:
case GET_FROM_STRETCH:
+ case GET_FROM_XWIDGET:
/* The position etc with which we have to proceed are on
the stack. The position may be at the end of a string,
if the `display' property takes up the whole string. */
@@ -6410,6 +6448,17 @@
return 1;
}
+/* im not sure about this FIXME JAVE*/
+static int
+next_element_from_xwidget (it)
+ struct it *it;
+{
+ it->what = IT_XWIDGET;
+ printf("xwidget: in next_element_from_xwidget\n");
+ return 1;
+}
+
+
/* Fill iterator IT with next display element from a stretch glyph
property. IT->object is the value of the text property. Value is
@@ -15456,6 +15505,10 @@
glyph->left_box_line_p,
glyph->right_box_line_p);
}
+ else if (glyph->type == XWIDGET_GLYPH)
+ {
+ printf("dump xwidget glyph\n");
+ }
}
@@ -18944,6 +18997,13 @@
return OK_PIXELS (width_p ? img->width : img->height);
}
+
+ if (FRAME_WINDOW_P (it->f)
+ && valid_xwidget_p (prop))
+ {
+ printf("calc_pixel_width_or_height: return dummy size\n");
+ return OK_PIXELS (width_p ? 100 : 100);
+ }
#endif
if (EQ (car, Qplus) || EQ (car, Qminus))
{
@@ -19477,6 +19537,19 @@
s->ybase += s->first_glyph->voffset;
}
+static void
+fill_xwidget_glyph_string (s)
+ struct glyph_string *s;
+{
+ xassert (s->first_glyph->type == XWIDGET_GLYPH);
+ printf("fill_xwidget_glyph_string: width:%d \n",s->first_glyph->pixel_width);
+ s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
+ s->font = s->face->font;
+ s->width = s->first_glyph->pixel_width;
+ s->ybase += s->first_glyph->voffset;
+ s->xwidget_id=s->first_glyph->u.xwidget_id;
+}
+
/* Fill glyph string S from a sequence of stretch glyphs.
@@ -19835,6 +19908,20 @@
} \
while (0)
+#define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
+ do \
+ { \
+ printf("BUILD_XWIDGET_GLYPH_STRING\n"); \
+ s = (struct glyph_string *) alloca (sizeof *s); \
+ INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL); \
+ fill_xwidget_glyph_string (s); \
+ append_glyph_string (&HEAD, &TAIL, s); \
+ ++START; \
+ s->x = (X); \
+ } \
+ while (0)
+
+
/* Add a glyph string for a sequence of character glyphs to the list
of strings between HEAD and TAIL. START is the index of the first
@@ -19942,7 +20029,11 @@
BUILD_IMAGE_GLYPH_STRING (START, END, HEAD, TAIL, \
HL, X, LAST_X); \
break; \
- \
+ case XWIDGET_GLYPH: \
+ BUILD_XWIDGET_GLYPH_STRING (START, END, HEAD, TAIL, \
+ HL, X, LAST_X); \
+ break; \
+ \
default: \
abort (); \
} \
@@ -20440,6 +20531,113 @@
}
}
+static void
+produce_xwidget_glyph (it)
+ struct it *it;
+{
+ // struct image *img;
+ struct face *face;
+ int glyph_ascent, crop;
+ // struct glyph_slice slice;
+
+ printf("produce_xwidget_glyph:\n");
+ xassert (it->what == IT_XWIDGET);
+
+ face = FACE_FROM_ID (it->f, it->face_id);
+ xassert (face);
+ /* Make sure X resources of the face is loaded. */
+ PREPARE_FACE_FOR_DISPLAY (it->f, face);
+
+
+
+ /////////////////////////////////////////////
+
+ // img = IMAGE_FROM_ID (it->f, it->image_id);
+ //xassert (img);
+ /* Make sure X resources of the image is loaded. */
+ //prepare_image_for_display (it->f, img);
+
+
+
+
+ it->ascent = it->phys_ascent = glyph_ascent = 50;//image_ascent (img, face, &slice);
+ it->descent = 50;//slice.height - glyph_ascent;
+
+ //it->descent += img->vmargin;
+ //it->descent += img->vmargin;
+ it->phys_descent = it->descent;
+
+ it->pixel_width = 50;
+
+ //it->pixel_width += img->hmargin;
+ //it->pixel_width += img->hmargin;
+
+ /////////////////////////////////////////
+
+ /* It's quite possible for images to have an ascent greater than
+ their height, so don't get confused in that case. */
+ if (it->descent < 0)
+ it->descent = 0;
+
+ it->nglyphs = 1;
+
+ if (face->box != FACE_NO_BOX)
+ {
+ if (face->box_line_width > 0)
+ {
+ it->ascent += face->box_line_width;
+ it->descent += face->box_line_width;
+ }
+
+ if (it->start_of_box_run_p)
+ it->pixel_width += eabs (face->box_line_width);
+ it->pixel_width += eabs (face->box_line_width);
+ }
+
+ take_vertical_position_into_account (it);
+
+ /* Automatically crop wide image glyphs at right edge so we can
+ draw the cursor on same display row. */
+ if ((crop = it->pixel_width - (it->last_visible_x - it->current_x), crop > 0)
+ && (it->hpos == 0 || it->pixel_width > it->last_visible_x / 4))
+ {
+ it->pixel_width -= crop;
+ }
+
+ if (it->glyph_row)
+ {
+ struct glyph *glyph;
+ enum glyph_row_area area = it->area;
+
+ glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
+ if (glyph < it->glyph_row->glyphs[area + 1])
+ {
+ glyph->charpos = CHARPOS (it->position);
+ glyph->object = it->object;
+ glyph->pixel_width = it->pixel_width;
+ glyph->ascent = glyph_ascent;
+ glyph->descent = it->descent;
+ glyph->voffset = it->voffset;
+ // glyph->type = IMAGE_GLYPH;
+ glyph->type = XWIDGET_GLYPH;
+
+ glyph->multibyte_p = it->multibyte_p;
+ glyph->left_box_line_p = it->start_of_box_run_p;
+ glyph->right_box_line_p = it->end_of_box_run_p;
+ glyph->overlaps_vertically_p = 0;
+ glyph->padding_p = 0;
+ glyph->glyph_not_available_p = 0;
+ glyph->face_id = it->face_id;
+ glyph->u.xwidget_id = it->xwidget_id;
+ // glyph->slice = slice;
+ glyph->font_type = FONT_TYPE_UNKNOWN;
+ ++it->glyph_row->used[area];
+ }
+ else
+ IT_EXPAND_MATRIX_WIDTH (it, area);
+ }
+}
+
/* Append a stretch glyph to IT->glyph_row. OBJECT is the source
of the glyph, WIDTH and HEIGHT are the width and height of the
@@ -21462,6 +21660,8 @@
produce_image_glyph (it);
else if (it->what == IT_STRETCH)
produce_stretch_glyph (it);
+ else if (it->what == IT_XWIDGET)
+ produce_xwidget_glyph (it);
/* Accumulate dimensions. Note: can't assume that it->descent > 0
because this isn't true for images with `:ascent 100'. */
=== modified file 'src/xterm.c'
--- src/xterm.c 2008-03-29 07:46:06 +0000
+++ src/xterm.c 2008-05-06 15:20:29 +0000
@@ -73,6 +73,7 @@
#include "ccl.h"
#include "frame.h"
#include "dispextern.h"
+#include "xwidget.h"
#include "fontset.h"
#include "termhooks.h"
#include "termopts.h"
@@ -86,6 +87,7 @@
#include "process.h"
#include "atimer.h"
#include "keymap.h"
+//#include "xwidget.h"
#ifdef USE_X_TOOLKIT
#include <X11/Shell.h>
@@ -2850,6 +2852,7 @@
{
int relief_drawn_p = 0;
+ printf("x_draw_glyph_string: %d\n",s->first_glyph->type);
/* If S draws into the background of its successors, draw the
background of the successors first so that S can draw into it.
This makes S->next use XDrawString instead of XDrawImageString. */
@@ -2903,6 +2906,10 @@
x_draw_image_glyph_string (s);
break;
+ case XWIDGET_GLYPH:
+ x_draw_xwidget_glyph_string (s);
+ break;
+
case STRETCH_GLYPH:
x_draw_stretch_glyph_string (s);
break;
=== added file 'src/xwidget.c'
--- src/xwidget.c 1970-01-01 00:00:00 +0000
+++ src/xwidget.c 2008-05-07 23:02:17 +0000
@@ -0,0 +1,291 @@
+#include <config.h>
+
+/* On 4.3 these lose if they come after xterm.h. */
+/* Putting these at the beginning seems to be standard for other .c files. */
+#include <signal.h>
+
+#include <stdio.h>
+
+#ifdef HAVE_X_WINDOWS
+
+#include "lisp.h"
+#include "blockinput.h"
+
+/* Need syssignal.h for various externs and definitions that may be required
+ by some configurations for calls to signal later in this source file. */
+#include "syssignal.h"
+
+/* This may include sys/types.h, and that somehow loses
+ if this is not done before the other system files. */
+#include "xterm.h"
+#include <X11/cursorfont.h>
+
+/* Load sys/types.h if not already loaded.
+ In some systems loading it twice is suicidal. */
+#ifndef makedev
+#include <sys/types.h>
+#endif /* makedev */
+
+#ifdef BSD_SYSTEM
+#include <sys/ioctl.h>
+#endif /* ! defined (BSD_SYSTEM) */
+
+#include "systime.h"
+
+#ifndef INCLUDED_FCNTL
+#include <fcntl.h>
+#endif
+#include <ctype.h>
+#include <errno.h>
+#include <setjmp.h>
+#include <sys/stat.h>
+/* Caused redefinition of DBL_DIG on Netbsd; seems not to be needed. */
+/* #include <sys/param.h> */
+
+#include "charset.h"
+#include "character.h"
+#include "coding.h"
+#include "ccl.h"
+#include "frame.h"
+#include "dispextern.h"
+#include "xwidget.h"
+#include "fontset.h"
+#include "termhooks.h"
+#include "termopts.h"
+#include "termchar.h"
+#include "emacs-icon.h"
+#include "disptab.h"
+#include "buffer.h"
+#include "window.h"
+#include "keyboard.h"
+#include "intervals.h"
+#include "process.h"
+#include "atimer.h"
+#include "keymap.h"
+//#include "xwidget.h"
+
+#ifdef USE_X_TOOLKIT
+#include <X11/Shell.h>
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+
+#include "gtkutil.h"
+#include "font.h"
+#endif
+
+/*
+each xwidget instance is described by this struct.
+ */
+struct xwidget{
+ int type;
+ GtkWidget* widget;
+ GtkWindow* widgetwindow;
+ char* title;
+ int initialized;
+};
+
+//just a fixed array of xwidgets for now
+struct xwidget xwidgets[100];
+
+
+
+static int once=0;
+
+
+//GtkWidget *button;
+//GtkWindow *xxwindow ;
+//GtkFixed *fixed ;
+//GdkWindow *parent;
+
+Lisp_Object Qxwidget,
+ Qxwidget_id,
+ Qtitle;
+extern Lisp_Object QCdata, QCtype;
+
+/**/
+void x_draw_xwidget_glyph_string (s)
+ struct glyph_string *s;
+{
+/*
+ called from xterm.c:x_draw_glyph_string()
+ similar to x_draw_image_glyph_string
+ */
+ int box_line_hwidth = eabs (s->face->box_line_width);
+ int box_line_vwidth = max (s->face->box_line_width, 0);
+ int height = s->height;
+ Pixmap pixmap = None;
+
+ //just debug print interesting values for now
+ printf("x_draw_xwidget_glyph_string: id:%d %d %d (%d,%d,%d,%d)\n",s->xwidget_id, box_line_hwidth, box_line_vwidth, s->x,s->y,s->height,s->width);
+ Screen *screen = FRAME_X_SCREEN (s->f);
+ int depth = DefaultDepthOfScreen (screen); //FIXME
+ ///////////////////////////////////////////////////////
+ // stuff that affects x,y: menu, toolbar, scrollbar
+ int x=s->x;
+ int y=s->y;
+
+ if(!xwidgets[s->xwidget_id].initialized){
+ printf("once for xwidget %d\n",s->xwidget_id);
+ xwidgets[s->xwidget_id].initialized=1;
+
+ GtkWidget *widget;
+
+ switch(xwidgets[s->xwidget_id].type){
+ case 1:
+ printf("mk button\n");
+ widget=GTK_WIDGET(gtk_button_new_with_label ( xwidgets[s->xwidget_id].title));
+ break;
+ case 2:
+ printf("mk togglebutton\n");
+ widget=GTK_WIDGET(gtk_toggle_button_new_with_label ( xwidgets[s->xwidget_id].title));
+ break;
+ case 3:
+
+ widget=GTK_WIDGET(gtk_socket_new ());
+ printf("mk socket\n");
+ break;
+ }
+ xwidgets[s->xwidget_id].widget = widget;
+ //s->window Window window; is an xwindows XID
+ // parent=gdk_window_foreign_new (s->window);
+ // g_assert(parent);
+ xwidgets[s->xwidget_id].widgetwindow = GTK_WINDOW(gtk_window_new (GTK_WINDOW_TOPLEVEL)); //GTK_WINDOW_POPUP somehow works better than GTK_TOPLEVEL
+ gtk_widget_set_size_request ( xwidgets[s->xwidget_id].widget ,s->background_width,s->height);
+ gtk_fixed_put(GTK_FIXED(getGwfixed()),xwidgets[s->xwidget_id].widget ,x,y);
+ gtk_widget_show_all (xwidgets[s->xwidget_id].widget );
+ if(GTK_SOCKET(widget))
+ printf("socket id:%x %d\n", gtk_socket_get_id (GTK_SOCKET(widget)), gtk_socket_get_id (GTK_SOCKET(widget)));
+ }
+ gtk_fixed_move(GTK_FIXED(getGwfixed()),xwidgets[s->xwidget_id].widget ,x,y);
+}
+
+
+void
+syms_of_xwidget ()
+{
+ int i;
+ Qxwidget = intern ("xwidget");
+ staticpro (&Qxwidget);
+ Qxwidget_id = intern (":xwidget-id");
+ staticpro (&Qxwidget_id);
+ Qtitle = intern (":title");
+ staticpro (&Qtitle);
+
+ for(i=0;i<100;i++)
+ xwidgets[i].initialized=0;
+}
+
+
+/* Value is non-zero if OBJECT is a valid Lisp xwidget specification. A
+ valid xwidget specification is a list whose car is the symbol
+ `xwidget', and whose rest is a property list. The property list must
+ contain a value for key `:type'. That value must be the name of a
+ supported xwidget type. The rest of the property list depends on the
+ xwidget type. */
+
+int valid_xwidget_p (object) Lisp_Object object;
+{
+ int valid_p = 0;
+
+ if (XWIDGETP (object))
+ {
+ /* Lisp_Object tem; */
+
+ /* for (tem = XCDR (object); CONSP (tem); tem = XCDR (tem)) */
+ /* if (EQ (XCAR (tem), QCtype)) */
+ /* { */
+ /* tem = XCDR (tem); */
+ /* if (CONSP (tem) && SYMBOLP (XCAR (tem))) */
+ /* { */
+ /* struct xwidget_type *type; */
+ /* type = lookup_xwidget_type (XCAR (tem)); */
+ /* if (type) */
+ /* valid_p = type->valid_p (object); */
+ /* } */
+
+ /* break; */
+ /* } */
+ //never mind type support for now
+ valid_p = 1;
+ }
+
+ return valid_p;
+}
+
+//type support nevermind for now
+
+/* /\* List of supported image types. Use define_image_type to add new */
+/* types. Use lookup_image_type to find a type for a given symbol. *\/ */
+
+/* static struct wxidget_type *wxidget_types; */
+
+/* /\* Look up xwidget type SYMBOL, and return a pointer to its xwidget_type */
+/* structure. Value is null if SYMBOL is not a known image type. *\/ */
+
+/* static INLINE struct xwidget_type *lookup_xwidget_type (Lisp_Object symbol) */
+/* { */
+/* struct xwidget_type *type; */
+
+/* for (type = xwidget_types; type; type = type->next) */
+/* if (EQ (symbol, *type->type)) */
+/* break; */
+
+/* return type; */
+/* } */
+
+
+
+Lisp_Object
+xwidget_spec_value (spec, key, found)
+ Lisp_Object spec, key;
+ int *found;
+{
+ Lisp_Object tail;
+
+ xassert (valid_xwidget_p (spec));
+
+ for (tail = XCDR (spec);
+ CONSP (tail) && CONSP (XCDR (tail));
+ tail = XCDR (XCDR (tail)))
+ {
+ if (EQ (XCAR (tail), key))
+ {
+ if (found)
+ *found = 1;
+ return XCAR (XCDR (tail));
+ }
+ }
+
+ if (found)
+ *found = 0;
+ return Qnil;
+}
+
+
+
+int
+lookup_xwidget (spec)
+ Lisp_Object spec;
+{
+
+ int found=0,found1=0,found2=0;
+ Lisp_Object value;
+ value= xwidget_spec_value(spec, Qxwidget_id, &found1);
+ int id=INTEGERP (value) ? XFASTINT (value) : 0; //id 0 by default, but id must be unique so this is dumb
+
+ struct xwidget* xw=&xwidgets[id];
+ value=xwidget_spec_value(spec, QCtype,&found);
+ xw->type=INTEGERP (value) ? XFASTINT (value) : 1; //ok
+ value=xwidget_spec_value(spec, Qtitle, &found2);
+ xw->title=STRINGP(value)?SDATA(value):"?";
+ printf("xwidget_id:%d type:%d found:%d %d %d title:%s\n",id, xw->type, found,found1,found2, xw->title);
+
+ return id;
+}
=== added file 'src/xwidget.h'
--- src/xwidget.h 1970-01-01 00:00:00 +0000
+++ src/xwidget.h 2008-05-06 19:08:12 +0000
@@ -0,0 +1,27 @@
+void x_draw_xwidget_glyph_string P_ ((struct glyph_string *s));
+void syms_of_xwidget ();
+
+extern Lisp_Object Qxwidget;
+/* Test for xwidget (xwidget . spec) (car must be the symbol xwidget)*/
+#define XWIDGETP(x) (CONSP (x) && EQ (XCAR (x), Qxwidget))
+
+int valid_xwidget_p (Lisp_Object object) ;
+
+
+
+struct xwidget_type
+{
+ /* A symbol uniquely identifying the xwidget type, */
+ Lisp_Object *type;
+
+ /* Check that SPEC is a valid image specification for the given
+ image type. Value is non-zero if SPEC is valid. */
+ int (* valid_p) P_ ((Lisp_Object spec));
+
+ /* Next in list of all supported image types. */
+ struct xwidget_type *next;
+};
+
+
+static INLINE struct xwidget_type *lookup_xwidget_type (Lisp_Object symbol);
+
[-- Attachment #3: Type: text/plain, Size: 19 bytes --]
--
Joakim Verona
next prev parent reply other threads:[~2008-05-08 0:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-07 23:23 embedding gtk widgets in a buffer joakim
2008-05-08 0:21 ` joakim [this message]
2008-05-08 9:02 ` BVK
2008-05-08 22:28 ` Richard M Stallman
2008-05-08 23:13 ` joakim
2008-05-08 23:24 ` Lennart Borgman (gmail)
2008-05-10 8:55 ` Richard M Stallman
2008-05-10 11:55 ` joakim
2008-05-10 8:55 ` Richard M Stallman
2008-05-10 9:58 ` joakim
2008-05-10 10:22 ` Lennart Borgman (gmail)
2008-05-11 7:34 ` Richard M Stallman
2008-05-09 8:34 ` YAMAMOTO Mitsuharu
2008-05-10 21:07 ` joakim
2008-05-11 7:35 ` Richard M Stallman
2008-05-11 8:25 ` joakim
2008-05-11 12:32 ` David Kastrup
2008-05-11 12:48 ` joakim
2008-05-11 12:58 ` Lennart Borgman (gmail)
2008-05-12 4:38 ` tomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3zlr1fxxi.fsf@verona.se \
--to=joakim@verona.se \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).