aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c4
-rw-r--r--src/xwidget.c73
2 files changed, 66 insertions, 11 deletions
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)