aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.xwidget69
-rw-r--r--lisp/xwidget-test.el5
-rw-r--r--src/xterm.c4
-rw-r--r--src/xwidget.c73
4 files changed, 137 insertions, 14 deletions
diff --git a/README.xwidget b/README.xwidget
index 77b98d5fd83..65e5598f7f2 100644
--- a/README.xwidget
+++ b/README.xwidget
@@ -169,7 +169,12 @@ it is, except symbols is used instead of integers.
169 169
170 170
171*** TODO better lisp based structure for xwidgets 171*** TODO better lisp based structure for xwidgets
172something like this: 172the lisp interface woud be like this:
173- xwidget-create returns an xwidget object, similar to a process
174 object. this id is used when creating the display spec(instead of
175 the user defined id now used)
176
177the data structure would be something like this:
173- a "process" like aproach to create the xwidgets. xwidgets are 178- a "process" like aproach to create the xwidgets. xwidgets are
174 coupled to buffers, somewhat like processes, except a buffer can 179 coupled to buffers, somewhat like processes, except a buffer can
175 hold several xwidgets 180 hold several xwidgets
@@ -183,7 +188,11 @@ there are some things that arent clear:
183 be better to store them window locally rather than in an assoc 188 be better to store them window locally rather than in an assoc
184 coupled to the xwidget model 189 coupled to the xwidget model
185 190
186 191stuff that needs to work:
192- do something for all views of a xwidget(resize, value change)
193- do something for all xw-views in an emacs window(deletion etc)
194- lookup xw-view for xwidget in emacs window(during redisplay)
195(- do something for all siblings of a xw-view. not atm)
187 196
188** TODO more documentation 197** TODO more documentation
189There should be user docs, and xwidget contributor docs. The current README 198There should be user docs, and xwidget contributor docs. The current README
@@ -228,5 +237,59 @@ Surprisingly, this just worked!
228I used gtk signals, the implementation for sliders works well! 237I used gtk signals, the implementation for sliders works well!
229 238
230** TODO canvas support 239** TODO canvas support
231goocanvas is a gtk canvas implemented with cairo. investigate. 240*** goocanvas
241goocanvas is a gtk canvas implemented using cairo. investigate.
232http://developer.gnome.org/goocanvas/unstable/goocanvas-model-view-canvas.html 242http://developer.gnome.org/goocanvas/unstable/goocanvas-model-view-canvas.html
243it has a MVC model aproach out of the box which is nice.
244
245
246export CFLAGS="`pkg-config --cflags goocanvas` -DHAVE_GOOCANVAS"
247export LDFLAGS=`pkg-config --libs goocanvas`
248./configure
249make
250
251I made a hello goo world xwidget so seems doable.
252I wanted to load a SVG which wasnt straightforward.
253*** clutter
254maybe clutter can be used as a canvas? seems to have a lot of traction atm.
255http://www.openismus.com/documents/clutter_tutorial/0.9/docs/tutorial/html/sec-stage-widget.html
256
257there is also cool stuff like this:
258http://gitorious.org/webkit-clutter/webkit-clutter which is an webkit actor for
259clutter! hmmmmm.
260
261I want to render svg. aparently:
262 librsvg rsvg_handle_render_cairo(h, cr);
263 ClutterCairoTexture
264 Clutter
265
266export CFLAGS="`pkg-config --cflags clutter-gtk-1.0` -DHAVE_CLUTTER"
267export LDFLAGS=`pkg-config --libs clutter-gtk-1.0`
268./configure
269make
270
271compiles but I get:
272Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in
273the same process is not supported
274
275export CFLAGS="`pkg-config --cflags clutter-gtk-0.10` -DHAVE_CLUTTER"
276export LDFLAGS=`pkg-config --libs clutter-gtk-0.10`
277./configure
278make
279
280
281** TODO mvc code crashes after a while
282seemingly only when compiling with optimizations
283
284** TODO delete xwidgets belonging to an emacs window
285when it closes
286** TODO xwidget-resize-at
287currently it rewrites the display spec. then it resizes the xwidget
288views. maybe rewriting the spec should be sufficient, and changes to
289it be picked up during redisplay somehow.
290
291** TODO display spec validation
292it is an error to reuse xwidgets in several buffers or in the same
293buffer. how do we catch these errors?
294
295
diff --git a/lisp/xwidget-test.el b/lisp/xwidget-test.el
index b9291c66853..2c73f4fd3ce 100644
--- a/lisp/xwidget-test.el
+++ b/lisp/xwidget-test.el
@@ -52,6 +52,11 @@
52 (xwidget-insert (point-min) 'slider "slider" 500 100 5) 52 (xwidget-insert (point-min) 'slider "slider" 500 100 5)
53 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) 53 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
54 54
55(xwidget-demo "a-canvas"
56 (xwidget-insert (point-min) 'cairo "canvas" 1000 1000 5)
57 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
58
59
55 60
56(xwidget-demo "basic" 61(xwidget-demo "basic"
57 (xwidget-insert (point-min) 'button "button" 40 50 1) 62 (xwidget-insert (point-min) 'button "button" 40 50 1)
diff --git a/src/xterm.c b/src/xterm.c
index ea03c04ce50..9bdbc1f7d34 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9911,7 +9911,11 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9911 https://bugzilla.gnome.org/show_bug.cgi?id=563627. */ 9911 https://bugzilla.gnome.org/show_bug.cgi?id=563627. */
9912 id = g_log_set_handler ("GLib", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL 9912 id = g_log_set_handler ("GLib", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
9913 | G_LOG_FLAG_RECURSION, my_log_handler, NULL); 9913 | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
9914#ifdef HAVE_CLUTTER
9915 gtk_clutter_init (&argc, &argv2);
9916#else
9914 gtk_init (&argc, &argv2); 9917 gtk_init (&argc, &argv2);
9918#endif
9915 g_log_remove_handler ("GLib", id); 9919 g_log_remove_handler ("GLib", id);
9916 9920
9917 /* gtk_init does set_locale. We must fix locale after calling it. */ 9921 /* gtk_init does set_locale. We must fix locale after calling it. */
diff --git a/src/xwidget.c b/src/xwidget.c
index 427004029d4..870054469c0 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -72,6 +72,17 @@
72#include <gtk/gtk.h> 72#include <gtk/gtk.h>
73#include <gdk/gdk.h> 73#include <gdk/gdk.h>
74 74
75#include <librsvg/rsvg.h>
76
77#ifdef HAVE_GOOCANVAS
78#include <goocanvas.h>
79#endif
80
81#ifdef HAVE_CLUTTER
82#include <clutter/clutter.h>
83#include <clutter-gtk/clutter-gtk.h>
84#endif
85
75#include "xwidget.h" 86#include "xwidget.h"
76 87
77//TODO should of course not be a hardcoded array but I can't be bothered atm 88//TODO should of course not be a hardcoded array but I can't be bothered atm
@@ -209,8 +220,8 @@ void xwidget_slider_changed (GtkRange *range,
209 //correspondingly. but remember that changing value will again 220 //correspondingly. but remember that changing value will again
210 //trigger signal 221 //trigger signal
211 222
212 //TODO view storage wont be an array futureish so the loop needs to change eventually 223 //TODO MVC view storage wont be an array futureish so the loop needs to change eventually
213 //TODO it would be nice if this code could be reusable but, alas, C is not a functional language 224 //TODO MVC it would be nice if this code could be reusable but, alas, C is not a functional language
214 //issues are: 225 //issues are:
215 // - the type of the controllers value (double, boolean etc) 226 // - the type of the controllers value (double, boolean etc)
216 // - the getter and setter (but they can be func pointers) 227 // - the getter and setter (but they can be func pointers)
@@ -245,7 +256,7 @@ int xwidget_view_index=0;
245/* initializes and does initial placement of an xwidget view on screen */ 256/* initializes and does initial placement of an xwidget view on screen */
246struct xwidget_view* 257struct xwidget_view*
247xwidget_init_view ( 258xwidget_init_view (
248 struct xwidget *xww, 259 struct xwidget *xww,
249 struct glyph_string *s, 260 struct glyph_string *s,
250 int x, int y) 261 int x, int y)
251{ 262{
@@ -282,6 +293,52 @@ xwidget_init_view (
282 //Cairo view 293 //Cairo view
283 //uhm cairo is differentish in gtk 3. 294 //uhm cairo is differentish in gtk 3.
284 //gdk_cairo_create (gtk_widget_get_window (f->gwfixed)); 295 //gdk_cairo_create (gtk_widget_get_window (f->gwfixed));
296#ifdef HAVE_GOOCANVAS
297 xv->widget = goo_canvas_new();
298 GooCanvasItem *root, *rect_item, *text_item;
299 goo_canvas_set_bounds (GOO_CANVAS (xv->widget), 0, 0, 1000, 1000);
300 root = goo_canvas_get_root_item (GOO_CANVAS (xv->widget));
301 rect_item = goo_canvas_rect_new (root, 100, 100, 400, 400,
302 "line-width", 10.0,
303 "radius-x", 20.0,
304 "radius-y", 10.0,
305 "stroke-color", "yellow",
306 "fill-color", "red",
307 NULL);
308
309 text_item = goo_canvas_text_new (root, "Hello World", 300, 300, -1,
310 GTK_ANCHOR_CENTER,
311 "font", "Sans 24",
312 NULL);
313 goo_canvas_item_rotate (text_item, 45, 300, 300);
314
315#endif
316#ifdef HAVE_CLUTTER
317 xv->widget = gtk_clutter_embed_new ();;
318 ClutterActor *stage = NULL;
319 stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED ( xv->widget));
320 ClutterColor stage_color = { 0xaa, 0xaa, 0xaa, 0xff }; /* Black */
321 clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
322
323 ClutterActor * texture = clutter_cairo_texture_new (1000, 1000);
324 clutter_container_add_actor(stage, texture);
325 clutter_actor_set_position(texture, 0,0);
326 clutter_actor_show(texture);
327
328 cairo_t *cr;
329 cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (texture));
330
331 /* draw on the context */
332 RsvgHandle *h = rsvg_handle_new_from_file ("/tmp/tst.svg",
333 NULL);
334
335 rsvg_handle_render_cairo(h, cr);
336 cairo_destroy (cr);
337
338 /* Show the stage: */
339 clutter_actor_show (stage);
340#endif
341
285 } else return NULL; 342 } else return NULL;
286 343
287 //widget realization 344 //widget realization
@@ -468,7 +525,7 @@ DEFUN ("xwidget-embed-steal-window", Fxwidget_embed_steal_window, Sxwidget_embed
468 525
469 526
470DEFUN ("xwidget-resize-internal", Fxwidget_resize_internal, Sxwidget_resize_internal, 3, 3, 0, doc: 527DEFUN ("xwidget-resize-internal", Fxwidget_resize_internal, Sxwidget_resize_internal, 3, 3, 0, doc:
471 /* resize xwidgets */) 528 /* resize xwidgets internal use only, because the lisp specs need to be updated also*/)
472 (Lisp_Object xwidget_id, Lisp_Object new_width, Lisp_Object new_height) 529 (Lisp_Object xwidget_id, Lisp_Object new_width, Lisp_Object new_height)
473{ 530{
474 struct xwidget *xw; 531 struct xwidget *xw;
@@ -486,12 +543,6 @@ DEFUN ("xwidget-resize-internal", Fxwidget_resize_internal, Sxwidget_resize_inte
486 printf("resize xwidget %d (%d,%d)->(%d,%d)",xid,xw->width,xw->height,w,h); 543 printf("resize xwidget %d (%d,%d)->(%d,%d)",xid,xw->width,xw->height,w,h);
487 xw->width=w; 544 xw->width=w;
488 xw->height=h; 545 xw->height=h;
489 /*
490 //this will be more complex, need to iterate all views and resize each. tedious TODO MVC
491 gtk_layout_set_size (GTK_LAYOUT (xw->widgetwindow), xw->width, xw->height);
492 gtk_widget_set_size_request (GTK_WIDGET (xw->widget), xw->width,
493 xw->height);
494 */
495 for (int i = 0; i < MAX_XWIDGETS; i++) //TODO MVC refactor lazy linear search 546 for (int i = 0; i < MAX_XWIDGETS; i++) //TODO MVC refactor lazy linear search
496 { 547 {
497 xv = &xwidget_views[i]; 548 xv = &xwidget_views[i];
@@ -538,7 +589,7 @@ DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_key
538 xid = XFASTINT (xwidget_id); 589 xid = XFASTINT (xwidget_id);
539 kbd_flag = XFASTINT (kbd_grab); 590 kbd_flag = XFASTINT (kbd_grab);
540 xw = &xwidgets[xid]; 591 xw = &xwidgets[xid];
541 if(xw->type != 3) return Qnil; //only relevant for xembed 592 if(xw->type != 3) return Qnil; //only relevant for xembed //TODO MVC
542 593
543 printf ("kbd grab: %d %d\n", xid, kbd_flag); 594 printf ("kbd grab: %d %d\n", xid, kbd_flag);
544 if (kbd_flag) 595 if (kbd_flag)